Re: [RFC] File system difference handling in git
- From
Steffen Prohaska <prohaska@zib.de>
- Date
- Jan 22, 2008, 17:44 UTC
- Message-ID
- <0AEE94F5-C0B2-4B92-AD99-8BF2298428AF@zib.de>
- In-Reply-To
- <3f4fd2640801220252q6a6557cdma4ca0a2c41223593@mail.gmail.com>
On Jan 22, 2008, at 11:52 AM, Reece Dunn wrote:
Show 38 quoted lines
>>> 2. Case (in)sensitivity >>> >>> Here, you have the following cases: >>> ... >>> 3. git says that the files are different, but the filesystem says >>> that the files are the same. >>> >>> Allow the move, updating the git directory tree only. >> >> Sorry, I cannot really tell what you are talking about. You >> seem to imply, with "Allow the move", that you are describing a >> scenario that involves a move of one existing file to another, >> but it is not clear. E.g. did you mean, by 3, "When the user >> says 'move a b', and if git says a and b are different but if >> the filesystem says a and b are the same, then..."? > > This is what I am saying. For example, if you say: > > git mv myfile.H myfile.h > > on a case sensitive filesystem (e.g. ext3), this will work, however on > a case insensitive filesystem (e.g. ntfs) git would complain that the > files are the same. > > The workaround is to say: > > git mv myfile.H myfile.h.tmp > git mv myfile.h.tmp myfile.h > > but this is not ideal, especially if you are automating some move > operations. > > This also applies to the VCS importers (e.g. git-p4) that can delete a > file that is a case-only move on case insensitive filesystems. > > The question then becomes what happens on Mac (with the Unicode > decomposing behaviour) if they differ in the way they are stored (e.g. > in Linus' 'ä' vs 'a¨' example)?
You can work around the problem as you described; but later git will hit you again and fails unexpectedly when you try to merge your change.
So better avoid renames that only change case until git at least passes the two test below.
Steffen
---- snip ---
Git behaves strangely (from a user's point of view) on filesystems that preserve case but do not distinguish it. The two major examples are Windows and Mac OS X. Simple operations such as "git mv" or "git merge" can fail unexpectedly.
This commit adds two simple tests. Both tests currently fail on Windows and Mac, although they pass on Linux.
Signed-off-by: Steffen Prohaska <prohaska@zib.de> --- t/t0050-filesystems.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+), 0 deletions(-) create mode 100755 t/t0050-filesystems.sh
diff --git a/t/t0050-filesystems.sh b/t/t0050-filesystems.sh new file mode 100755 index 0000000..953b02b --- /dev/null +++ b/t/t0050-filesystems.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +test_description='Various filesystems issues' + +. ./test-lib.sh + +test_expect_success setup ' + + touch camelcase && + git add camelcase && + git commit -m "initial" && + git tag initial && + git checkout -b topic && + git mv camelcase tmp && + git mv tmp CamelCase && + git commit -m "rename" && + git checkout -f master + +' + +test_expect_success 'rename (case change)' ' + + git mv camelcase CamelCase && + git commit -m "rename" + +' + +test_expect_success 'merge (case change)' ' + + git reset --hard initial && + git merge topic + +' + +test_done
-- 1.5.4.rc4