Re: [PATCH v5 09/14] commit.h: add wrapped tags in commit struct
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Aug 25, 2021, 23:58 UTC
- Message-ID
- <87wno9axfs.fsf@evledraar.gmail.com>
- In-Reply-To
- <011e5eaea3f48eeacac1614f769e8fd809e0c093.1629805396.git.dyroneteng@gmail.com>
On Wed, Aug 25 2021, Teng Long wrote:
Show 54 quoted lines
> Signed-off-by: Teng Long <dyroneteng@gmail.com>
> ---
> commit.h | 5 +++++
> revision.c | 8 ++++++--
> 2 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/commit.h b/commit.h
> index df42eb434f..1e99e9ae8a 100644
> --- a/commit.h
> +++ b/commit.h
> @@ -38,6 +38,11 @@ struct commit {
> */
> struct tree *maybe_tree;
> unsigned int index;
> + /*
> + * wrapped tags or NULL. If the commit is peeled from tag(s),
> + * then save the wraps, otherwise will be NULL.
> + */
> + struct object_list *wraps;
> };
>
> extern int save_commit_buffer;
> diff --git a/revision.c b/revision.c
> index 65e0926d25..aecf493f46 100644
> --- a/revision.c
> +++ b/revision.c
> @@ -416,14 +416,17 @@ static struct commit *handle_commit(struct rev_info *revs,
> const char *path = entry->path;
> unsigned int mode = entry->mode;
> unsigned long flags = object->flags;
> -
> + struct object_list *wraps = NULL;
> /*
> * Tag object? Look what it points to..
> */
> while (object->type == OBJ_TAG) {
> struct tag *tag = (struct tag *) object;
> - if (revs->tag_objects && !(flags & UNINTERESTING))
> + if (revs->tag_objects && !(flags & UNINTERESTING)) {
> + object_list_insert(object, &wraps);
> add_pending_object(revs, object, tag->tag);
> + }
> +
> object = parse_object(revs->repo, get_tagged_oid(tag));
> if (!object) {
> if (revs->ignore_missing_links || (flags & UNINTERESTING))
> @@ -449,6 +452,7 @@ static struct commit *handle_commit(struct rev_info *revs,
> */
> if (object->type == OBJ_COMMIT) {
> struct commit *commit = (struct commit *)object;
> + commit->wraps = wraps;
>
> if (repo_parse_commit(revs->repo, commit) < 0)
> die("unable to parse commit %s", name);Can't we store this info on the side between these two static functions somehow, instead of adding this "wraps" to all commit structs?