Draft: reftable: stop reading pseudorefs via the filesystem in git-completion
In contrib/completion/git-completion.bash, there were a bunch of instances where we read special refs like HEAD, MERGE_HEAD, REVERT_HEAD, and others via the filesystem. However, the upcoming reftable refs backend won't use '.git/HEAD' at all, but will write an invalid refname as placeholder for backwards compatibility instead, which will break the git-completion script.
Update the git-completion script with a '__git_ref_exists' function that will:
- Recognize the placeholder '.git/HEAD' written by the reftable backend (its content is specified in the reftable specs).
- If reftable is in use, use 'git rev-parse' to determine whether the given ref exists.
- Otherwise, check for the ref's filename.
To simplify the code, each caller of '__git_ref_exists' must call '__git_find_repo_path` first. '_git_restore' already used 'git rev-parse HEAD', but to use '__git_ref_exists' insert a '__git_find_repo_path' at the start.
Relates to #213 (closed)
Edited by Stan Hu