diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2018-05-19 08:28:24 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-05-21 08:07:20 +0300 |
commit | 87be252333bac84d425973627266dfa20511224d (patch) | |
tree | 86e6ab8cf5b0c81da90b2b443a81fb601d1bc669 /revision.c | |
parent | 3cc0287b394bf802af68d4fdb8c18e16318df907 (diff) |
revision.c: use commit-slab for show_source
Instead of relying on commit->util to store the source string, let the
user provide a commit-slab to store the source strings in.
It's done so that commit->util can be removed. See more explanation in
the commit that removes commit->util.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'revision.c')
-rw-r--r-- | revision.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/revision.c b/revision.c index 1cff11833e..be8fe7d67b 100644 --- a/revision.c +++ b/revision.c @@ -29,6 +29,8 @@ volatile show_early_output_fn_t show_early_output; static const char *term_bad; static const char *term_good; +implement_shared_commit_slab(revision_sources, char *); + void show_object_with_name(FILE *out, struct object *obj, const char *name) { const char *p; @@ -255,14 +257,19 @@ static struct commit *handle_commit(struct rev_info *revs, */ if (object->type == OBJ_COMMIT) { struct commit *commit = (struct commit *)object; + if (parse_commit(commit) < 0) die("unable to parse commit %s", name); if (flags & UNINTERESTING) { mark_parents_uninteresting(commit); revs->limited = 1; } - if (revs->show_source && !commit->util) - commit->util = xstrdup(name); + if (revs->sources) { + char **slot = revision_sources_at(revs->sources, commit); + + if (!*slot) + *slot = xstrdup(name); + } return commit; } @@ -814,8 +821,12 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit, } return -1; } - if (revs->show_source && !p->util) - p->util = commit->util; + if (revs->sources) { + char **slot = revision_sources_at(revs->sources, p); + + if (!*slot) + *slot = *revision_sources_at(revs->sources, commit); + } p->object.flags |= left_flag; if (!(p->object.flags & SEEN)) { p->object.flags |= SEEN; |