git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-completion.bash: always swallow error output of for-each-ref
@ 2016-02-04 10:34 Sebastian Schuberth
  2016-02-04 11:13 ` Jeff King
  2016-02-12  9:23 ` Sebastian Schuberth
  0 siblings, 2 replies; 24+ messages in thread
From: Sebastian Schuberth @ 2016-02-04 10:34 UTC (permalink / raw)
  To: git; +Cc: szeder, Junio C Hamano, tr

This avoids output like

    warning: ignoring broken ref refs/remotes/origin/HEAD

while completing branch names.

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
---
 contrib/completion/git-completion.bash | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 15ebba5..7c0549d 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -317,7 +317,7 @@ __git_heads ()
 	local dir="$(__gitdir)"
 	if [ -d "$dir" ]; then
 		git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
-			refs/heads
+			refs/heads 2>/dev/null
 		return
 	fi
 }
@@ -327,7 +327,7 @@ __git_tags ()
 	local dir="$(__gitdir)"
 	if [ -d "$dir" ]; then
 		git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
-			refs/tags
+			refs/tags 2>/dev/null
 		return
 	fi
 }
@@ -355,14 +355,14 @@ __git_refs ()
 			;;
 		esac
 		git --git-dir="$dir" for-each-ref --format="%($format)" \
-			$refs
+			$refs 2>/dev/null
 		if [ -n "$track" ]; then
 			# employ the heuristic used by git checkout
 			# Try to find a remote branch that matches the completion word
 			# but only output if the branch name is unique
 			local ref entry
 			git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" \
-				"refs/remotes/" | \
+				"refs/remotes/" 2>/dev/null | \
 			while read -r entry; do
 				eval "$entry"
 				ref="${ref#*/}"
@@ -1835,7 +1835,7 @@ _git_config ()
 		remote="${remote%.push}"
 		__gitcomp_nl "$(git --git-dir="$(__gitdir)" \
 			for-each-ref --format='%(refname):%(refname)' \
-			refs/heads)"
+			refs/heads 2>/dev/null)"
 		return
 		;;
 	pull.twohead|pull.octopus)
-- 
2.7.0.windows.1

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

end of thread, other threads:[~2016-02-24  7:48 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-04 10:34 [PATCH] git-completion.bash: always swallow error output of for-each-ref Sebastian Schuberth
2016-02-04 11:13 ` Jeff King
2016-02-04 11:26   ` Johannes Schindelin
2016-02-04 11:45     ` Jeff King
2016-02-04 19:06     ` Junio C Hamano
2016-02-12 23:21     ` SZEDER Gábor
2016-02-12 23:40       ` Jeff King
2016-02-13  1:07         ` SZEDER Gábor
2016-02-13  9:21           ` Johannes Schindelin
2016-02-13 13:53             ` SZEDER Gábor
2016-02-13 17:14               ` Johannes Schindelin
2016-02-13 16:57           ` Jeff King
2016-02-12 23:43       ` SZEDER Gábor
2016-02-12 23:46         ` Jeff King
2016-02-13  0:53           ` Duy Nguyen
2016-02-12 20:00   ` Junio C Hamano
2016-02-12 20:10     ` Jeff King
2016-02-12 20:26       ` Junio C Hamano
2016-02-12 21:40     ` SZEDER Gábor
2016-02-12 22:16       ` Jeff King
2016-02-12 23:37         ` Junio C Hamano
2016-02-23 23:30           ` Junio C Hamano
2016-02-24  7:48             ` Sebastian Schuberth
2016-02-12  9:23 ` Sebastian Schuberth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).