tags:

views:

128

answers:

3

We work in a mixed case sensitive/insensitive environment (cywgin/linux), and today someone created a small havoc in our workflow by renaming a file, changing an S to an s. This caused all sorts of interesting merge issues across branches, and to be quite honest no-one's entirely sure of what happened.

What is the most appropriate way to change casing of a file under git for cygwin? I must stress that we are case sensitive and normally do this right - if it wasn't for that S.

+2  A: 

Having thought about it a couple minutes, it seems very likely git-mv would do what you need to. I'm fairly sure that it will attempt the rename (which might be a no-op on a a case-insensitive OS) then add the rename to the index. This should be based on the arguments, not on the actual file - I see rename_cache_entry_at(pos, dst); in builtin-mv.c.

I'm not sure if this is part of what you're asking or not, but with respect to your branch chaos, here's the general approach you probably want to take:

  • Commit the rename fix to all of your "farthest downward" branches. These are probably topic and maintenance branches - the ones that are merged into other branches, but never have branches merged to them
  • Merge these branches as per your normal workflow, fixing any conflicts that may result from the rename.
  • Encourage everyone to pull soon, just in case the issue has a way to propagate further. For example, someone could work on the renamed file, then pull, and fix the rename conflict the wrong way, resulting in a state which would recreate the problem when pushed/pulled.
Jefromi
For others who find this, you will need to use "git mv -f" to force the rename, because Cygwin will complain that the source and destination are the same.
Christopher Currie
+1  A: 

I'd like to point that as a fallback you can manipulate entries in index (the staging area), from where you would be able to commit with "git commit" (not "git commit -a") with git update-index plumbing (low level) command.

Jakub Narębski
+1  A: 

I just had a problem similar to this where I just wanted to rename a directory, 'Scripts', to 'scripts'. I am currently working in Cygwin so it wasn't quite so easy. If I attempt to do it as I would in GNU/Linux, I get an error.

$ git mv foo Foo
fatal: renaming foo failed: Invalid argument

However, I realized I could bypass what I assume are Windows' shortcomings by moving twice, first to a name that doesn't collide, and then to the actually desired name.

$ git mv foo Foo2 && git mv Foo2 Foo

I had stashed my working tree away for this change though so I could commit it separately and evidently didn't think things through because now the files beneath the directory that I moved fail to merge from the stash to my tree. :-/ In my case, it's a minor problem though (and to be safe, I tarballed the tree before attempting this, I so I can always just do it the forceful unversioned way... :P).

bamccaig