git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / Atom feed
From: Kenneth Hsu <kennethhsu@gmail.com>
To: git@vger.kernel.org
Subject: bug: HEAD vs. head on case-insensitive filesystems
Date: Mon, 10 Jul 2017 20:32:36 -0700
Message-ID: <20170711033236.GA11492@lenny.localdomain> (raw)

I'm not sure what the general consensus is regarding the use of "head"
vs. "HEAD" on case insensitive filesystems, but it appears that some
confusing behavior (bug?) may have arisen.

To summarize, "HEAD" and "head" may resolve to different revisions when
in a worktree.  The following example was generated using git version
2.13.1 for Mac (HFS+):

$ git --version
git version 2.13.1
$ git init
Initialized empty Git repository in /Users/ken/Desktop/test/.git/

$ echo "Hello" > hello.txt
$ git add . && git commit -qm "Add hello."

$ echo "Bye" > bye.txt
$ git add . && git commit -qm "Add bye."

Note that at this point, both HEAD and head (correctly) resolve to the
same revision:

$ git rev-parse HEAD
4a71a947fb683698f80f543f9cd27acd066e2659

$ git rev-parse head
4a71a947fb683698f80f543f9cd27acd066e2659

However, if we create (and cd into) a worktree based on "master~", "HEAD" and
"head" resolve to _different_ revisions:

$ git worktree add -b feature/branch ../branch master~
Preparing ../branch (identifier branch)
HEAD is now at f752545 Add hello.
$ cd ../branch/

$ git rev-parse HEAD
f7525451640f6f5e8842cc00b6639c80558dd6c2

$ git rev-parse head
4a71a947fb683698f80f543f9cd27acd066e2659

$ git rev-parse master
4a71a947fb683698f80f543f9cd27acd066e2659

$ git rev-parse master~
f7525451640f6f5e8842cc00b6639c80558dd6c2

$ git rev-parse feature/branch
f7525451640f6f5e8842cc00b6639c80558dd6c2

Note that "HEAD" resolves to the same revision as "master~" and
"feature/branch" (which seems correct since that is what the worktree
was based on), while "head" resolves to the same revision as "master".

This appears to affect other case-insensitive filesystems (Windows) as
well.  See the following bug report:

https://github.com/git-for-windows/git/issues/1225

I'm not sure if the behavior is well-defined when using "head", but the
above example may illustrate a case where users should not assume that
they resolve to the same thing.

Thanks.


             reply index

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-11  3:32 Kenneth Hsu [this message]
2017-07-11  7:12 ` Jeff King
2017-07-12  2:37   ` Kenneth Hsu

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170711033236.GA11492@lenny.localdomain \
    --to=kennethhsu@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

git@vger.kernel.org list mirror (unofficial, one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git