git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Beller <sbeller@google.com>
To: Jonathan Tan <jonathantanmy@google.com>
Cc: git <git@vger.kernel.org>
Subject: Re: [PATCH v2 1/6] commit-graph: refactor preparing commit graph
Date: Mon, 9 Jul 2018 14:41:23 -0700	[thread overview]
Message-ID: <CAGZ79kaE_42A2B=VjRcNdJzueeVZmrsj6iNgk=6u9bi6pA4hQA@mail.gmail.com> (raw)
In-Reply-To: <9769e2a7471c2b32185896e833cc74824ac5437e.1531168854.git.jonathantanmy@google.com>

Hi Jonathan,
On Mon, Jul 9, 2018 at 1:44 PM Jonathan Tan <jonathantanmy@google.com> wrote:
>
> Two functions in the code (1) check if the repository is configured for
> commit graphs, (2) call prepare_commit_graph(), and (3) check if the
> graph exists. Move (1) and (3) into prepare_commit_graph(), reducing
> duplication of code.
>
> Signed-off-by: Jonathan Tan <jonathantanmy@google.com>



>  static int prepare_commit_graph_run_once = 0;
> -static void prepare_commit_graph(void)
> +
> +/*
> + * Return 1 if commit_graph is non-NULL, and 0 otherwise.
> + *
> + * On the first invocation, this function attemps to load the commit
> + * graph if the_repository is configured to have one.

and as we talk about in-memory commit graph (and not some
stale file that may still be around on the fs), we can assertly return
0 when core_commit_graph is false.

Makes sense!

> @@ -337,22 +348,17 @@ static int parse_commit_in_graph_one(struct commit_graph *g, struct commit *item
>
>  int parse_commit_in_graph(struct commit *item)
>  {
> -       if (!core_commit_graph)
> +       if (!prepare_commit_graph())
>                 return 0;
> -
> -       prepare_commit_graph();
> -       if (commit_graph)
> -               return parse_commit_in_graph_one(commit_graph, item);
> -       return 0;
> +       return parse_commit_in_graph_one(commit_graph, item);

Makes sense.

>  }
>
>  void load_commit_graph_info(struct commit *item)
>  {
>         uint32_t pos;
> -       if (!core_commit_graph)
> +       if (!prepare_commit_graph())
>                 return;
> -       prepare_commit_graph();
> -       if (commit_graph && find_commit_in_graph(item, commit_graph, &pos))
> +       if (find_commit_in_graph(item, commit_graph, &pos))
>                 fill_commit_graph_info(item, commit_graph, pos);

here too,

This is
Reviewed-by: Stefan Beller <sbeller@google.com>

  reply	other threads:[~2018-07-09 21:41 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-21 21:29 [PATCH 0/5] Object store refactoring: commit graph Jonathan Tan
2018-06-21 21:29 ` [PATCH 1/5] object-store: add missing include Jonathan Tan
2018-06-21 21:29 ` [PATCH 2/5] commit-graph: add missing forward declaration Jonathan Tan
2018-06-21 21:43   ` Stefan Beller
2018-06-21 22:39     ` Jonathan Tan
2018-06-22  0:17       ` Derrick Stolee
2018-06-21 21:29 ` [PATCH 3/5] commit-graph: add free_commit_graph Jonathan Tan
2018-06-21 21:29 ` [PATCH 4/5] commit-graph: store graph in struct object_store Jonathan Tan
2018-06-25 20:57   ` Junio C Hamano
2018-06-25 22:09     ` Jonathan Tan
2018-06-26 16:40       ` Junio C Hamano
2018-06-21 21:29 ` [PATCH 5/5] commit-graph: add repo arg to graph readers Jonathan Tan
2018-06-21 22:41   ` Stefan Beller
2018-06-21 23:06     ` Jonathan Tan
2018-06-22  0:33       ` Derrick Stolee
2018-06-22  1:01         ` Derrick Stolee
2018-06-22 17:21         ` Jonathan Tan
2018-07-09 20:44 ` [PATCH v2 on ds/commit-graph-fsck 0/6] Object store refactoring: commit graph Jonathan Tan
2018-07-09 20:44   ` [PATCH v2 1/6] commit-graph: refactor preparing " Jonathan Tan
2018-07-09 21:41     ` Stefan Beller [this message]
2018-07-10  0:23       ` Derrick Stolee
2018-07-09 20:44   ` [PATCH v2 2/6] object-store: add missing include Jonathan Tan
2018-07-09 20:44   ` [PATCH v2 3/6] commit-graph: add missing forward declaration Jonathan Tan
2018-07-09 20:44   ` [PATCH v2 4/6] commit-graph: add free_commit_graph Jonathan Tan
2018-07-09 20:44   ` [PATCH v2 5/6] commit-graph: store graph in struct object_store Jonathan Tan
2018-07-09 20:44   ` [PATCH v2 6/6] commit-graph: add repo arg to graph readers Jonathan Tan
2018-07-10  0:48     ` Derrick Stolee
2018-07-10 17:31       ` Jonathan Tan
2018-07-11 19:41         ` Derrick Stolee
2018-07-11 21:08           ` Jonathan Tan
2018-07-10 11:53     ` SZEDER Gábor
2018-07-10 13:18       ` Johannes Schindelin
2018-07-10 17:23         ` Jonathan Tan
2018-07-09 21:47   ` [PATCH v2 on ds/commit-graph-fsck 0/6] Object store refactoring: commit graph Stefan Beller
2018-07-09 22:27   ` Junio C Hamano
2018-07-10  0:30     ` Derrick Stolee
2018-07-10  0:32       ` Derrick Stolee
2018-07-11 22:42 ` [PATCH v3 " Jonathan Tan
2018-07-11 22:42   ` [PATCH v3 1/6] commit-graph: refactor preparing " Jonathan Tan
2018-07-11 22:42   ` [PATCH v3 2/6] object-store: add missing include Jonathan Tan
2018-07-11 22:42   ` [PATCH v3 3/6] commit-graph: add missing forward declaration Jonathan Tan
2018-07-11 22:42   ` [PATCH v3 4/6] commit-graph: add free_commit_graph Jonathan Tan
2018-07-11 22:42   ` [PATCH v3 5/6] commit-graph: store graph in struct object_store Jonathan Tan
2018-07-11 22:42   ` [PATCH v3 6/6] commit-graph: add repo arg to graph readers Jonathan Tan
2018-08-13  0:30     ` [PATCH] t5318: avoid unnecessary command substitutions SZEDER Gábor
2018-08-13 11:23       ` Derrick Stolee
2018-08-13 19:05       ` Junio C Hamano
2018-07-12 16:56   ` [PATCH v3 0/6] Object store refactoring: commit graph Junio C Hamano
2018-07-12 17:43   ` Derrick Stolee

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='CAGZ79kaE_42A2B=VjRcNdJzueeVZmrsj6iNgk=6u9bi6pA4hQA@mail.gmail.com' \
    --to=sbeller@google.com \
    --cc=git@vger.kernel.org \
    --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.
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).