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

7 messages from 2014-09-15 to 2014-09-16. Participants: David Aguilar, Junio C Hamano.
Thread: https://gitlist.dev/t/37573

## David Aguilar, 2014-09-15 19:07

Subject: [PATCH v3 1/3] t1503: test rev-parse --verify --quiet with deleted reflogs
Message-ID: <1410808059-1459-1-git-send-email-davvid@gmail.com>
URL: https://gitlist.dev/e/1410808059-1459-1-git-send-email-davvid%40gmail.com

```
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(+)

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, 2014-09-15 19:07

Subject: [PATCH v3 2/3] t1503: use test_must_be_empty
Message-ID: <1410808059-1459-2-git-send-email-davvid@gmail.com>
URL: https://gitlist.dev/e/1410808059-1459-2-git-send-email-davvid%40gmail.com
In-Reply-To: <1410808059-1459-1-git-send-email-davvid@gmail.com>

```
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(-)

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, 2014-09-15 19:07

Subject: [PATCH v3 3/3] Documentation: a note about stdout for git rev-parse --verify --quiet
Message-ID: <1410808059-1459-3-git-send-email-davvid@gmail.com>
URL: https://gitlist.dev/e/1410808059-1459-3-git-send-email-davvid%40gmail.com
In-Reply-To: <1410808059-1459-2-git-send-email-davvid@gmail.com>

```
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.
 
 --sq::
 	Usually the output is made one line per flag and
-- 
2.1.0.30.g05c535b.dirty

```

## Junio C Hamano, 2014-09-15 22:32

Subject: Re: [PATCH v3 1/3] t1503: test rev-parse --verify --quiet with deleted reflogs
Message-ID: <xmqqk3544ire.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqk3544ire.fsf%40gitster.dls.corp.google.com
In-Reply-To: <1410808059-1459-1-git-send-email-davvid@gmail.com>

```
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?

```

## Junio C Hamano, 2014-09-15 22:33

Subject: Re: [PATCH v3 2/3] t1503: use test_must_be_empty
Message-ID: <xmqqfvfs4ip7.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqfvfs4ip7.fsf%40gitster.dls.corp.google.com
In-Reply-To: <1410808059-1459-2-git-send-email-davvid@gmail.com>

```
David Aguilar <davvid@gmail.com> writes:

> 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?".



>
>  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, 2014-09-15 22:34

Subject: Re: [PATCH v3 3/3] Documentation: a note about stdout for git rev-parse --verify --quiet
Message-ID: <xmqqbnqg4ion.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqbnqg4ion.fsf%40gitster.dls.corp.google.com
In-Reply-To: <1410808059-1459-3-git-send-email-davvid@gmail.com>

```
David Aguilar <davvid@gmail.com> writes:

> 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

```

## David Aguilar, 2014-09-16 03:06

Subject: Re: [PATCH v3 1/3] t1503: test rev-parse --verify --quiet with deleted reflogs
Message-ID: <20140916030615.GA2286@gmail.com>
URL: https://gitlist.dev/e/20140916030615.GA2286%40gmail.com
In-Reply-To: <xmqqk3544ire.fsf@gitster.dls.corp.google.com>

```
On Mon, Sep 15, 2014 at 03:32:37PM -0700, Junio C Hamano wrote:
> 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

```
