Thread (12 messages) flat view 12 messages, 1 author, 2016-06-15
DORMANTno replies

Revision v6 of 3 in this series.

Revisions (3)
  1. v5 [diff vs current]
  2. v6 [diff vs current]
  3. v6 current

[PATCH v6a 2/9] detached-stash: work around git rev-parse failure to detect bad log refs

From: Jon Seymour <hidden>
Date: 2016-06-15 22:49:21
Subsystem: the rest · Maintainer: Linus Torvalds

| amended to include trailing } in 1/9

This commit is required because git rev-parse in 1.7.2 does not correctly
indicate invalid log references using a non-zero status code.

We use a proxy for the condition (non-empty error output) as
a substitute. This commit can be reverted when, and if, rev-parse
is fixed to indicate invalid log references with a status code.

Signed-off-by: Jon Seymour <redacted>
---
 git-stash.sh |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/git-stash.sh b/git-stash.sh
index 836d6e6..42b0da2 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -328,6 +328,15 @@ parse_flags_and_rev()
 	test "$ref_stash" = "$(git rev-parse --symbolic-full-name "${REV%@*}")" &&
 	IS_STASH_REF=t
 
+	if test "${REV}" != "${REV%{*\}}"
+	then
+		# maintainers: it would be better if git rev-parse indicated
+		# this condition with a non-zero status code but as of 1.7.2.1 it
+		# it did not. So, we use non-empty stderr output as a proxy for the
+		# condition of interest.
+		test -z "$(git rev-parse "$REV" 2>&1 >/dev/null)" || die "$REV does not exist in the stash log"
+	fi
+
 }
 
 is_stash_like()
-- 
1.7.2.2.178.g949b
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help