Skip to content

Commit 98349e5

Browse files
committed
Merge branch 'jc/completion-no-chdir'
* jc/completion-no-chdir: completion: use "git -C $there" instead of (cd $there && git ...)
2 parents c11dc64 + fca416a commit 98349e5

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

contrib/completion/git-completion.bash

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -281,16 +281,12 @@ __gitcomp_file ()
281281
# argument, and using the options specified in the second argument.
282282
__git_ls_files_helper ()
283283
{
284-
(
285-
test -n "${CDPATH+set}" && unset CDPATH
286-
cd "$1"
287-
if [ "$2" == "--committable" ]; then
288-
git diff-index --name-only --relative HEAD
289-
else
290-
# NOTE: $2 is not quoted in order to support multiple options
291-
git ls-files --exclude-standard $2
292-
fi
293-
) 2>/dev/null
284+
if [ "$2" == "--committable" ]; then
285+
git -C "$1" diff-index --name-only --relative HEAD
286+
else
287+
# NOTE: $2 is not quoted in order to support multiple options
288+
git -C "$1" ls-files --exclude-standard $2
289+
fi 2>/dev/null
294290
}
295291

296292

@@ -522,7 +518,7 @@ __git_complete_index_file ()
522518
;;
523519
esac
524520

525-
__gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_"
521+
__gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_"
526522
}
527523

528524
__git_complete_file ()

0 commit comments

Comments
 (0)