Wednesday, November 05, 2014

Git line ending fixups revisited

I blogged about this a few years ago. I discovered how to do this when using .gitattributes, which is automatically created when you use Visual Studio to create a project that uses git as its version control system.

I have a .gitattributes file that contains (among other things) this line at the top:
The sequence of commands is the following:

First, add all changed files: Then, edit the .gitattributes file to comment out the "text=auto" line and save this file: Then issue this command to un-stage all the files. It doesn't matter whether some of the files have meaningful changes. You're not resetting or undoing any file edits, you're merely removing them from the index: Finally, restore the "text=auto" line in your .gitattributes file and save that file: You should be all set. If you issue a git status command again you should see only the files that have meaningful changes, if any.

Friday, September 26, 2014

Beyond SOLID: The Dependency Elimination Principle

http://qualityisspeed.blogspot.com/2014/09/beyond-solid-dependency-elimination.html
Last post I explained why I don't teach the SOLID design principles. Read the post for more detail, but the primary reason is that SOLID encourages heavy use of dependencies. Applying SOLID to a codebase for even a short time will yield dependencies on abstractions everywhere -- quickly producing a codebase that is unintelligible.

Friday, September 05, 2014

git cherry

My mnemonic for git cherry, i.e. git cherry upstream [head]

My quick understanding is that in many cases it means: show me everything that's NOT in upstream.

In other words:

git cherry branch-without-stuff branch-with-stuff

or

git cherry less-stuff more-stuff

or

git cherry present future

or

git cherry past present


So to see what's in develop but not yet in master, type this:

git cherry master develop

Which means, essentially, show me everything in develop that's not (yet) in master. 

Wednesday, August 20, 2014

Strongly-typed function callbacks in TypeScript

The question: http://stackoverflow.com/questions/14638990/are-strongly-typed-functions-as-parameters-possible-in-typescript
In TypeScript I can declare a parameter of a function as a type Function. Is there a "type-safe" way of doing this that I am missing?
My favorite answer: http://stackoverflow.com/a/24034429/53107 from Drew Noakes:
Here are TypeScript equivalents of some common .NET delegates:
interface Action<T>
{
    (item: T): void;
}

interface Func<T,TResult>
{
    (item: T): TResult;
}

Renaming a remote branch in Git

I don't quite understand this, but I'll post it here anyway. It comes from StackOverflow user sschuberth.

git push <remote> <remote>/<old_name>:refs/heads/<new_name> :<old_name>

Example:
git push origin origin/hotfix/Cant-load-assembly.0:refs/heads/feature/Fix-cant-load-assembly :hotfix/Cant-load-assembly.0

Source: http://stackoverflow.com/a/21302474/53107