From 6bf0ced4e21bfc757641ec537b8bb9dd63ece904 Mon Sep 17 00:00:00 2001 From: =?utf8?q?SZEDER=20G=C3=A1bor?= Date: Tue, 17 Apr 2018 00:41:07 +0200 Subject: [PATCH] completion: simplify prefix path component handling during path completion MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 ''" as a no-op when 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 Signed-off-by: Junio C Hamano --- contrib/completion/git-completion.bash | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index a87a8b2a7b..57fc7417f9 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -387,7 +387,7 @@ __git_ls_files_helper () # slash. __git_index_files () { - local root="${2-.}" file + local root="$2" file __git_ls_files_helper "$root" "$1" | while read -r file; do @@ -408,13 +408,12 @@ __git_complete_index_file () case "$cur_" in ?*/*) - pfx="${cur_%/*}" + pfx="${cur_%/*}/" cur_="${cur_##*/}" - pfx="${pfx}/" ;; esac - __gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_" + __gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_" } # Lists branches from the local repository. -- 2.11.4.GIT