diff mbox series

[v2,12/21] t5304: use "reflog expire --all" to clear the reflog

Message ID d8e80d83b6f8ee929b187aaffd5f37c3c981b50b.1619519903.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series Prepare tests for reftable backend | expand

Commit Message

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

This is more explicit, and reduces the depency between test functions. It also
is more amenable to use with reftable, which has no concept of (non)existence of
a reflog

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
---
 t/t5304-prune.sh | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Ævar Arnfjörð Bjarmason May 20, 2021, 3:27 p.m. UTC | #1
On Tue, Apr 27 2021, Han-Wen Nienhuys via GitGitGadget wrote:

> From: Han-Wen Nienhuys <hanwen@google.com>
>
> This is more explicit, and reduces the depency between test functions. It also
> is more amenable to use with reftable, which has no concept of (non)existence of
> a reflog

Sounds good in principle, but:

> @@ -94,9 +94,7 @@ test_expect_success 'prune: prune unreachable heads' '
>  test_expect_success 'prune: do not prune detached HEAD with no reflog' '
>  	git checkout --detach --quiet &&
>  	git commit --allow-empty -m "detached commit" &&
> -	# verify that there is no reflogs
> -	# (should be removed and disabled by previous test)
> -	test_path_is_missing .git/logs &&
> +	git reflog expire --all &&
>  	git prune -n >prune_actual &&
>  	test_must_be_empty prune_actual
>  '

Isn't the point of the existing test to check that there isn't an
existing reflog, not to just expire it if we find it, or does expire
--all return non-zero if none was found ?

> @@ -104,6 +102,7 @@ test_expect_success 'prune: do not prune detached HEAD with no reflog' '
>  test_expect_success 'prune: prune former HEAD after checking out branch' '
>  	head_oid=$(git rev-parse HEAD) &&
>  	git checkout --quiet main &&
> +	git reflog expire --all &&
>  	git prune -v >prune_actual &&
>  	grep "$head_oid" prune_actual
>  '

Just skimming this I'm perplexed why this needs expiring now, as opposed
to being s/file/command/ changes like the rest...
Han-Wen Nienhuys May 31, 2021, 2:04 p.m. UTC | #2
On Thu, May 20, 2021 at 5:28 PM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
>
>
> On Tue, Apr 27 2021, Han-Wen Nienhuys via GitGitGadget wrote:
>
> > From: Han-Wen Nienhuys <hanwen@google.com>
> >
> > This is more explicit, and reduces the depency between test functions. It also
> > is more amenable to use with reftable, which has no concept of (non)existence of
> > a reflog
>
> Sounds good in principle, but:
>
> > @@ -94,9 +94,7 @@ test_expect_success 'prune: prune unreachable heads' '
> >  test_expect_success 'prune: do not prune detached HEAD with no reflog' '
> >       git checkout --detach --quiet &&
> >       git commit --allow-empty -m "detached commit" &&
> > -     # verify that there is no reflogs
> > -     # (should be removed and disabled by previous test)
> > -     test_path_is_missing .git/logs &&
> > +     git reflog expire --all &&
> >       git prune -n >prune_actual &&
> >       test_must_be_empty prune_actual
> >  '
>
> Isn't the point of the existing test to check that there isn't an
> existing reflog, not to just expire it if we find it, or does expire
> --all return non-zero if none was found ?

no. it's verifying that the cross-test behavior is working as
intended. The real objective is to make sure there is no reflog.
Clarified commit msg.

> > @@ -104,6 +102,7 @@ test_expect_success 'prune: do not prune detached HEAD with no reflog' '
> >  test_expect_success 'prune: prune former HEAD after checking out branch' '
> >       head_oid=$(git rev-parse HEAD) &&
> >       git checkout --quiet main &&
> > +     git reflog expire --all &&
> >       git prune -v >prune_actual &&
> >       grep "$head_oid" prune_actual
> >  '
>
> Just skimming this I'm perplexed why this needs expiring now, as opposed
> to being s/file/command/ changes like the rest...

explained in the commit msg.
diff mbox series

Patch

diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh
index 7f47f13c78e8..7b850ae26171 100755
--- a/t/t5304-prune.sh
+++ b/t/t5304-prune.sh
@@ -81,12 +81,12 @@  test_expect_success 'prune: prune nonsense parameters' '
 
 test_expect_success 'prune: prune unreachable heads' '
 	git config core.logAllRefUpdates false &&
-	mv .git/logs .git/logs.old &&
-	: > file2 &&
+	>file2 &&
 	git add file2 &&
 	git commit -m temporary &&
 	tmp_head=$(git rev-list -1 HEAD) &&
 	git reset HEAD^ &&
+	git reflog expire --all &&
 	git prune &&
 	test_must_fail git reset $tmp_head --
 '
@@ -94,9 +94,7 @@  test_expect_success 'prune: prune unreachable heads' '
 test_expect_success 'prune: do not prune detached HEAD with no reflog' '
 	git checkout --detach --quiet &&
 	git commit --allow-empty -m "detached commit" &&
-	# verify that there is no reflogs
-	# (should be removed and disabled by previous test)
-	test_path_is_missing .git/logs &&
+	git reflog expire --all &&
 	git prune -n >prune_actual &&
 	test_must_be_empty prune_actual
 '
@@ -104,6 +102,7 @@  test_expect_success 'prune: do not prune detached HEAD with no reflog' '
 test_expect_success 'prune: prune former HEAD after checking out branch' '
 	head_oid=$(git rev-parse HEAD) &&
 	git checkout --quiet main &&
+	git reflog expire --all &&
 	git prune -v >prune_actual &&
 	grep "$head_oid" prune_actual
 '