pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/msysgit/git/commit/063da62b02aeafe58fdacce0ea48c0761b06df60

rimer-b48faa60c69660fa.css" /> commit: add for_each_mergetag() · msysgit/git@063da62 · GitHub
Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 063da62

Browse files
chriscoolgitster
authored andcommitted
commit: add for_each_mergetag()
In the same way as there is for_each_ref() to iterate on refs, for_each_mergetag() allows the caller to iterate on the mergetags of a given commit. Use it to rewrite show_mergetag() used in "git log". Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 6f92e5f commit 063da62

3 files changed

Lines changed: 22 additions & 11 deletions

File tree

commit.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,6 +1316,19 @@ struct commit_extra_header *read_commit_extra_headers(struct commit *commit,
13161316
return extra;
13171317
}
13181318

1319+
void for_each_mergetag(each_mergetag_fn fn, struct commit *commit, void *data)
1320+
{
1321+
struct commit_extra_header *extra, *to_free;
1322+
1323+
to_free = read_commit_extra_headers(commit, NULL);
1324+
for (extra = to_free; extra; extra = extra->next) {
1325+
if (strcmp(extra->key, "mergetag"))
1326+
continue; /* not a merge tag */
1327+
fn(commit, extra, data);
1328+
}
1329+
free_commit_extra_headers(to_free);
1330+
}
1331+
13191332
static inline int standard_header_field(const char *field, size_t len)
13201333
{
13211334
return ((len == 4 && !memcmp(field, "tree ", 5)) ||

commit.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,11 @@ extern struct commit_extra_header *read_commit_extra_headers(struct commit *, co
312312

313313
extern void free_commit_extra_headers(struct commit_extra_header *extra);
314314

315+
typedef void (*each_mergetag_fn)(struct commit *commit, struct commit_extra_header *extra,
316+
void *cb_data);
317+
318+
extern void for_each_mergetag(each_mergetag_fn fn, struct commit *commit, void *data);
319+
315320
struct merge_remote_desc {
316321
struct object *obj; /* the named object, could be a tag */
317322
const char *name;

log-tree.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,11 @@ static int is_common_merge(const struct commit *commit)
413413
&& !commit->parents->next->next);
414414
}
415415

416-
static void show_one_mergetag(struct rev_info *opt,
416+
static void show_one_mergetag(struct commit *commit,
417417
struct commit_extra_header *extra,
418-
struct commit *commit)
418+
void *data)
419419
{
420+
struct rev_info *opt = (struct rev_info *)data;
420421
unsigned char sha1[20];
421422
struct tag *tag;
422423
struct strbuf verify_message;
@@ -463,15 +464,7 @@ static void show_one_mergetag(struct rev_info *opt,
463464

464465
static void show_mergetag(struct rev_info *opt, struct commit *commit)
465466
{
466-
struct commit_extra_header *extra, *to_free;
467-
468-
to_free = read_commit_extra_headers(commit, NULL);
469-
for (extra = to_free; extra; extra = extra->next) {
470-
if (strcmp(extra->key, "mergetag"))
471-
continue; /* not a merge tag */
472-
show_one_mergetag(opt, extra, commit);
473-
}
474-
free_commit_extra_headers(to_free);
467+
for_each_mergetag(show_one_mergetag, commit, opt);
475468
}
476469

477470
void show_log(struct rev_info *opt)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy