Git Gripe

Git and renaming files

There’s an entry here about how intelligent Git is in detecting renamed files or folders.  When I hear that, I think “Oh, so I can rename something on the filesystem and git will automatically detect that when I do a status or a commit (albeit the latter is functionality I may not want).

Turns out that’s not the case.  Git can detect renames without you explicitly performing a ‘git mv’.  However after you do the operation outlined above, a ‘git status’ will only show a deleted file and an untracked file and not the desired rename.  So where’s the magic?  Turns out you have to add the untracked file and even then a ‘git status’ won’t show you the intelligence at work.  You have to do a ‘git commit -a –dry-run’, in which case git will show that it found the connection between the old and new file.

Here’s a screencast that illustrates what I’m talking about.

This is on git version 1.7.2.3

Here’s the link that started me on this thread.  Took a bit too much discussion for the guy to get his answer.

http://stackoverflow.com/questions/2641146/handling-file-renames-in-git

Language inconsistencies Part 1

First in a series of posts about inconsistences in computing languages

First up is Python and the way strings are read.  The following are two ways to access a part of a string.  One produces an error while the other doesn’t.

First, the one that produces an error

print ”.[0]  # access the first element of an empty string produces an error

You would think this second example would produce an error too, but on the contrary.

print ”.[0:]  # accessing the string using a sequence (note the colon) doesn’t produce an error.