summaryrefslogtreecommitdiff
path: root/t/t1503-rev-parse-verify.sh
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2014-09-29 12:36:10 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2014-09-29 12:36:10 -0700
commit507fe835ed0753ff266fdb998853cc5dea3758c6 (patch)
tree06a7d355d50bea90bf2a3859c11e9d9a5b633b6f /t/t1503-rev-parse-verify.sh
parentMerge branch 'hj/pretty-naked-decoration' (diff)
parentstash: prefer --quiet over shell redirection of the standard error stream (diff)
downloadtgif-507fe835ed0753ff266fdb998853cc5dea3758c6.tar.xz
Merge branch 'da/rev-parse-verify-quiet'
"rev-parse --verify --quiet $name" is meant to quietly exit with a non-zero status when $name is not a valid object name, but still gave error messages in some cases. * da/rev-parse-verify-quiet: stash: prefer --quiet over shell redirection of the standard error stream refs: make rev-parse --quiet actually quiet t1503: use test_must_be_empty Documentation: a note about stdout for git rev-parse --verify --quiet
Diffstat (limited to 't/t1503-rev-parse-verify.sh')
-rwxr-xr-xt/t1503-rev-parse-verify.sh37
1 files changed, 32 insertions, 5 deletions
diff --git a/t/t1503-rev-parse-verify.sh b/t/t1503-rev-parse-verify.sh
index 813cc1b3e2..823fe1d799 100755
--- a/t/t1503-rev-parse-verify.sh
+++ b/t/t1503-rev-parse-verify.sh
@@ -72,15 +72,42 @@ test_expect_success 'fails with any bad rev or many good revs' '
test_expect_success 'fails silently when using -q' '
test_must_fail git rev-parse --verify --quiet 2>error &&
- test -z "$(cat error)" &&
+ test_must_be_empty error &&
test_must_fail git rev-parse -q --verify foo 2>error &&
- test -z "$(cat error)" &&
+ test_must_be_empty error &&
test_must_fail git rev-parse --verify -q HEAD bar 2>error &&
- test -z "$(cat error)" &&
+ test_must_be_empty error &&
test_must_fail git rev-parse --quiet --verify baz HEAD 2>error &&
- test -z "$(cat error)" &&
+ test_must_be_empty error &&
test_must_fail git rev-parse -q --verify $HASH2 HEAD 2>error &&
- test -z "$(cat error)"
+ test_must_be_empty error
+'
+
+test_expect_success 'fails silently when using -q with deleted reflogs' '
+ ref=$(git rev-parse HEAD) &&
+ : >.git/logs/refs/test &&
+ git update-ref -m "message for refs/test" refs/test "$ref" &&
+ git reflog delete --updateref --rewrite refs/test@{0} &&
+ test_must_fail git rev-parse -q --verify refs/test@{0} >error 2>&1 &&
+ test_must_be_empty error
+'
+
+test_expect_success 'fails silently when using -q with not enough reflogs' '
+ ref=$(git rev-parse HEAD) &&
+ : >.git/logs/refs/test2 &&
+ git update-ref -m "message for refs/test2" refs/test2 "$ref" &&
+ test_must_fail git rev-parse -q --verify refs/test2@{999} >error 2>&1 &&
+ test_must_be_empty error
+'
+
+test_expect_success 'succeeds silently with -q and reflogs that do not go far back enough in time' '
+ ref=$(git rev-parse HEAD) &&
+ : >.git/logs/refs/test3 &&
+ git update-ref -m "message for refs/test3" refs/test3 "$ref" &&
+ git rev-parse -q --verify refs/test3@{1.year.ago} >actual 2>error &&
+ test_must_be_empty error &&
+ echo "$ref" >expect &&
+ test_cmp expect actual
'
test_expect_success 'no stdout output on error' '