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

Re: Is fetch.writeCommitGraph (and thus features.experimental) meant to work in the presence of shallow clones?

From
JTJonathan Tan <jonathantanmy@google.com>
Date
Apr 16, 2020, 02:05 UTC
Message-ID
<20200416020509.225014-1-jonathantanmy@google.com>
In-Reply-To
<20200414235057.GA6863@syl.local>
Show 9 quoted lines
> Here's a patch that I didn't sign-off on that fixes the problem for me.
> 
> --- >8 ---
> 
> Subject: [PATCH] shallow.c: use 'reset_repository_shallow' when appropriate
> 
> In bd0b42aed3 (fetch-pack: do not take shallow lock unnecessarily,
> 2019-01-10), the author noted that 'is_repository_shallow' produces
> visible side-effect(s) by setting 'is_shallow' and 'shallow_stat'.

Thanks for the reference to my commit. When I wrote that, if I remember correctly, I found it difficult to be able to guarantee that the clearing of is_shallow and shallow_stat was performed upon every commit-lock (which creates a new shallow file) and <unlink+rollback-lock> (which removes the shallow file, potentially changing the repo state from shallow to none), so I added the NEEDSWORK instead. I see that this patch makes some progress in solving that.

Show 8 quoted lines
> @@ -1630,6 +1630,7 @@ static void update_shallow(struct fetch_pack_args *args,
>  		if (*alternate_shallow_file == '\0') { /* --unshallow */
>  			unlink_or_warn(git_path_shallow(the_repository));
>  			rollback_lock_file(&shallow_lock);
> +			reset_repository_shallow(the_repository);
>  		} else
>  			commit_lock_file(&shallow_lock);
>  		alternate_shallow_file = NULL;

Here, do you need a reset in the "else" branch as well? (I.e. in both branches, so you can put it outside the "if" block.) I didn't look at it too closely, but I would think that when the shallow_lock file is committed, there might have been no shallow beforehand, changing the state from no-shallow to shallow.

Show 8 quoted lines
> @@ -411,6 +411,7 @@ void prune_shallow(unsigned options)
>  			die_errno("failed to write to %s",
>  				  get_lock_file_path(&shallow_lock));
>  		commit_lock_file(&shallow_lock);
> +		reset_repository_shallow(the_repository);
>  	} else {
>  		unlink(git_path_shallow(the_repository));
>  		rollback_lock_file(&shallow_lock);

And the opposite case here - reset in the "else" branch because the state could have changed from shallow to no-shallow.

In any case, I think the commit message should discuss why reset_repository_shallow() is added only on the unlink+rollback side in one "if" statement, but only on the opposite "commit" side in another "if" statement.

Previous: Elijah NewrenNext: Jonathan Nieder
Message 9 of 12 in “Is fetch.writeCommitGraph (and thus features.experimental) meant to work in the presence of shallow clones?”
  1. Elijah NewrenApr 14, 2020
  2. Taylor BlauApr 14, 2020
  3. Derrick StoleeApr 14, 2020
  4. Taylor BlauApr 14, 2020
  5. Taylor BlauApr 15, 2020
  6. Derrick StoleeApr 15, 2020
  7. Taylor BlauApr 15, 2020
  8. Elijah NewrenApr 15, 2020
  9. Jonathan TanApr 16, 2020
  10. Jonathan NiederApr 15, 2020
  11. Elijah NewrenApr 15, 2020
  12. Taylor BlauApr 16, 2020

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.