Skip to content

Commit 3bf5ccf

Browse files
pks-tgitster
authored andcommitted
completion: discover repo path in __git_pseudoref_exists ()
The helper function `__git_pseudoref_exists ()` expects that the repo path has already been discovered by its callers, which makes for a rather fragile calling convention. Refactor the function to discover the repo path itself to make it more self-contained, which also removes the need to discover the path in some of its callers. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d4dbce1 commit 3bf5ccf

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

contrib/completion/git-completion.bash

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ __git_pseudoref_exists ()
138138
{
139139
local ref=$1
140140

141+
__git_find_repo_path
142+
141143
# If the reftable is in use, we have to shell out to 'git rev-parse'
142144
# to determine whether the ref exists instead of looking directly in
143145
# the filesystem to determine whether the ref exists. Otherwise, use
@@ -1656,7 +1658,6 @@ __git_cherry_pick_inprogress_options=$__git_sequencer_inprogress_options
16561658

16571659
_git_cherry_pick ()
16581660
{
1659-
__git_find_repo_path
16601661
if __git_pseudoref_exists CHERRY_PICK_HEAD; then
16611662
__gitcomp "$__git_cherry_pick_inprogress_options"
16621663
return
@@ -2966,7 +2967,6 @@ _git_reset ()
29662967

29672968
_git_restore ()
29682969
{
2969-
__git_find_repo_path
29702970
case "$prev" in
29712971
-s)
29722972
__git_complete_refs
@@ -2995,7 +2995,6 @@ __git_revert_inprogress_options=$__git_sequencer_inprogress_options
29952995

29962996
_git_revert ()
29972997
{
2998-
__git_find_repo_path
29992998
if __git_pseudoref_exists REVERT_HEAD; then
30002999
__gitcomp "$__git_revert_inprogress_options"
30013000
return

0 commit comments

Comments
 (0)