git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] index-pack: remove fetch_if_missing=0

From
JTJonathan Tan <jonathantanmy@google.com>
Date
Feb 27, 2023, 22:14 UTC
Message-ID
<20230227221451.2433306-1-jonathantanmy@google.com>
In-Reply-To
<20230225052439.27096-1-five231003@gmail.com>
Kousik Sanagavarapu <five231003@gmail.com> writes:
> A collision test is triggered in sha1_object(), whenever there is an
> object file in our repo. If our repo is a partial clone, then checking
> for this file existence has the behavior of lazy-fetching the object
> because we have one or more promisor remotes.
Hmm...this is not true, because (as you said)...
 
> This behavior is controlled by setting fetch_if_missing to 0,
...this makes it so that we don't fetch in this situation.
> but this
> global was added in the first place as a temporary measure to suppress
> the fetching of missing objects and can be removed once the commands
> have been taught to handle these cases.
Yes, that's true.
Show 11 quoted lines
> @@ -1728,14 +1727,6 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
>  	int report_end_of_input = 0;
>  	int hash_algo = 0;
>  
> -	/*
> -	 * index-pack never needs to fetch missing objects except when
> -	 * REF_DELTA bases are missing (which are explicitly handled). It only
> -	 * accesses the repo to do hash collision checks and to check which
> -	 * REF_DELTA bases need to be fetched.
> -	 */
> -	fetch_if_missing = 0;

I think that the author of such a commit (you) should also independently verify that this comment is true (and if it is, then yes, all the remaining cases are handled and we can remove this assignment to fetch_if_missing). I believe this comment to be true, but I haven't checked the code in a while so I'm not sure myself.

Show 27 quoted lines
> +test_expect_success 'index-pack does not lazy-fetch when checking for sha1 collisions' '
> +	rm -rf server promisor-remote client &&
> +	rm -rf object-count &&
> +
> +	git init server &&
> +	for i in 1 2 3 4
> +	do
> +		echo $i >$(pwd)/server/file$i &&
> +		git -C server add file$i &&
> +		git -C server commit -am "Commit $i" || return 1
> +	done &&
> +	git -C server config --local uploadpack.allowFilter 1 &&
> +	git -C server config --local uploadpack.allowAnySha1InWant 1 &&
> +	HASH=$(git -C server hash-object file3) &&
> +
> +	git init promisor-remote &&
> +	git -C promisor-remote fetch --keep "file://$(pwd)/server" $HASH &&
> +
> +	git clone --no-checkout --filter=blob:none "file://$(pwd)/server" client &&
> +	git -C client remote set-url origin "file://$(pwd)/promisor-remote" &&
> +	git -C client config extensions.partialClone 1 &&
> +	git -C client config remote.origin.promisor 1 &&
> +
> +	# make sure that index-pack is run from within the repository
> +	git -C client index-pack $(pwd)/client/.git/objects/pack/*.pack &&
> +	test_path_is_missing $(pwd)/client/file3
> +'

How does this check that no lazy fetch has occurred? It seems to me that you're just checking the existence of a file in the worktree, which does not indicate the presence or absence of a lazy fetch.

I think the way to test needs to be more complicated: you need to create a partial clone, fetch into it from another repo, and then verify that no fetches were made to the original partial clone.

Previous: Kousik SanagavarapuNext: Kousik Sanagavarapu
Message 3 of 20 in “index-pack: remove fetch_if_missing=0”
  1. index-pack: remove fetch_if_missing=0Kousik Sanagavarapu, Feb 25, 2023
  2. Kousik SanagavarapuFeb 27, 2023
  3. Jonathan TanFeb 27, 2023
  4. Kousik SanagavarapuFeb 28, 2023
  5. index-pack: remove fetch_if_missing=0Kousik Sanagavarapu, Mar 10, 2023
  6. Junio C HamanoMar 10, 2023
  7. Jonathan TanMar 10, 2023
  8. Junio C HamanoMar 10, 2023
  9. Jonathan TanMar 11, 2023
  10. Kousik SanagavarapuMar 12, 2023
  11. Kousik SanagavarapuMar 11, 2023
  12. Kousik SanagavarapuMar 11, 2023
  13. index-pack: remove fetch_if_missing=0Kousik Sanagavarapu, Mar 13, 2023
  14. Junio C HamanoMar 13, 2023
  15. Junio C HamanoMar 13, 2023
  16. index-pack: remove fetch_if_missing=0Kousik Sanagavarapu, Mar 17, 2023
  17. Junio C HamanoMar 17, 2023
  18. Kousik SanagavarapuMar 19, 2023
  19. Sean AllredMar 11, 2023
  20. Junio C HamanoMar 11, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.