summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorJohn Szakmeister <john@szakmeister.net>2014-10-14 10:49:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-10-14 20:06:13 (GMT)
commit8f7ff5b2fe7f52966c034a12cf8980dae1160222 (patch)
treeab5a656ac4e0c0e2f766850f40edf36c60fd8c65 /contrib
parent670a3c1d5a27bfb1cc6b526559c6f5874f00042f (diff)
downloadgit-8f7ff5b2fe7f52966c034a12cf8980dae1160222.zip
git-8f7ff5b2fe7f52966c034a12cf8980dae1160222.tar.gz
git-8f7ff5b2fe7f52966c034a12cf8980dae1160222.tar.bz2
completion: silence "fatal: Not a git repository" error
It is possible that a user is trying to run a git command and fail to realize that they are not in a git repository or working tree. When trying to complete an operation, __git_refs would fall to a degenerate case and attempt to use "git for-each-ref", which would emit the error. Hide this error message coming from "git for-each-ref". Signed-off-by: John Szakmeister <john@szakmeister.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib')
-rw-r--r--contrib/completion/git-completion.bash3
1 files changed, 2 insertions, 1 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 2ed230a..80e422f 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -388,7 +388,8 @@ __git_refs ()
;;
*)
echo "HEAD"
- git for-each-ref --format="%(refname:short)" -- "refs/remotes/$dir/" | sed -e "s#^$dir/##"
+ git for-each-ref --format="%(refname:short)" -- \
+ "refs/remotes/$dir/" 2>/dev/null | sed -e "s#^$dir/##"
;;
esac
}