git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Confusing treatment of "head" in worktree on case-insensitive FS

From
Julia Evans <julia@jvns.ca>
Date
Jun 29, 2024, 14:39 UTC
Message-ID
<A72DCB1B-8D81-4DD7-93AD-BF37E88E9D63@jvns.ca>
Hello,

When I run `git rev-parse head` inside a worktree on a case insensitive filesystem, the result is different from `git rev-parse HEAD`.

Steps to reproduce, on a case insensitive filesystem:

$ git init $ git commit --allow-empty -m'test' $ git worktree add /tmp/myworktree $ cd /tmp/myworktree $ git commit --allow-empty -m'test' $ git rev-parse head adf59ca8da0ee5c4eb455f87efecc6c79eaf030f $ git rev-parse hEAd adf59ca8da0ee5c4eb455f87efecc6c79eaf030f $ git rev-parse HEAD fbb28196d08d74aa61f65e5cee3cb11cc24c338a

This also happens when using any other command involving "head", like `git show head`, `git diff head`, etc.

What did you expect to happen?

If `git rev-parse head` returns anything at all (of course on a case-sensitive filesystem it just returns an error), I'd expect it to be the same as `git rev-parse HEAD`.

I accidentally got into the happen of using `git diff head` instead of `git diff HEAD` on a case insensitive filesystem and was thrown off by this when I ran into it.

What happened instead?

When in a worktree, `head` appears to get resolved to the value of `HEAD` in `git rev-parse --git-common-dir`, while `HEAD` gets resolved to the value of `HEAD` in the worktree.

[System Info] git version: git version 2.39.2 (Apple Git-143) cpu: arm64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh feature: fsmonitor--daemon uname: Darwin 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:41 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T8103 arm64 compiler info: clang: 14.0.3 (clang-1403.0.22.14.1) libc info: no libc information available $SHELL (typically, interactive shell): /usr/bin/fish

Next: Jeff King
Message 1 of 4 in “Confusing treatment of "head" in worktree on case-insensitive FS”
  1. Julia EvansJun 29, 2024
  2. Jeff KingJul 1, 2024
  3. Phillip WoodJul 1, 2024
  4. Jeff KingJul 1, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.