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 <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
SZEDER Gábor committed
Apr 17, 2018 at 00:41 UTC
722e31c713a2f33dc483c0f17f208b2260faebe4
1 file changed
+19
-20
contrib/completion/git-completion.bash
+19
-20
@@ -398,6 +398,25 @@ __git_index_files ()
398
done | sort | uniq
399
}
400
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
+
420
# Lists branches from the local repository.
421
# 1: A prefix to be added to each listed branch (optional).
422
# 2: List only branches matching this word (optional; list all branches if
@@ -714,26 +733,6 @@ __git_complete_revlist_file ()
733
esac
734
}
735
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
-
736
__git_complete_file ()
737
{
738
__git_complete_revlist_file