diff mbox series

[01/18] t4202: split testcase for invalid HEAD symref and HEAD hash

Message ID 91ef012cbcc9a3106fa51236e20458f108e50ce9.1618829583.git.gitgitgadget@gmail.com (mailing list archive)
State Superseded
Headers show
Series Prepare tests for reftable backend | expand

Commit Message

Han-Wen Nienhuys April 19, 2021, 10:52 a.m. UTC
From: Han-Wen Nienhuys <hanwen@google.com>

Reftable will prohibit invalid hashes at the storage level, but
git-symbolic-ref can still create branches ending in ".lock".

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
---
 t/t4202-log.sh | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

SZEDER Gábor April 19, 2021, 9:11 p.m. UTC | #1
On Mon, Apr 19, 2021 at 10:52:46AM +0000, Han-Wen Nienhuys via GitGitGadget wrote:
> From: Han-Wen Nienhuys <hanwen@google.com>
> 
> Reftable will prohibit invalid hashes at the storage level, but
> git-symbolic-ref can still create branches ending in ".lock".
> 
> Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
> ---
>  t/t4202-log.sh | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/t/t4202-log.sh b/t/t4202-log.sh
> index 350cfa35936a..c575deaad4fb 100755
> --- a/t/t4202-log.sh
> +++ b/t/t4202-log.sh
> @@ -1834,14 +1834,17 @@ test_expect_success 'log --graph --no-walk is forbidden' '
>  	test_must_fail git log --graph --no-walk
>  '
>  
> -test_expect_success 'log diagnoses bogus HEAD' '
> +test_expect_success 'log diagnoses bogus HEAD hash' '
>  	git init empty &&

This test creates a new repo in 'empty'...

>  	test_must_fail git -C empty log 2>stderr &&
>  	test_i18ngrep does.not.have.any.commits stderr &&
>  	echo 1234abcd >empty/.git/refs/heads/main &&
>  	test_must_fail git -C empty log 2>stderr &&
> -	test_i18ngrep broken stderr &&
> -	echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
> +	test_i18ngrep broken stderr'
> +
> +test_expect_success 'log diagnoses bogus HEAD symref' '
> +	git init empty &&

... and this test create a new repo in 'empty' as well.  Or rather
re-initializes the already existing repository there.

Is this intentional?  It surely cases some confusion.

> +	git --git-dir empty/.git symbolic-ref HEAD refs/heads/invalid.lock &&
>  	test_must_fail git -C empty log 2>stderr &&
>  	test_i18ngrep broken stderr &&
>  	test_must_fail git -C empty log --default totally-bogus 2>stderr &&
> -- 
> gitgitgadget
>
Han-Wen Nienhuys April 27, 2021, 9:14 a.m. UTC | #2
On Mon, Apr 19, 2021 at 11:11 PM SZEDER Gábor <szeder.dev@gmail.com> wrote:
> > +test_expect_success 'log diagnoses bogus HEAD symref' '
> > +     git init empty &&
>
> ... and this test create a new repo in 'empty' as well.  Or rather
> re-initializes the already existing repository there.
>
> Is this intentional?  It surely cases some confusion.

fixed.
diff mbox series

Patch

diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 350cfa35936a..c575deaad4fb 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -1834,14 +1834,17 @@  test_expect_success 'log --graph --no-walk is forbidden' '
 	test_must_fail git log --graph --no-walk
 '
 
-test_expect_success 'log diagnoses bogus HEAD' '
+test_expect_success 'log diagnoses bogus HEAD hash' '
 	git init empty &&
 	test_must_fail git -C empty log 2>stderr &&
 	test_i18ngrep does.not.have.any.commits stderr &&
 	echo 1234abcd >empty/.git/refs/heads/main &&
 	test_must_fail git -C empty log 2>stderr &&
-	test_i18ngrep broken stderr &&
-	echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
+	test_i18ngrep broken stderr'
+
+test_expect_success 'log diagnoses bogus HEAD symref' '
+	git init empty &&
+	git --git-dir empty/.git symbolic-ref HEAD refs/heads/invalid.lock &&
 	test_must_fail git -C empty log 2>stderr &&
 	test_i18ngrep broken stderr &&
 	test_must_fail git -C empty log --default totally-bogus 2>stderr &&