Derrick Stolee <dsto...@microsoft.com> writes:

> In anticipation of checking commit-graph file contents against the
> object database, create parse_commit_internal() to allow side-stepping
> the commit-graph file and parse directly from the object database.

Nitpick/Bikeshed painting: do we have any naming convention for such
functions (*_internal() here)?

>
> Due to the use of generation numbers, this method should not be called
> unless the intention is explicit in avoiding commits from the
> commit-graph file.

Looks good to me, except for some stray whitespace changes in the
patch.

>
> Signed-off-by: Derrick Stolee <dsto...@microsoft.com>
> ---
>  commit.c | 14 ++++++++++----
>  commit.h |  1 +
>  2 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/commit.c b/commit.c
> index 9ef6f699bd..07752d8503 100644
> --- a/commit.c
> +++ b/commit.c
> @@ -392,7 +392,8 @@ int parse_commit_buffer(struct commit *item, const void 
> *buffer, unsigned long s
>       return 0;
>  }
>  
> -int parse_commit_gently(struct commit *item, int quiet_on_missing)
> +

Stray empty line, though I think it may improve readability of the code
by using two empty lines between separate functions.

But to be consistent with the rest of the file, there shouldn't be this
extra empty line.

> +int parse_commit_internal(struct commit *item, int quiet_on_missing, int 
> use_commit_graph)
>  {
>       enum object_type type;
>       void *buffer;
> @@ -403,17 +404,17 @@ int parse_commit_gently(struct commit *item, int 
> quiet_on_missing)
>               return -1;
>       if (item->object.parsed)
>               return 0;
> -     if (parse_commit_in_graph(item))
> +     if (use_commit_graph && parse_commit_in_graph(item))
>               return 0;

All right.

>       buffer = read_sha1_file(item->object.oid.hash, &type, &size);
>       if (!buffer)
>               return quiet_on_missing ? -1 :
>                       error("Could not read %s",
> -                          oid_to_hex(&item->object.oid));
> +                                     oid_to_hex(&item->object.oid));

Stray whitespace change (looks like spaces to tabs conversion).

>       if (type != OBJ_COMMIT) {
>               free(buffer);
>               return error("Object %s not a commit",
> -                          oid_to_hex(&item->object.oid));
> +                             oid_to_hex(&item->object.oid));

Stray whitespace change (looks like spaces to tabs conversion).

>       }
>       ret = parse_commit_buffer(item, buffer, size, 0);
>       if (save_commit_buffer && !ret) {
> @@ -424,6 +425,11 @@ int parse_commit_gently(struct commit *item, int 
> quiet_on_missing)
>       return ret;
>  }
>  
> +int parse_commit_gently(struct commit *item, int quiet_on_missing)
> +{
> +     return parse_commit_internal(item, quiet_on_missing, 1);
> +}

All right; if it is internal details of implementations, I don't mind
this slightly cryptic "1" as the value of last parameters.

> +
>  void parse_commit_or_die(struct commit *item)
>  {
>       if (parse_commit(item))
> diff --git a/commit.h b/commit.h
> index b5afde1ae9..5fde74fcd7 100644
> --- a/commit.h
> +++ b/commit.h
> @@ -73,6 +73,7 @@ struct commit *lookup_commit_reference_by_name(const char 
> *name);
>  struct commit *lookup_commit_or_die(const struct object_id *oid, const char 
> *ref_name);
>  
>  int parse_commit_buffer(struct commit *item, const void *buffer, unsigned 
> long size, int check_graph);
> +int parse_commit_internal(struct commit *item, int quiet_on_missing, int 
> use_commit_graph);
>  int parse_commit_gently(struct commit *item, int quiet_on_missing);
>  static inline int parse_commit(struct commit *item)
>  {

All right.

Reply via email to