Skip to content

Commit 722e31c

Browse files
szedergitster
authored andcommitted
completion: move __git_complete_index_file() next to its helpers
It's much easier to read, understand and modify the functions related to git-aware path completion when they are right next to each other. Signed-off-by: SZEDER Gábor <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5bb534a commit 722e31c

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

contrib/completion/git-completion.bash

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,25 @@ __git_index_files ()
398398
done | sort | uniq
399399
}
400400

401+
# __git_complete_index_file requires 1 argument:
402+
# 1: the options to pass to ls-file
403+
#
404+
# The exception is --committable, which finds the files appropriate commit.
405+
__git_complete_index_file ()
406+
{
407+
local pfx="" cur_="$cur"
408+
409+
case "$cur_" in
410+
?*/*)
411+
pfx="${cur_%/*}"
412+
cur_="${cur_##*/}"
413+
pfx="${pfx}/"
414+
;;
415+
esac
416+
417+
__gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_"
418+
}
419+
401420
# Lists branches from the local repository.
402421
# 1: A prefix to be added to each listed branch (optional).
403422
# 2: List only branches matching this word (optional; list all branches if
@@ -714,26 +733,6 @@ __git_complete_revlist_file ()
714733
esac
715734
}
716735

717-
718-
# __git_complete_index_file requires 1 argument:
719-
# 1: the options to pass to ls-file
720-
#
721-
# The exception is --committable, which finds the files appropriate commit.
722-
__git_complete_index_file ()
723-
{
724-
local pfx="" cur_="$cur"
725-
726-
case "$cur_" in
727-
?*/*)
728-
pfx="${cur_%/*}"
729-
cur_="${cur_##*/}"
730-
pfx="${pfx}/"
731-
;;
732-
esac
733-
734-
__gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_"
735-
}
736-
737736
__git_complete_file ()
738737
{
739738
__git_complete_revlist_file

0 commit comments

Comments
 (0)