git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Derrick Stolee <dstolee@microsoft.com>,
	Johannes Schindelin <johannes.schindelin@gmx.de>,
	Jonathan Tan <jonathantanmy@google.com>
Subject: noisy "warning: repository contains (deprecated) grafts; skipping commit-graph" warnings
Date: Thu, 25 Feb 2021 15:07:41 +0100	[thread overview]
Message-ID: <87pn0o6y1e.fsf@evledraar.gmail.com> (raw)
In-Reply-To: <pull.875.git.1613057954213.gitgitgadget@gmail.com>


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


      parent reply	other threads:[~2021-02-25 14:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-11 15:39 [PATCH] commit-graph: when incompatible with graphs, indicate why Johannes Schindelin via GitGitGadget
2021-02-11 16:17 ` Derrick Stolee
2021-02-11 17:32   ` Junio C Hamano
2021-02-25 14:07 ` Ævar Arnfjörð Bjarmason [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=87pn0o6y1e.fsf@evledraar.gmail.com \
    --to=avarab@gmail.com \
    --cc=dstolee@microsoft.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=johannes.schindelin@gmx.de \
    --cc=jonathantanmy@google.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).