public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Jeff King <peff@peff•net>
Cc: Sebastian Schuberth <sschuberth@gmail•com>,
	git@vger•kernel.org, szeder@ira•uka.de, tr@thomasrast•ch
Subject: Re: [PATCH] git-completion.bash: always swallow error output of for-each-ref
Date: Fri, 12 Feb 2016 12:00:43 -0800	[thread overview]
Message-ID: <xmqqsi0xu2ac.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20160204111307.GA30495@sigill.intra.peff.net> (Jeff King's message of "Thu, 4 Feb 2016 06:13:07 -0500")

Jeff King <peff@peff•net> writes:

> On Thu, Feb 04, 2016 at 11:34:59AM +0100, Sebastian Schuberth wrote:
>
>> This avoids output like
>> 
>>     warning: ignoring broken ref refs/remotes/origin/HEAD
>> 
>> while completing branch names.
>
> Hmm. I feel like this case (HEAD points to a branch, then `fetch
> --prune` deletes it) came up recently and we discussed quieting that
> warning. But now I cannot seem to find it.
>
> Anyway, I this is a reasonable workaround. Errors from bash completion
> scripts are almost always going to be useless and get in the way of
> reading your own prompt.

I think that is absolutely the right stance to take, but then I
wonder if it is a sensible execution to sprinkle 2>/dev/null
everywhere.

For example, couldn't we do something like this instead?

This is just for illustration and does not remove all 2>/dev/null
and replace them with a single redirection that covers the entire
shell function body, but something along this line smells a lot more
pleasant.  I dunno.

 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 ba4137d..637c42d 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -47,14 +47,14 @@ __gitdir ()
 		elif [ -d .git ]; then
 			echo .git
 		else
-			git rev-parse --git-dir 2>/dev/null
+			git rev-parse --git-dir
 		fi
 	elif [ -d "$1/.git" ]; then
 		echo "$1/.git"
 	else
 		echo "$1"
 	fi
-}
+} 2>/dev/null
 
 # The following function is based on code from:
 #
@@ -320,7 +320,7 @@ __git_heads ()
 			refs/heads
 		return
 	fi
-}
+} 2>/dev/null
 
 __git_tags ()
 {
@@ -330,7 +330,7 @@ __git_tags ()
 			refs/tags
 		return
 	fi
-}
+} 2>/dev/null
 
 # __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments
 # presence of 2nd argument means use the guess heuristic employed
@@ -389,7 +389,7 @@ __git_refs ()
 			"refs/remotes/$dir/" 2>/dev/null | sed -e "s#^$dir/##"
 		;;
 	esac
-}
+} 2>/dev/null
 
 # __git_refs2 requires 1 argument (to pass to __git_refs)
 __git_refs2 ()

  parent reply	other threads:[~2016-02-12 20:00 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqsi0xu2ac.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=peff@peff$(echo .)net \
    --cc=sschuberth@gmail$(echo .)com \
    --cc=szeder@ira$(echo .)uka.de \
    --cc=tr@thomasrast$(echo .)ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox