git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Derrick Stolee <stolee@gmail.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Thomas Ferris Nicolaisen <tfnico@gmail.com>,
	"git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: commit-graph idea: warn when disabled for incompatible repositories
Date: Tue, 18 Dec 2018 14:07:26 -0500	[thread overview]
Message-ID: <98e86f95-78d7-a64b-86d9-c33cecfcb28c@gmail.com> (raw)
In-Reply-To: <87bm5ig0h3.fsf@evledraar.gmail.com>

On 12/18/2018 1:21 PM, Ævar Arnfjörð Bjarmason wrote:
> diff --git a/builtin/gc.c b/builtin/gc.c
> index 871a56f1c5..702568b70d 100644
> --- a/builtin/gc.c
> +++ b/builtin/gc.c
> @@ -662,9 +662,14 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
>   	if (pack_garbage.nr > 0)
>   		clean_pack_garbage();
>
> -	if (gc_write_commit_graph)
> +	if (gc_write_commit_graph) {
> +		int verbose = !quiet && !daemonized;
> +		if (verbose && !commit_graph_compatible(the_repository))
> +			warning(_("The `gc.writeCommitGraph' setting is on, "
> +				  "but commit_graph_compatible() = false"));
>   		write_commit_graph_reachable(get_object_directory(), 0,
> -					     !quiet && !daemonized);
> +					     verbose);
> +	}

I actually think this is the wrong place to put it. This will cause a 
warning for someone with 'gc.writeCommitGraph' enabled and running GC on 
a shallow clone.

I think the issue was someone running 'git commit-graph write' inside a 
shallow clone that succeeds without doing anything.

Also, I bet you would hit this block if you run the test suite with 
GIT_TEST_COMMIT_GRAPH=1.

Thanks,

-Stolee


>   	if (auto_gc && too_many_loose_objects())
>   		warning(_("There are too many unreachable loose objects; "
> diff --git a/commit-graph.c b/commit-graph.c
> index 40c855f185..60915bf9aa 100644
> --- a/commit-graph.c
> +++ b/commit-graph.c
> @@ -61,7 +61,7 @@ static struct commit_graph *alloc_commit_graph(void)
>
>   extern int read_replace_refs;
>
> -static int commit_graph_compatible(struct repository *r)
> +int commit_graph_compatible(struct repository *r)
>   {
>   	if (!r->gitdir)
>   		return 0;
> diff --git a/commit-graph.h b/commit-graph.h
> index 9db40b4d3a..7c92d41a28 100644
> --- a/commit-graph.h
> +++ b/commit-graph.h
> @@ -12,6 +12,8 @@ struct commit;
>
>   char *get_commit_graph_filename(const char *obj_dir);
>
> +int commit_graph_compatible(struct repository *r);
> +
>   /*
>    * Given a commit struct, try to fill the commit struct info, including:
>    *  1. tree object

This part looks correct, and necessary for the warning in 
builtin/commit-graph.c

Thanks,

-Stolee


      reply	other threads:[~2018-12-18 19:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-18 14:22 commit-graph idea: warn when disabled for incompatible repositories Thomas Ferris Nicolaisen
2018-12-18 14:35 ` Derrick Stolee
2018-12-18 18:21   ` Ævar Arnfjörð Bjarmason
2018-12-18 19:07     ` Derrick Stolee [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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=98e86f95-78d7-a64b-86d9-c33cecfcb28c@gmail.com \
    --to=stolee@gmail.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=tfnico@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).