completion: simplify prefix path component handling during path completion
Once upon a time 'git -C "" cmd' errored out with "Cannot change to '': No such file or directory", therefore the completion script took extra steps to run 'git -C "." cmd' instead; see fca416a41e (completion: use "git -C $there" instead of (cd $there && git ...), 2014-10-09). Those extra steps are not needed since 6a536e2076 (git: treat "git -C '<path>'" as a no-op when <path> is empty, 2015-03-06), so remove them. While at it, also simplify how the trailing '/' is appended to the variable holding the prefix path components. 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
6bf0ced4e21bfc757641ec537b8bb9dd63ece904
1 file changed
+3
-4
contrib/completion/git-completion.bash
+3
-4
@@ -387,7 +387,7 @@ __git_ls_files_helper ()
387
# slash.
388
__git_index_files ()
389
{
390
- local root="${2-.}" file
390
+ local root="$2" file
391
392
__git_ls_files_helper "$root" "$1" |
393
while read -r file; do
@@ -408,13 +408,12 @@ __git_complete_index_file ()
408
409
case "$cur_" in
410
?*/*)
411
- pfx="${cur_%/*}"
411
+ pfx="${cur_%/*}/"
412
cur_="${cur_##*/}"
413
- pfx="${pfx}/"
413
;;
414
esac
415
417
- __gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_"
416
+ __gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_"
417
}
418
419
# Lists branches from the local repository.