Skip to content

Commit 6bf0ced

Browse files
szedergitster
authored andcommitted
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 fca416a (completion: use "git -C $there" instead of (cd $there && git ...), 2014-10-09). Those extra steps are not needed since 6a536e2 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 722e31c commit 6bf0ced

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

contrib/completion/git-completion.bash

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ __git_ls_files_helper ()
387387
# slash.
388388
__git_index_files ()
389389
{
390-
local root="${2-.}" file
390+
local root="$2" file
391391

392392
__git_ls_files_helper "$root" "$1" |
393393
while read -r file; do
@@ -408,13 +408,12 @@ __git_complete_index_file ()
408408

409409
case "$cur_" in
410410
?*/*)
411-
pfx="${cur_%/*}"
411+
pfx="${cur_%/*}/"
412412
cur_="${cur_##*/}"
413-
pfx="${pfx}/"
414413
;;
415414
esac
416415

417-
__gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_"
416+
__gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_"
418417
}
419418

420419
# Lists branches from the local repository.

0 commit comments

Comments
 (0)