{"thread":{"id":"46356","subject":"bug: HEAD vs. head on case-insensitive filesystems","startedAt":"2017-07-11T03:32:48Z","lastAt":"2017-07-12T02:37:23Z","messageCount":3,"participants":["Kenneth Hsu","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"324146","messageId":"20170711033236.GA11492@lenny.localdomain","threadId":"46356","inReplyTo":null,"subject":"bug: HEAD vs. head on case-insensitive filesystems","fromName":"Kenneth Hsu","fromEmail":"kennethhsu@gmail.com","sentAt":"2017-07-11T03:32:36Z","receivedAt":"2017-07-11T03:32:48Z","isPatch":false,"sender":{"key":"kennethhsu@gmail.com","avatar":null},"body":"I'm not sure what the general consensus is regarding the use of \"head\"\nvs. \"HEAD\" on case insensitive filesystems, but it appears that some\nconfusing behavior (bug?) may have arisen.\n\nTo summarize, \"HEAD\" and \"head\" may resolve to different revisions when\nin a worktree.  The following example was generated using git version\n2.13.1 for Mac (HFS+):\n\n$ git --version\ngit version 2.13.1\n$ git init\nInitialized empty Git repository in /Users/ken/Desktop/test/.git/\n\n$ echo \"Hello\" > hello.txt\n$ git add . && git commit -qm \"Add hello.\"\n\n$ echo \"Bye\" > bye.txt\n$ git add . && git commit -qm \"Add bye.\"\n\nNote that at this point, both HEAD and head (correctly) resolve to the\nsame revision:\n\n$ git rev-parse HEAD\n4a71a947fb683698f80f543f9cd27acd066e2659\n\n$ git rev-parse head\n4a71a947fb683698f80f543f9cd27acd066e2659\n\nHowever, if we create (and cd into) a worktree based on \"master~\", \"HEAD\" and\n\"head\" resolve to _different_ revisions:\n\n$ git worktree add -b feature/branch ../branch master~\nPreparing ../branch (identifier branch)\nHEAD is now at f752545 Add hello.\n$ cd ../branch/\n\n$ git rev-parse HEAD\nf7525451640f6f5e8842cc00b6639c80558dd6c2\n\n$ git rev-parse head\n4a71a947fb683698f80f543f9cd27acd066e2659\n\n$ git rev-parse master\n4a71a947fb683698f80f543f9cd27acd066e2659\n\n$ git rev-parse master~\nf7525451640f6f5e8842cc00b6639c80558dd6c2\n\n$ git rev-parse feature/branch\nf7525451640f6f5e8842cc00b6639c80558dd6c2\n\nNote that \"HEAD\" resolves to the same revision as \"master~\" and\n\"feature/branch\" (which seems correct since that is what the worktree\nwas based on), while \"head\" resolves to the same revision as \"master\".\n\nThis appears to affect other case-insensitive filesystems (Windows) as\nwell.  See the following bug report:\n\nhttps://github.com/git-for-windows/git/issues/1225\n\nI'm not sure if the behavior is well-defined when using \"head\", but the\nabove example may illustrate a case where users should not assume that\nthey resolve to the same thing.\n\nThanks.\n\n"},{"id":"324155","messageId":"20170711071234.bj3kzfn5xii4e33w@sigill.intra.peff.net","threadId":"46356","inReplyTo":"20170711033236.GA11492@lenny.localdomain","subject":"Re: bug: HEAD vs. head on case-insensitive filesystems","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-07-11T07:12:34Z","receivedAt":"2017-07-11T07:12:41Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jul 10, 2017 at 08:32:36PM -0700, Kenneth Hsu wrote:\n\n> I'm not sure what the general consensus is regarding the use of \"head\"\n> vs. \"HEAD\" on case insensitive filesystems, but it appears that some\n> confusing behavior (bug?) may have arisen.\n\nGenerally, the advice on \"head\" is \"don't\". It's an accident that\nit works at all, and as you noticed, there are odd corner cases. There\nare similar oddities when mixing and matching case for other refnames on\ncase-insensitive filesystems, too.\n\nI was going to point you to the recent thread in\n\n  http://public-inbox.org/git/87ziclb2pa.fsf@gmail.com/\n\nbut I see you already participated there. So if your mail here is\n\"here's a summary of how HEAD/head don't quite work\", then OK, that\nmight be handy. But I think the ultimate resolution is not \"let's make\nthem work\", but \"let's consistently enforce case-sensitivity in ref\nnames, regardless of the underlying filesystem\".\n\n-Peff\n"},{"id":"324254","messageId":"20170712023655.GA15598@lenny.localdomain","threadId":"46356","inReplyTo":"20170711071234.bj3kzfn5xii4e33w@sigill.intra.peff.net","subject":"Re: bug: HEAD vs. head on case-insensitive filesystems","fromName":"Kenneth Hsu","fromEmail":"kennethhsu@gmail.com","sentAt":"2017-07-12T02:37:10Z","receivedAt":"2017-07-12T02:37:23Z","isPatch":false,"sender":{"key":"kennethhsu@gmail.com","avatar":null},"body":"> I was going to point you to the recent thread in\n> \n>   http://public-inbox.org/git/87ziclb2pa.fsf@gmail.com/\n> \n> but I see you already participated there. So if your mail here is\n> \"here's a summary of how HEAD/head don't quite work\", then OK, that\n> might be handy. But I think the ultimate resolution is not \"let's make\n> them work\", but \"let's consistently enforce case-sensitivity in ref\n> names, regardless of the underlying filesystem\".\n\nThanks, that makes sense.  Perhaps it's best to just view my original\nmessage as, \"here's a new example of where 'head' doesn't work\".\n"}]}