]> git.ipfire.org Git - thirdparty/git.git/commit
completion: support pseudoref existence checks for reftables
authorStan Hu <stanhu@gmail.com>
Tue, 19 Dec 2023 22:14:18 +0000 (14:14 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 19 Dec 2023 23:11:58 +0000 (15:11 -0800)
commit44dbb3bf29a7e27ee2f52b5ab86347618c879811
tree2197e6aeb6815db15543fa955ef48e2e8ca8a754
parent666270a2df49132c683f53b5efde240dd9bf5c5e
completion: support pseudoref existence checks for reftables

In contrib/completion/git-completion.bash, there are a bunch of
instances where we read pseudorefs, such as HEAD, MERGE_HEAD,
REVERT_HEAD, and others via the filesystem. However, the upcoming
reftable refs backend won't use '.git/HEAD' at all but instead will
write an invalid refname as placeholder for backwards compatibility,
which will break the git-completion script.

Update the '__git_pseudoref_exists' function to:

1. Recognize the placeholder '.git/HEAD' written by the reftable
   backend (its content is specified in the reftable specs).
2. If reftable is in use, use 'git rev-parse' to determine whether the
    given ref exists.
3. Otherwise, continue to use 'test -f' to check for the ref's filename.

Signed-off-by: Stan Hu <stanhu@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-completion.bash