git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Shubham Kanodia via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org
Cc: Patrick Steinhardt <ps@pks.im>,
	Junio C Hamano <gitster@pobox.com>,
	Derrick Stolee <stolee@gmail.com>,
	Shubham Kanodia <shubham.kanodia10@gmail.com>
Subject: Re: [PATCH v4] remote: allow specifying refs to prefetch
Date: Tue, 5 Nov 2024 14:45:17 +0000	[thread overview]
Message-ID: <8c4e5911-d908-437a-8eec-385e272c8847@gmail.com> (raw)
In-Reply-To: <pull.1782.v4.git.1728073292874.gitgitgadget@gmail.com>

Hi Shubham

On 04/10/2024 21:21, Shubham Kanodia via GitGitGadget wrote:
> From: Shubham Kanodia <shubham.kanodia10@gmail.com>
> 

I agree with the Patrick's comments on the implementation, I've left a 
couple of test comments below.

> +test_expect_success 'prefetch with positive prefetch ref patterns' '
> +	test_create_repo filter-prefetch-positive &&
> +	(
> +		cd filter-prefetch-positive &&
> +		test_commit initial &&
> +		git clone . clone2 &&
> +		git remote add remote2 "file://$(pwd)/clone2" &&
> +
> +		cd clone2 &&
> +		git checkout -b feature && test_commit feature-commit-2 &&
> +		git checkout -b wip/test && test_commit wip-test-commit-2 &&
> +		git checkout -b topic/x && test_commit topic-x-commit-2 &&
> +		git push -f origin feature wip/test topic/x &&
> +		cd .. &&

I think it would make sense to have a blank line before this rather than 
after it so "cd" is grouped with the commands executed in that directory.

> +		git config remote.remote2.prefetchref "refs/heads/feature" &&
> +		fetchargs="--prefetch --prune --no-tags --no-write-fetch-head \
> +			--recurse-submodules=no --quiet" &&
> +		GIT_TRACE2_EVENT="$(pwd)/prefetch-positive.txt" \
> +			git maintenance run --task=prefetch 2>/dev/null &&
> +		test_subcommand git fetch remote2 $fetchargs <prefetch-positive.txt &&

This seems to be testing what "git maintenance" runs which is not really 
related to testing the prefetch ref pattern matching. I think just

	git maintenance run --task=prefetch &&

would be sufficient. We certainly should not be redirecting stderr to 
/dev/null as that hides any error messages that are helpful when 
debugging test failures.

> +		git rev-parse refs/prefetch/remotes/remote2/feature &&
> +		test_must_fail git rev-parse refs/prefetch/remotes/remote2/wip/test &&
> +		test_must_fail git rev-parse refs/prefetch/remotes/remote2/topic/x

these are the important tests for checking the prefetch pattern 
matching. We should perhaps be using "git rev-parse --verify"

The test coverage looks good

Best Wishes

Phillip

> +	)
> +'
> +
> +test_expect_success 'prefetch with negative prefetch ref patterns' '
> +	test_create_repo filter-prefetch-negative &&
> +	(
> +		cd filter-prefetch-negative &&
> +		test_commit initial &&
> +		git clone . clone3 &&
> +		git remote add remote3 "file://$(pwd)/clone3" &&
> +		cat .git/config &&
> +
> +		cd clone3 &&
> +		git checkout -b feature && test_commit feature-commit-3 &&
> +		git checkout -b wip/test && test_commit wip-test-commit-3 &&
> +		git checkout -b topic/x && test_commit topic-x-commit-3 &&
> +		git push -f origin feature wip/test topic/x &&
> +		cd .. &&
> +
> +		git config remote.remote3.prefetchref "!refs/heads/wip/*" &&
> +		fetchargs="--prefetch --prune --no-tags --no-write-fetch-head \
> +			--recurse-submodules=no --quiet" &&
> +		GIT_TRACE2_EVENT="$(pwd)/prefetch-negative.txt" \
> +			git maintenance run --task=prefetch 2>/dev/null &&
> +		test_subcommand git fetch remote3 $fetchargs <prefetch-negative.txt &&
> +		git rev-parse refs/prefetch/remotes/remote3/feature &&
> +		git rev-parse refs/prefetch/remotes/remote3/topic/x &&
> +		test_must_fail git rev-parse refs/prefetch/remotes/remote3/wip/test
> +	)
> +'
> +
> +test_expect_success 'prefetch with positive & negative prefetch ref patterns' '
> +	test_create_repo filter-prefetch-mixed &&
> +	(
> +		cd filter-prefetch-mixed &&
> +		test_commit initial &&
> +		git clone . clone4 &&
> +		git remote add remote4 "file://$(pwd)/clone4" &&
> +
> +		cd clone4 &&
> +		git checkout -b feature && test_commit feature-commit-4 &&
> +		git checkout -b topic/x && test_commit topic-x-commit-4 &&
> +		git checkout -b topic/y && test_commit topic-y-commit-4 &&
> +		git push -f origin feature topic/x topic/y &&
> +		cd .. &&
> +
> +		git config remote.remote4.prefetchref \
> +			"refs/heads/topic/* !refs/heads/topic/y" &&
> +		fetchargs="--prefetch --prune --no-tags --no-write-fetch-head \
> +			--recurse-submodules=no --quiet" &&
> +		GIT_TRACE2_EVENT="$(pwd)/prefetch-mixed.txt" \
> +			git maintenance run --task=prefetch 2>/dev/null &&
> +		test_subcommand git fetch remote4 $fetchargs <prefetch-mixed.txt &&
> +
> +		test_must_fail git rev-parse refs/prefetch/remotes/remote4/feature &&
> +		test_must_fail git rev-parse refs/prefetch/remotes/remote4/topic/y &&
> +		git rev-parse refs/prefetch/remotes/remote4/topic/x
> +	)
> +'
> +
>   test_expect_success 'loose-objects task' '
>   	# Repack everything so we know the state of the object dir
>   	git repack -adk &&
> 
> base-commit: 2e7b89e038c0c888acf61f1b4ee5a43d4dd5e94c


      parent reply	other threads:[~2024-11-05 14:45 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-09  9:47 [PATCH] remote: introduce config to set prefetch refs Shubham Kanodia via GitGitGadget
2024-09-09  9:51 ` Shubham Kanodia
2024-09-09 16:42 ` Junio C Hamano
2024-09-09 18:21   ` Shubham Kanodia
2024-09-09 18:33     ` Junio C Hamano
2024-09-13  6:16       ` Shubham Kanodia
2024-09-13 16:58         ` Junio C Hamano
2024-09-14 19:35           ` Shubham Kanodia
2024-09-14 20:11             ` Junio C Hamano
2024-09-15 14:06               ` Shubham Kanodia
2024-09-15 16:12               ` Junio C Hamano
2024-09-16  4:34                 ` Shubham Kanodia
2024-09-15 14:08 ` [PATCH v2] " Shubham Kanodia via GitGitGadget
2024-09-19 10:23   ` [PATCH v3] " Shubham Kanodia via GitGitGadget
2024-09-23 21:24     ` Junio C Hamano
2024-10-07 14:30       ` Shubham Kanodia
2024-10-04 20:21     ` [PATCH v4] remote: allow specifying refs to prefetch Shubham Kanodia via GitGitGadget
2024-11-04  8:47       ` Shubham Kanodia
2024-11-05  6:45       ` Patrick Steinhardt
2024-11-05 14:47         ` Phillip Wood
2024-11-05 16:26           ` Shubham Kanodia
2024-11-06  0:39             ` Junio C Hamano
2024-11-06  6:52               ` Patrick Steinhardt
2024-11-06  8:20                 ` Junio C Hamano
2024-11-06  6:46             ` Patrick Steinhardt
2024-11-06 11:04               ` Phillip Wood
2024-11-05 14:45       ` Phillip Wood [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8c4e5911-d908-437a-8eec-385e272c8847@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=ps@pks.im \
    --cc=shubham.kanodia10@gmail.com \
    --cc=stolee@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).