Skip to content

Commit b0f0ecd

Browse files
jonseymourgitster
authored andcommitted
detached-stash: work around git rev-parse failure to detect bad log refs
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ef76312 commit b0f0ecd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

git-stash.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,15 @@ parse_flags_and_rev()
328328
test "$ref_stash" = "$(git rev-parse --symbolic-full-name "${REV%@*}")" &&
329329
IS_STASH_REF=t
330330

331+
if test "${REV}" != "${REV%{*\}}"
332+
then
333+
# maintainers: it would be better if git rev-parse indicated
334+
# this condition with a non-zero status code but as of 1.7.2.1 it
335+
# it did not. So, we use non-empty stderr output as a proxy for the
336+
# condition of interest.
337+
test -z "$(git rev-parse "$REV" 2>&1 >/dev/null)" || die "$REV does not exist in the stash log"
338+
fi
339+
331340
}
332341

333342
is_stash_like()

0 commit comments

Comments
 (0)