summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSZEDER Gábor <szeder@ira.uka.de>2016-02-25 23:50:37 +0100
committerJunio C Hamano <gitster@pobox.com>2016-02-28 16:37:15 -0800
commit1678f4126dadafddfe0775a6b38aad7df4abca88 (patch)
tree300d3c83ae327682bb2b0d5cc066e66033589e12
parentb3e189d0bef0aa4fa03d2a277f7b902415adbc4e (diff)
downloadgit-1678f4126dadafddfe0775a6b38aad7df4abca88.tar.gz
completion: fix most spots not respecting 'git --git-dir=<path>'
The completion script already respects the path to the repository specified on the command line most of the time, here we add the necessary '--git-dir=$(__gitdir)' options to most of the places where git was executed without it. The exceptions where said option is not added are the git invocations: - in __git_refs() which are non-trivial and will be the subject of the following patch, - getting the list of git commands, merge strategies and archive formats, because these are independent from the repository and thus don't need it, and - the 'git rev-parse --git-dir' in __gitdir() itself. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--contrib/completion/git-completion.bash12
1 files changed, 7 insertions, 5 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 0ec988c0ee..59dffe7f39 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -283,11 +283,13 @@ __gitcomp_file ()
# argument, and using the options specified in the second argument.
__git_ls_files_helper ()
{
+ local dir="$(__gitdir)"
+
if [ "$2" == "--committable" ]; then
- git -C "$1" diff-index --name-only --relative HEAD
+ git --git-dir="$dir" -C "$1" diff-index --name-only --relative HEAD
else
# NOTE: $2 is not quoted in order to support multiple options
- git -C "$1" ls-files --exclude-standard $2
+ git --git-dir="$dir" -C "$1" ls-files --exclude-standard $2
fi 2>/dev/null
}
@@ -407,7 +409,7 @@ __git_refs2 ()
__git_refs_remotes ()
{
local i hash
- git ls-remote "$1" 'refs/heads/*' 2>/dev/null | \
+ git --git-dir="$(__gitdir)" ls-remote "$1" 'refs/heads/*' 2>/dev/null | \
while read -r hash i; do
echo "$i:refs/remotes/$1/${i#refs/heads/}"
done
@@ -1138,7 +1140,7 @@ _git_commit ()
return
esac
- if git rev-parse --verify --quiet HEAD >/dev/null; then
+ if git --git-dir="$(__gitdir)" rev-parse --verify --quiet HEAD >/dev/null; then
__git_complete_index_file "--committable"
else
# This is the first commit
@@ -1431,7 +1433,7 @@ _git_log ()
{
__git_has_doubledash && return
- local g="$(git rev-parse --git-dir 2>/dev/null)"
+ local g="$(__gitdir)"
local merge=""
if [ -f "$g/MERGE_HEAD" ]; then
merge="--merge"