git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v4 3/3] stash: prefer --quiet over shell redirection of the standard error stream

From
David Aguilar <davvid@gmail.com>
Date
Sep 16, 2014, 03:24 UTC
Message-ID
<1410837850-5169-3-git-send-email-davvid@gmail.com>
In-Reply-To
<1410837850-5169-2-git-send-email-davvid@gmail.com>

Use `git rev-parse --verify --quiet` instead of redirecting stderr to /dev/null.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
This patch is unchanged from when it was first written,
but is now correct thanks to the preceding patch.
 git-stash.sh | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/git-stash.sh b/git-stash.sh
index 9c1ba8e..7ece0f1 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -50,7 +50,7 @@ clear_stash () {
 	then
 		die "$(gettext "git stash clear with parameters is unimplemented")"
 	fi
-	if current=$(git rev-parse --verify $ref_stash 2>/dev/null)
+	if current=$(git rev-parse --verify --quiet $ref_stash)
 	then
 		git update-ref -d $ref_stash $current
 	fi
@@ -292,7 +292,7 @@ save_stash () {
 }
 
 have_stash () {
-	git rev-parse --verify $ref_stash >/dev/null 2>&1
+	git rev-parse --verify --quiet $ref_stash >/dev/null
 }
 
 list_stash () {
@@ -392,12 +392,12 @@ parse_flags_and_rev()
 		;;
 	esac
 
-	REV=$(git rev-parse --quiet --symbolic --verify "$1" 2>/dev/null) || {
+	REV=$(git rev-parse --symbolic --verify --quiet "$1") || {
 		reference="$1"
 		die "$(eval_gettext "\$reference is not valid reference")"
 	}
 
-	i_commit=$(git rev-parse --quiet --verify "$REV^2" 2>/dev/null) &&
+	i_commit=$(git rev-parse --verify --quiet "$REV^2") &&
 	set -- $(git rev-parse "$REV" "$REV^1" "$REV:" "$REV^1:" "$REV^2:" 2>/dev/null) &&
 	s=$1 &&
 	w_commit=$1 &&
@@ -409,7 +409,7 @@ parse_flags_and_rev()
 	test "$ref_stash" = "$(git rev-parse --symbolic-full-name "${REV%@*}")" &&
 	IS_STASH_REF=t
 
-	u_commit=$(git rev-parse --quiet --verify "$REV^3" 2>/dev/null) &&
+	u_commit=$(git rev-parse --verify --quiet "$REV^3") &&
 	u_tree=$(git rev-parse "$REV^3:" 2>/dev/null)
 }
 
@@ -531,7 +531,8 @@ drop_stash () {
 		die "$(eval_gettext "\${REV}: 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 --verify --quiet "$ref_stash@{0}" >/dev/null ||
+	clear_stash
 }
 
 apply_to_branch () {
-- 
2.1.0.30.g05c535b.dirty
Previous: David AguilarNext: Junio C Hamano
Message 3 of 4 in “t1503: use test_must_be_empty”
  1. 1/3 t1503: use test_must_be_emptyDavid Aguilar, Sep 16, 2014
  2. 2/3 refs: make rev-parse --quiet actually quietDavid Aguilar, Sep 16, 2014
  3. 3/3 stash: prefer --quiet over shell redirection of the standard error streamDavid Aguilar, Sep 16, 2014
  4. Junio C HamanoSep 16, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.