git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Eliminate redirection to stdout and stderr when quiet option  is available
@ 2009-05-14  7:13 Dan Loewenherz
  2009-05-14  7:27 ` Junio C Hamano
  2009-05-14  7:35 ` Johannes Schindelin
  0 siblings, 2 replies; 4+ messages in thread
From: Dan Loewenherz @ 2009-05-14  7:13 UTC (permalink / raw)
  To: gitster, git

This follows an earlier commit (7bd93c1) that eliminates the usage of
`>dev/null 2>&1` and friends when a `--quiet` option is available.

Signed-off-by: Dan Loewenherz <daniel.loewenherz@yale.edu>
---
 git-add--interactive.perl          |    2 +-
 git-am.sh                          |    2 +-
 git-cvsexportcommit.perl           |    2 +-
 git-cvsimport.perl                 |    2 +-
 git-lost-found.sh                  |    2 +-
 git-rebase--interactive.sh         |    8 ++++----
 git-rebase.sh                      |    2 +-
 git-stash.sh                       |   12 ++++++------
 git-submodule.sh                   |    6 +++---
 templates/hooks--pre-commit.sample |    2 +-
 10 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index f6e536e..e1106c9 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -158,7 +158,7 @@ my $status_head = sprintf($status_fmt, 'staged',
'unstaged', 'path');
 {
 	my $initial;
 	sub is_initial_commit {
-		$initial = system('git rev-parse HEAD -- >/dev/null 2>&1') != 0
+		$initial = system('git rev-parse -q HEAD -- ') != 0
 			unless defined $initial;
 		return $initial;
 	}
diff --git a/git-am.sh b/git-am.sh
index 6d1848b..8a86d05 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -36,7 +36,7 @@ cd_to_toplevel
 git var GIT_COMMITTER_IDENT >/dev/null ||
 	die "You need to set your committer info first"

-if git rev-parse --verify -q HEAD >/dev/null
+if git rev-parse --verify -q HEAD
 then
 	HAS_HEAD=yes
 else
diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl
index 6d9f0ef..a10303a 100755
--- a/git-cvsexportcommit.perl
+++ b/git-cvsexportcommit.perl
@@ -127,7 +127,7 @@ my $go_back_to = 0;

 if ($opt_W) {
     $opt_v && print "Resetting to $parent\n";
-    $go_back_to = `git symbolic-ref HEAD 2> /dev/null ||
+    $go_back_to = `git symbolic-ref -q HEAD ||
 	git rev-parse HEAD` || die "Could not determine current branch";
     system("git checkout -q $parent^0") && die "Could not check out $parent^0";
 }
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index e439202..81b808e 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -535,7 +535,7 @@ sub is_sha1 {

 sub get_headref ($) {
 	my $name = shift;
-	my $r = `git rev-parse --verify '$name' 2>/dev/null`;
+	my $r = `git rev-parse -q --verify '$name' `;
 	return undef unless $? == 0;
 	chomp $r;
 	return $r;
diff --git a/git-lost-found.sh b/git-lost-found.sh
index 0b3e8c7..c64a308 100755
--- a/git-lost-found.sh
+++ b/git-lost-found.sh
@@ -20,7 +20,7 @@ while read dangling type sha1
 do
 	case "$dangling" in
 	dangling)
-		if git rev-parse -q --verify "$sha1^0" >/dev/null
+		if git rev-parse -q --verify "$sha1^0"
 		then
 			dir="$laf/commit"
 			git show-branch "$sha1"
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 314cd36..118508e 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -83,7 +83,7 @@ run_pre_rebase_hook () {

 require_clean_work_tree () {
 	# test if working tree is dirty
-	git rev-parse --verify HEAD > /dev/null &&
+	git rev-parse -q --verify HEAD &&
 	git update-index --ignore-submodules --refresh &&
 	git diff-files --quiet --ignore-submodules &&
 	git diff-index --cached --quiet HEAD --ignore-submodules -- ||
@@ -258,7 +258,7 @@ pick_one_preserving_merges () {
 		if [ "$1" != "-n" ]
 		then
 			# detach HEAD to current parent
-			output git checkout $first_parent 2> /dev/null ||
+			output git checkout -q $first_parent ||
 				die "Cannot move HEAD to $first_parent"
 		fi

@@ -498,7 +498,7 @@ do
 		test -d "$DOTEST" || die "No interactive rebase running"

 		# Sanity check
-		git rev-parse --verify HEAD >/dev/null ||
+		git rev-parse -q --verify HEAD ||
 			die "Cannot read HEAD"
 		git update-index --ignore-submodules --refresh &&
 			git diff-files --quiet --ignore-submodules ||
@@ -632,7 +632,7 @@ first and then run 'git rebase --continue' again."
 		mkdir "$DOTEST" || die "Could not create temporary $DOTEST"

 		: > "$DOTEST"/interactive || die "Could not mark as interactive"
-		git symbolic-ref HEAD > "$DOTEST"/head-name 2> /dev/null ||
+		git symbolic-ref -q HEAD > "$DOTEST"/head-name ||
 			echo "detached HEAD" > "$DOTEST"/head-name

 		echo $HEAD > "$DOTEST"/head
diff --git a/git-rebase.sh b/git-rebase.sh
index b83fd3f..da575d9 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -91,7 +91,7 @@ call_merge () {
 	cmt="$(cat "$dotest/cmt.$1")"
 	echo "$cmt" > "$dotest/current"
 	hd=$(git rev-parse --verify HEAD)
-	cmt_name=$(git symbolic-ref HEAD 2> /dev/null || echo HEAD)
+	cmt_name=$(git symbolic-ref -q HEAD || echo HEAD)
 	msgnum=$(cat "$dotest/msgnum")
 	end=$(cat "$dotest/end")
 	eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"'
diff --git a/git-stash.sh b/git-stash.sh
index b9ace99..7661862 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -30,7 +30,7 @@ clear_stash () {
 	then
 		die "git stash clear with parameters is unimplemented"
 	fi
-	if current=$(git rev-parse --verify $ref_stash 2>/dev/null)
+	if current=$(git rev-parse -q --verify $ref_stash)
 	then
 		git update-ref -d $ref_stash $current
 	fi
@@ -129,7 +129,7 @@ save_stash () {
 }

 have_stash () {
-	git rev-parse --verify $ref_stash >/dev/null 2>&1
+	git rev-parse -q --verify $ref_stash
 }

 list_stash () {
@@ -229,16 +229,16 @@ drop_stash () {
 	fi
 	# Verify supplied argument looks like a stash entry
 	s=$(git rev-parse --verify "$@") &&
-	git rev-parse --verify "$s:"   > /dev/null 2>&1 &&
-	git rev-parse --verify "$s^1:" > /dev/null 2>&1 &&
-	git rev-parse --verify "$s^2:" > /dev/null 2>&1 ||
+	git rev-parse -q --verify "$s:" &&
+	git rev-parse -q --verify "$s^1:" &&
+	git rev-parse -q --verify "$s^2:" ||
 		die "$*: not a valid stashed state"

 	git reflog delete --updateref --rewrite "$@" &&
 		echo "Dropped $* ($s)" || die "$*: Could not drop stash entry"

 	# clear_stash if we just dropped the last stash entry
-	git rev-parse --verify "$ref_stash@{0}" > /dev/null 2>&1 || clear_stash
+	git rev-parse -q --verify "$ref_stash@{0}" || clear_stash
 }

 apply_to_branch () {
diff --git a/git-submodule.sh b/git-submodule.sh
index 8e234a4..5ef605d 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -459,7 +459,7 @@ cmd_summary() {
 			# Always show modules deleted or type-changed (blob<->module)
 			test $status = D -o $status = T && echo "$name" && continue
 			# Also show added or modified modules which are checked out
-			GIT_DIR="$name/.git" git-rev-parse --git-dir >/dev/null 2>&1 &&
+			GIT_DIR="$name/.git" git-rev-parse -q --git-dir &&
 			echo "$name"
 		done
 	)
@@ -493,11 +493,11 @@ cmd_summary() {
 		missing_dst=

 		test $mod_src = 160000 &&
-		! GIT_DIR="$name/.git" git-rev-parse -q --verify $sha1_src^0 >/dev/null &&
+		! GIT_DIR="$name/.git" git-rev-parse -q --verify $sha1_src^0 &&
 		missing_src=t

 		test $mod_dst = 160000 &&
-		! GIT_DIR="$name/.git" git-rev-parse -q --verify $sha1_dst^0 >/dev/null &&
+		! GIT_DIR="$name/.git" git-rev-parse -q --verify $sha1_dst^0 &&
 		missing_dst=t

 		total_commits=
diff --git a/templates/hooks--pre-commit.sample
b/templates/hooks--pre-commit.sample
index 0e49279..8ef822b 100755
--- a/templates/hooks--pre-commit.sample
+++ b/templates/hooks--pre-commit.sample
@@ -7,7 +7,7 @@
 #
 # To enable this hook, rename this file to "pre-commit".

-if git-rev-parse --verify HEAD 2>/dev/null
+if git-rev-parse -q --verify HEAD
 then
 	against=HEAD
 else
-- 
1.6.3.1.10.gf494c2.dirty

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

* Re: [PATCH] Eliminate redirection to stdout and stderr when quiet option  is available
  2009-05-14  7:13 [PATCH] Eliminate redirection to stdout and stderr when quiet option is available Dan Loewenherz
@ 2009-05-14  7:27 ` Junio C Hamano
  2009-05-14  7:35 ` Johannes Schindelin
  1 sibling, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2009-05-14  7:27 UTC (permalink / raw)
  To: Dan Loewenherz; +Cc: gitster, git

Dan Loewenherz <daniel.loewenherz@yale.edu> writes:

> diff --git a/git-add--interactive.perl b/git-add--interactive.perl
> index f6e536e..e1106c9 100755
> --- a/git-add--interactive.perl
> +++ b/git-add--interactive.perl
> @@ -158,7 +158,7 @@ my $status_head = sprintf($status_fmt, 'staged',
> 'unstaged', 'path');
>  {
>  	my $initial;
>  	sub is_initial_commit {
> -		$initial = system('git rev-parse HEAD -- >/dev/null 2>&1') != 0
> +		$initial = system('git rev-parse -q HEAD -- ') != 0

Isn't this conversion wrong?

	$ git rev-parse -q HEAD --
        95405ba6cf7adeaa4a066e8a3a1b76b73f7b9341

> diff --git a/git-am.sh b/git-am.sh
> index 6d1848b..8a86d05 100755
> --- a/git-am.sh
> +++ b/git-am.sh
> @@ -36,7 +36,7 @@ cd_to_toplevel
>  git var GIT_COMMITTER_IDENT >/dev/null ||
>  	die "You need to set your committer info first"
>
> -if git rev-parse --verify -q HEAD >/dev/null
> +if git rev-parse --verify -q HEAD

Likewise.

Should I spend more time myself, or will you double check the patch and
resubmit?

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

* Re: [PATCH] Eliminate redirection to stdout and stderr when quiet option  is available
  2009-05-14  7:13 [PATCH] Eliminate redirection to stdout and stderr when quiet option is available Dan Loewenherz
  2009-05-14  7:27 ` Junio C Hamano
@ 2009-05-14  7:35 ` Johannes Schindelin
  2009-05-14  7:48   ` Dan Loewenherz
  1 sibling, 1 reply; 4+ messages in thread
From: Johannes Schindelin @ 2009-05-14  7:35 UTC (permalink / raw)
  To: Dan Loewenherz; +Cc: gitster, git

Hi,

On Thu, 14 May 2009, Dan Loewenherz wrote:

> This follows an earlier commit (7bd93c1) that eliminates the usage of
> `>dev/null 2>&1` and friends when a `--quiet` option is available.

I like this patch, but I think that

	git rev-parse -q HEAD

_does_ output a commit name...

Ciao,
Dscho

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

* Re: Eliminate redirection to stdout and stderr when quiet option is available
  2009-05-14  7:35 ` Johannes Schindelin
@ 2009-05-14  7:48   ` Dan Loewenherz
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Loewenherz @ 2009-05-14  7:48 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Dan Loewenherz, gitster, git

On 14/05/09 09:35 +0200, Johannes Schindelin wrote:
> I like this patch, but I think that
> 
> 	git rev-parse -q HEAD
> 
> _does_ output a commit name...
> 

Thanks for pointing this out. I probably should have checked to see that 
the changes still gave the desired output (or lack thereof). I'll resubmit 
the patch.

Best,
Dan

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

end of thread, other threads:[~2009-05-14  7:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-14  7:13 [PATCH] Eliminate redirection to stdout and stderr when quiet option is available Dan Loewenherz
2009-05-14  7:27 ` Junio C Hamano
2009-05-14  7:35 ` Johannes Schindelin
2009-05-14  7:48   ` Dan Loewenherz

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).