threads / patch / 37573

v3, 3 partst1503: test rev-parse --verify --quiet with deleted reflogs

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

## tl;dr

7 messages between Sep 15, 2014 and Sep 16, 2014. Diffs are folded; open one to read it.

replies: 6people: 2as markdown or json

David Aguilar· Sep 15, 2014, 19:07 UTC · lore

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

Helped-by: Fabian Ruch <bafain@gmail.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
---
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(+)
Show changes to t/t1503-rev-parse-verify.sh +9 −0
diff --git a/t/t1503-rev-parse-verify.sh b/t/t1503-rev-parse-verify.sh
index 813cc1b..fd9d0c3 100755
--- a/t/t1503-rev-parse-verify.sh
+++ b/t/t1503-rev-parse-verify.sh
@@ -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)" &&
-- 
2.1.0.30.g05c535b.dirty
David Aguilar· Sep 15, 2014, 19:07 UTC · re: David Aguilar · lore

[PATCH v3 2/3] t1503: use test_must_be_empty

Use `test_must_be_be_empty <file>` instead of `test -z "$(cat <file>)"`.
Suggested-by: Fabian Ruch <bafain@gmail.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
---
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(-)
Show changes to t/t1503-rev-parse-verify.sh +6 −6
diff --git a/t/t1503-rev-parse-verify.sh b/t/t1503-rev-parse-verify.sh
index fd9d0c3..4fe9f0e 100755
--- a/t/t1503-rev-parse-verify.sh
+++ b/t/t1503-rev-parse-verify.sh
@@ -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' '
-- 
2.1.0.30.g05c535b.dirty
David Aguilar· Sep 15, 2014, 19:07 UTC · re: David Aguilar · lore

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

Signed-off-by: David Aguilar <davvid@gmail.com>
---
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(+)
Show changes to Documentation/git-rev-parse.txt +1 −0
diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index 0b84769..fa4a8c3 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -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
-- 
2.1.0.30.g05c535b.dirty
Junio C Hamano· Sep 15, 2014, 22:34 UTC · re: David Aguilar · lore

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

David Aguilar <davvid@gmail.com> writes:
Show 18 quoted lines
> Signed-off-by: David Aguilar <davvid@gmail.com>
> ---
> 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(+)
>
> diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
> index 0b84769..fa4a8c3 100644
> --- a/Documentation/git-rev-parse.txt
> +++ b/Documentation/git-rev-parse.txt
> @@ -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.
>  
>  --sq::
>  	Usually the output is made one line per flag and
Junio C Hamano· Sep 15, 2014, 22:33 UTC · re: David Aguilar · lore

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

David Aguilar <davvid@gmail.com> writes:
Show 7 quoted lines
> Use `test_must_be_be_empty <file>` instead of `test -z "$(cat <file>)"`.
>
> Suggested-by: Fabian Ruch <bafain@gmail.com>
> Signed-off-by: David Aguilar <davvid@gmail.com>
> ---
> 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?".

Show 38 quoted lines
>
>  t/t1503-rev-parse-verify.sh | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/t/t1503-rev-parse-verify.sh b/t/t1503-rev-parse-verify.sh
> index fd9d0c3..4fe9f0e 100755
> --- a/t/t1503-rev-parse-verify.sh
> +++ b/t/t1503-rev-parse-verify.sh
> @@ -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' '
Junio C Hamano· Sep 15, 2014, 22:32 UTC · re: David Aguilar · lore

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

David Aguilar <davvid@gmail.com> writes:
Show 10 quoted lines
> Ensure that rev-parse --verify --quiet is silent when asked
> about deleted reflog entries.
>
> Helped-by: Fabian Ruch <bafain@gmail.com>
> Signed-off-by: David Aguilar <davvid@gmail.com>
> ---
> 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?

David Aguilar· Sep 16, 2014, 03:06 UTC · re: Junio C Hamano · lore

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

On Mon, Sep 15, 2014 at 03:32:37PM -0700, Junio C Hamano wrote:
Show 16 quoted lines
> David Aguilar <davvid@gmail.com> writes:
> 
> > Ensure that rev-parse --verify --quiet is silent when asked
> > about deleted reflog entries.
> >
> > Helped-by: Fabian Ruch <bafain@gmail.com>
> > Signed-off-by: David Aguilar <davvid@gmail.com>
> > ---
> > 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?
> 

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.

-- 
David

← back to recent threads