All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [kernel] completion: silence "fatal: Not a git repository" error
@ 2014-10-14 10:49 John Szakmeister
  2014-10-14 13:58 ` John Szakmeister
  2014-10-14 18:29 ` Junio C Hamano
  0 siblings, 2 replies; 5+ messages in thread
From: John Szakmeister @ 2014-10-14 10:49 UTC (permalink / raw)
  To: git; +Cc: John Szakmeister

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.

Let's fix this by shunting the error message coming from "git for-each-ref".

Signed-off-by: John Szakmeister <john@szakmeister.net>
---
 contrib/completion/git-completion.bash | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 5ea5b82..31b4739 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
 }
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-10-14 22:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-14 10:49 [PATCH] [kernel] completion: silence "fatal: Not a git repository" error John Szakmeister
2014-10-14 13:58 ` John Szakmeister
2014-10-14 18:29 ` Junio C Hamano
2014-10-14 19:18   ` John Szakmeister
2014-10-14 22:14     ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.