Skip to contentSkip to conversation

t1503: test rev-parse --verify --quiet with deleted reflogs

PATCH In review David Aguilar 2 participants 7 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/3 t1503: test rev-parse --verify --quiet with deleted reflogs

Ensure that rev-parse --verify --quiet is silent when asked about deleted reflog entries.

---
Differences since last time:

This goes back to the original approach of using "git update-ref" plumbing instead of "git branch" when testing deleted reflogs.

 t/t1503-rev-parse-verify.sh | 9 +++++++++
 1 file changed, 9 insertions(+)
t/t1503-rev-parse-verify.sh +9 -0
index 813cc1b..fd9d0c3 100755
@@ -83,6 +83,15 @@ test_expect_success 'fails silently when using -q' '
 	test -z "$(cat 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 "reflog 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 -z "$(cat error)"
+'
+
 test_expect_success 'no stdout output on error' '
 	test -z "$(git rev-parse --verify)" &&
 	test -z "$(git rev-parse --verify foo)" &&
Signature · 1 line
2.1.0.30.g05c535b.dirty
#1 lore raw

PATCH v3 2/3 t1503: use test_must_be_empty

Use test_must_be_be_empty <file> instead of test -z "$(cat <file>)".

---
Unchanged since last time, but rebased for the change in the previous patch.

 t/t1503-rev-parse-verify.sh | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
t/t1503-rev-parse-verify.sh +6 -6
index fd9d0c3..4fe9f0e 100755
@@ -72,15 +72,15 @@ 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' '
@@ -89,7 +89,7 @@ test_expect_success 'fails silently when using -q with deleted reflogs' '
 	git update-ref -m "reflog 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 -z "$(cat error)"
+	test_must_be_empty error
 '
 
 test_expect_success 'no stdout output on error' '
Signature · 1 line
2.1.0.30.g05c535b.dirty
#2 lore raw

PATCH v3 3/3 Documentation: a note about stdout for git rev-parse --verify --quiet

---
This patch is new: we now mention that stdout contains the valid object name when --quiet is used, which may not be clear when reading this paragraph in isolation.

 Documentation/git-rev-parse.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/git-rev-parse.txt +1 -0
index 0b84769..fa4a8c3 100644
@@ -114,6 +114,7 @@ can be used.
 	Only meaningful in `--verify` mode. Do not output an error
 	message if the first argument is not a valid object name;
 	instead exit with non-zero status silently.
+	SHA-1s for valid object names are printed to stdout on success.
 
 --sq::
 	Usually the output is made one line per flag and
Signature · 1 line
2.1.0.30.g05c535b.dirty
#3 lore raw

Re: [PATCH v3 3/3] Documentation: a note about stdout for git rev-parse --verify --quiet

Quoted 14 lines · David Aguilar

---
This patch is new: we now mention that stdout contains the valid object name when --quiet is used, which may not be clear when reading this paragraph in isolation.

 Documentation/git-rev-parse.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/git-rev-parse.txt +0 -0
index 0b84769..fa4a8c3 100644

Documentation/git-rev-parse.txt can be used. · line 117

Quoted 4 lines
Documentation/git-rev-parse.txt +1 -0
@@ -114,6 +114,7 @@ can be used.
 	Only meaningful in `--verify` mode. Do not output an error
 	message if the first argument is not a valid object name;
 	instead exit with non-zero status silently.
+	SHA-1s for valid object names are printed to stdout on success.

OK. Thanks.

Quoted 3 lines
Documentation/git-rev-parse.txt +0 -0
 --sq::
 	Usually the output is made one line per flag and
#4 lore raw

Re: [PATCH v3 2/3] t1503: use test_must_be_empty

In reply to David Aguilar
Quoted 7 lines · David Aguilar

Use test_must_be_be_empty <file> instead of test -z "$(cat <file>)".

---
Unchanged since last time, but rebased for the change in the previous patch.

It probably makes more sense to have this at the beginning of a series as preliminary clean-up. That way, the more interesting change does not have to have "test -z $(cat ...)" that makes readers go "Huh?".

Quoted 38 lines
 t/t1503-rev-parse-verify.sh | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
t/t1503-rev-parse-verify.sh +6 -6
index fd9d0c3..4fe9f0e 100755
@@ -72,15 +72,15 @@ 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' '
@@ -89,7 +89,7 @@ test_expect_success 'fails silently when using -q with deleted reflogs' '
 	git update-ref -m "reflog 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 -z "$(cat error)"
+	test_must_be_empty error
 '
 
 test_expect_success 'no stdout output on error' '
#5 lore raw
In reply to David Aguilar
Quoted 10 lines · David Aguilar

Ensure that rev-parse --verify --quiet is silent when asked about deleted reflog entries.

---
Differences since last time:

This goes back to the original approach of using "git update-ref" plumbing instead of "git branch" when testing deleted reflogs.

Is this 1/3 (the first one in the series) supposed to pass without no other patches, either in the series or something outside?

#6 lore raw
Quoted 10 lines · Junio C Hamano
Quoted 8 lines · David Aguilar

Ensure that rev-parse --verify --quiet is silent when asked about deleted reflog entries.

---
Differences since last time:

Quoted 6 lines
Quoted 2 lines

This goes back to the original approach of using "git update-ref" plumbing instead of "git branch" when testing deleted reflogs.

Is this 1/3 (the first one in the series) supposed to pass without no other patches, either in the series or something outside?

It depends on the patch I sent not too long ago that makes rev-parse --quiet actually quiet.

I'll rework this series to do the test_must_be_empty cleanup first and include the prerequisite patch when I re-roll shortly.

Signature · 1 line
David