]> git.ipfire.org Git - thirdparty/git.git/commit
worktree add: stop reading ".git/HEAD"
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Thu, 26 Mar 2026 14:16:58 +0000 (14:16 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 26 Mar 2026 15:20:50 +0000 (08:20 -0700)
commit8bad0e07e1eddff2268bc9be3368c9b5fee47915
tree1ecb360702e1776dde61e023ca45c69a5cb2fa6e
parent0f7791476029b73ca9b7dfc0816bfee5f21c0dbb
worktree add: stop reading ".git/HEAD"

The function can_use_local_refs() prints a warning if there are no local
branches and HEAD is invalid or points to an unborn branch. As part of
the warning it prints the contents of ".git/HEAD". In a repository using
the reftable backend HEAD is not stored in the filesystem so reading
that file is pointless. In a repository using the files backend it is
unclear how useful printing it is - it would be better to diagnose the
problem for the user. For now, simplify the warning by not printing
the file contents and adjust the relevant test case accordingly. Also
fixup the test case to use test_grep so that anyone trying to debug a
test failure in the future is not met by a wall of silence.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/worktree.c
t/t2400-worktree-add.sh