Skip to content

Commit

Permalink
completion: refactor __git_complete_index_file()
Browse files Browse the repository at this point in the history
The calls to __gitcomp_file() are essentially the same, but with
different prefix.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Felipe Contreras authored and Junio C Hamano committed Apr 27, 2013
1 parent f825972 commit fda54ef
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions contrib/completion/git-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -535,20 +535,17 @@ __git_complete_revlist_file ()
# The exception is --committable, which finds the files appropriate commit.
__git_complete_index_file ()
{
local pfx cur_="$cur"
local pfx="" cur_="$cur"

case "$cur_" in
?*/*)
pfx="${cur_%/*}"
cur_="${cur_##*/}"
pfx="${pfx}/"

__gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_"
;;
*)
__gitcomp_file "$(__git_index_files "$1")" "" "$cur_"
;;
esac

__gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_"
}

__git_complete_file ()
Expand Down

0 comments on commit fda54ef

Please sign in to comment.