Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be clear why commit-graph was skipped #875

Closed

Conversation

dscho
Copy link
Member

@dscho dscho commented Feb 11, 2021

After repairing my local checkout, I was puzzled that the commit-graph file was not written. Turns out that I still had almost a dozen replace objects. But I only found out that they were blocking the commit-graph when I stepped through git gc in a debugger. This is my attempt to make it more straight-forward to recover from similar situations in the future.

Cc: Derrick Stolee dstolee@microsoft.com
cc: Derrick Stolee stolee@gmail.com
cc: Ævar Arnfjörð Bjarmason avarab@gmail.com

When `gc.writeCommitGraph = true`, it is possible that the commit-graph
is _still_ not written: replace objects, grafts and shallow repositories
are incompatible with the commit-graph feature.

Under such circumstances, we need to indicate to the user why the
commit-graph was not written instead of staying silent about it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho
Copy link
Member Author

dscho commented Feb 11, 2021

/submit

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 11, 2021

Submitted as pull.875.git.1613057954213.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git pr-875/dscho/warn-if-commit-graph-is-skipped-v1

To fetch this version to local tag pr-875/dscho/warn-if-commit-graph-is-skipped-v1:

git fetch --no-tags https://github.com/gitgitgadget/git tag pr-875/dscho/warn-if-commit-graph-is-skipped-v1

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 11, 2021

On the Git mailing list, Derrick Stolee wrote (reply to this):

On 2/11/21 10:39 AM, Johannes Schindelin via GitGitGadget wrote:
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
> 
> When `gc.writeCommitGraph = true`, it is possible that the commit-graph
> is _still_ not written: replace objects, grafts and shallow repositories
> are incompatible with the commit-graph feature.
> 
> Under such circumstances, we need to indicate to the user why the
> commit-graph was not written instead of staying silent about it.

This feedback is valuable for these corner cases, especially now
that the commit-graph is getting less and less "optional" as time
goes on.

> +		if (hashmap_get_size(&r->objects->replace_map->map)) {
> +			warning(_("repository contains replace objects; "
> +			       "skipping commit-graph"));
...
> +		warning(_("repository is shallow; skipping commit-graph"));

These warnings make sense to me.

Thanks,
-Stolee

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 11, 2021

User Derrick Stolee <stolee@gmail.com> has been added to the cc: list.

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 11, 2021

On the Git mailing list, Junio C Hamano wrote (reply to this):

Derrick Stolee <stolee@gmail.com> writes:

> On 2/11/21 10:39 AM, Johannes Schindelin via GitGitGadget wrote:
>> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>> 
>> When `gc.writeCommitGraph = true`, it is possible that the commit-graph
>> is _still_ not written: replace objects, grafts and shallow repositories
>> are incompatible with the commit-graph feature.
>> 
>> Under such circumstances, we need to indicate to the user why the
>> commit-graph was not written instead of staying silent about it.
>
> This feedback is valuable for these corner cases, especially now
> that the commit-graph is getting less and less "optional" as time
> goes on.
>
>> +		if (hashmap_get_size(&r->objects->replace_map->map)) {
>> +			warning(_("repository contains replace objects; "
>> +			       "skipping commit-graph"));
> ...
>> +		warning(_("repository is shallow; skipping commit-graph"));
>
> These warnings make sense to me.

I take that as your Acked-by.

Thanks, both.

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 11, 2021

This branch is now known as js/commit-graph-warning.

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 11, 2021

This patch series was integrated into seen via git@153cd96.

@gitgitgadget gitgitgadget bot added the seen label Feb 11, 2021
@gitgitgadget
Copy link

gitgitgadget bot commented Feb 12, 2021

This patch series was integrated into seen via git@dabbcfd.

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 12, 2021

This patch series was integrated into next via git@e9faad5.

@gitgitgadget gitgitgadget bot added the next label Feb 12, 2021
@gitgitgadget
Copy link

gitgitgadget bot commented Feb 19, 2021

This patch series was integrated into seen via git@726b11d.

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 19, 2021

This patch series was integrated into next via git@726b11d.

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 19, 2021

This patch series was integrated into master via git@726b11d.

@gitgitgadget gitgitgadget bot added the master label Feb 19, 2021
@gitgitgadget gitgitgadget bot closed this Feb 19, 2021
@gitgitgadget
Copy link

gitgitgadget bot commented Feb 19, 2021

Closed via 726b11d.

@dscho dscho deleted the warn-if-commit-graph-is-skipped branch February 19, 2021 12:23
@gitgitgadget
Copy link

gitgitgadget bot commented Feb 25, 2021

On the Git mailing list, Ævar Arnfjörð Bjarmason wrote (reply to this):


On Thu, Feb 11 2021, Johannes Schindelin via GitGitGadget wrote:

> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> When `gc.writeCommitGraph = true`, it is possible that the commit-graph
> is _still_ not written: replace objects, grafts and shallow repositories
> are incompatible with the commit-graph feature.
>
> Under such circumstances, we need to indicate to the user why the
> commit-graph was not written instead of staying silent about it.

This change really needs to be changed in some way or other, but
unfortunately the commit message has little/no information about when
these warnings are expected, and no tests.

I'm assuming you were targeting the write_commit_graph() caller of
commit_graph_compatible(). In that case this somewhat makes sense I
guess.

But we also call this at a distance when simply checking if we can
lookup things in the commit-graph, observe this on the current git
master:

    $ git clone --depth 1 --no-tags --single-branch --branch master https://github.com/git/git.git /tmp/git.git
    [...]
    warning: repository contains (deprecated) grafts; skipping commit-graph
    warning: repository contains (deprecated) grafts; skipping commit-graph

In that case we reach this via "parse_object()" in the "clone" process,
and print it twice because our rev-list child also spews the warning at
us.

Perhaps a better approach here is to pass down some flag and e.g. write
it only from "git gc" and friends?

> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>     Be clear why commit-graph was skipped
>     
>     After repairing my local checkout
>     [https://github.com/gitgitgadget/git/pull/873], I was puzzled that the
>     commit-graph file was not written. Turns out that I still had almost a
>     dozen replace objects. But I only found out that they were blocking the
>     commit-graph when I stepped through git gc in a debugger. This is my
>     attempt to make it more straight-forward to recover from similar
>     situations in the future.
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-875%2Fdscho%2Fwarn-if-commit-graph-is-skipped-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-875/dscho/warn-if-commit-graph-is-skipped-v1
> Pull-Request: https://github.com/gitgitgadget/git/pull/875
>
>  commit-graph.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/commit-graph.c b/commit-graph.c
> index 65410602714e..9ad176fa7c8e 100644
> --- a/commit-graph.c
> +++ b/commit-graph.c
> @@ -205,16 +205,24 @@ static int commit_graph_compatible(struct repository *r)
>  
>  	if (read_replace_refs) {
>  		prepare_replace_object(r);
> -		if (hashmap_get_size(&r->objects->replace_map->map))
> +		if (hashmap_get_size(&r->objects->replace_map->map)) {
> +			warning(_("repository contains replace objects; "
> +			       "skipping commit-graph"));
>  			return 0;
> +		}
>  	}
>  
>  	prepare_commit_graft(r);
>  	if (r->parsed_objects &&
> -	    (r->parsed_objects->grafts_nr || r->parsed_objects->substituted_parent))
> +	    (r->parsed_objects->grafts_nr || r->parsed_objects->substituted_parent)) {
> +		warning(_("repository contains (deprecated) grafts; "
> +		       "skipping commit-graph"));
>  		return 0;
> -	if (is_repository_shallow(r))
> +	}
> +	if (is_repository_shallow(r)) {
> +		warning(_("repository is shallow; skipping commit-graph"));
>  		return 0;
> +	}
>  
>  	return 1;
>  }
>
> base-commit: f9f2520108bab26a750bcbb00518dc27672cf0a2

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 25, 2021

User Ævar Arnfjörð Bjarmason <avarab@gmail.com> has been added to the cc: list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant