diff mbox series

[v4,5/7] t5615-partial-clone: add test for fetch --refetch

Message ID 6c17167ac1edbeea5f6d375a989aa49f5748d099.1648476132.git.gitgitgadget@gmail.com (mailing list archive)
State Accepted
Commit 011b7757279e52043a0398b0a3b1d497d8417daf
Headers show
Series fetch: add repair: full refetch without negotiation (was: "refiltering") | expand

Commit Message

Robert Coup March 28, 2022, 2:02 p.m. UTC
From: Robert Coup <robert@coup.net.nz>

Add a test for doing a refetch to apply a changed partial clone filter
under protocol v0 and v2.

Signed-off-by: Robert Coup <robert@coup.net.nz>
---
 t/t5616-partial-clone.sh | 52 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 51 insertions(+), 1 deletion(-)

Comments

Ævar Arnfjörð Bjarmason March 31, 2022, 3:20 p.m. UTC | #1
On Mon, Mar 28 2022, Robert Coup via GitGitGadget wrote:

> From: Robert Coup <robert@coup.net.nz>
>
> Add a test for doing a refetch to apply a changed partial clone filter
> under protocol v0 and v2.
>
> Signed-off-by: Robert Coup <robert@coup.net.nz>
> ---
>  t/t5616-partial-clone.sh | 52 +++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 51 insertions(+), 1 deletion(-)
>
> diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
> index 34469b6ac10..87ebf4b0b1c 100755
> --- a/t/t5616-partial-clone.sh
> +++ b/t/t5616-partial-clone.sh
> @@ -166,6 +166,56 @@ test_expect_success 'manual prefetch of missing objects' '
>  	test_line_count = 0 observed.oids
>  '
>  
> +# create new commits in "src" repo to establish a history on file.4.txt
> +# and push to "srv.bare".
> +test_expect_success 'push new commits to server for file.4.txt' '
> +	for x in a b c d e f
> +	do
> +		echo "Mod file.4.txt $x" >src/file.4.txt &&
> +		if list_contains "a,b" "$x"; then
> +			printf "%10000s" X >>src/file.4.txt
> +		fi &&
> +		if list_contains "c,d" "$x"; then
> +			printf "%20000s" X >>src/file.4.txt
> +		fi &&
> +		git -C src add file.4.txt &&
> +		git -C src commit -m "mod $x" || return 1
> +	done &&
> +	git -C src push -u srv main
> +'
> +
> +# Do partial fetch to fetch smaller files; then verify that without --refetch
> +# applying a new filter does not refetch missing large objects. Then use
> +# --refetch to apply the new filter on existing commits. Test it under both
> +# protocol v2 & v0.
> +test_expect_success 'apply a different filter using --refetch' '
> +	git -C pc1 fetch --filter=blob:limit=999 origin &&
> +	git -C pc1 rev-list --quiet --objects --missing=print \
> +		main..origin/main >observed &&
> +	test_line_count = 4 observed &&
> +
> +	git -C pc1 fetch --filter=blob:limit=19999 --refetch origin &&

Is 19999 just "arbitrary big number" here?

> +	git -C pc1 rev-list --quiet --objects --missing=print \
> +		main..origin/main >observed &&
> +	test_line_count = 2 observed &&
> +
> +	git -c protocol.version=0 -C pc1 fetch --filter=blob:limit=29999 \
> +		--refetch origin &&
> +	git -C pc1 rev-list --quiet --objects --missing=print \
> +		main..origin/main >observed &&
> +	test_line_count = 0 observed

Does this test_line_count *really* want to be = 0, or does this mean
test_must_be_empty?

I.e. are we expecting content here, just not ending in a \n, or nothing
at all?

> +'
> +
> +test_expect_success 'fetch --refetch works with a shallow clone' '
> +	git clone --no-checkout --depth=1 --filter=blob:none "file://$(pwd)/srv.bare" pc1s &&
> +	git -C pc1s rev-list --objects --missing=print HEAD >observed &&
> +	test_line_count = 6 observed &&
> +
> +	GIT_TRACE=1 git -C pc1s fetch --filter=blob:limit=999 --refetch origin &&

Why the GIT_TRACE=1? Seems to not be used.
Robert Coup April 1, 2022, 10:36 a.m. UTC | #2
Hi,

On Thu, 31 Mar 2022 at 16:22, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
>
>

> > +
> > +     git -C pc1 fetch --filter=blob:limit=19999 --refetch origin &&
>
> Is 19999 just "arbitrary big number" here?

A selected big number so we can change it and have different objects match.

>
> > +     git -C pc1 rev-list --quiet --objects --missing=print \
> > +             main..origin/main >observed &&
> > +     test_line_count = 2 observed &&
> > +
> > +     git -c protocol.version=0 -C pc1 fetch --filter=blob:limit=29999 \
> > +             --refetch origin &&
> > +     git -C pc1 rev-list --quiet --objects --missing=print \
> > +             main..origin/main >observed &&
> > +     test_line_count = 0 observed
>
> Does this test_line_count *really* want to be = 0, or does this mean
> test_must_be_empty?
>
> I.e. are we expecting content here, just not ending in a \n, or nothing
> at all?

I'm expecting no missing objects after a refetch with a new filter
that matches all the objects in the repo.

> > +     GIT_TRACE=1 git -C pc1s fetch --filter=blob:limit=999 --refetch origin &&
>
> Why the GIT_TRACE=1? Seems to not be used.

Ah, extraneous debugging on my part.

Thanks, Rob :)
diff mbox series

Patch

diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index 34469b6ac10..87ebf4b0b1c 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -166,6 +166,56 @@  test_expect_success 'manual prefetch of missing objects' '
 	test_line_count = 0 observed.oids
 '
 
+# create new commits in "src" repo to establish a history on file.4.txt
+# and push to "srv.bare".
+test_expect_success 'push new commits to server for file.4.txt' '
+	for x in a b c d e f
+	do
+		echo "Mod file.4.txt $x" >src/file.4.txt &&
+		if list_contains "a,b" "$x"; then
+			printf "%10000s" X >>src/file.4.txt
+		fi &&
+		if list_contains "c,d" "$x"; then
+			printf "%20000s" X >>src/file.4.txt
+		fi &&
+		git -C src add file.4.txt &&
+		git -C src commit -m "mod $x" || return 1
+	done &&
+	git -C src push -u srv main
+'
+
+# Do partial fetch to fetch smaller files; then verify that without --refetch
+# applying a new filter does not refetch missing large objects. Then use
+# --refetch to apply the new filter on existing commits. Test it under both
+# protocol v2 & v0.
+test_expect_success 'apply a different filter using --refetch' '
+	git -C pc1 fetch --filter=blob:limit=999 origin &&
+	git -C pc1 rev-list --quiet --objects --missing=print \
+		main..origin/main >observed &&
+	test_line_count = 4 observed &&
+
+	git -C pc1 fetch --filter=blob:limit=19999 --refetch origin &&
+	git -C pc1 rev-list --quiet --objects --missing=print \
+		main..origin/main >observed &&
+	test_line_count = 2 observed &&
+
+	git -c protocol.version=0 -C pc1 fetch --filter=blob:limit=29999 \
+		--refetch origin &&
+	git -C pc1 rev-list --quiet --objects --missing=print \
+		main..origin/main >observed &&
+	test_line_count = 0 observed
+'
+
+test_expect_success 'fetch --refetch works with a shallow clone' '
+	git clone --no-checkout --depth=1 --filter=blob:none "file://$(pwd)/srv.bare" pc1s &&
+	git -C pc1s rev-list --objects --missing=print HEAD >observed &&
+	test_line_count = 6 observed &&
+
+	GIT_TRACE=1 git -C pc1s fetch --filter=blob:limit=999 --refetch origin &&
+	git -C pc1s rev-list --objects --missing=print HEAD >observed &&
+	test_line_count = 6 observed
+'
+
 test_expect_success 'partial clone with transfer.fsckobjects=1 works with submodules' '
 	test_create_repo submodule &&
 	test_commit -C submodule mycommit &&
@@ -225,7 +275,7 @@  test_expect_success 'use fsck before and after manually fetching a missing subtr
 
 	# Auto-fetch all remaining trees and blobs with --missing=error
 	git -C dst rev-list --missing=error --objects main >fetched_objects &&
-	test_line_count = 70 fetched_objects &&
+	test_line_count = 88 fetched_objects &&
 
 	awk -f print_1.awk fetched_objects |
 	xargs -n1 git -C dst cat-file -t >fetched_types &&