X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-for-each-ref.c;h=af72a12a5798265cece6c7b72582fd3672421394;hb=43853554542700e0d129ce853a3d4b16740035d4;hp=93d3d7eef06315c598952761a7f2755a2f95be2c;hpb=244a0ae114824c8ca29bdc2148b98caaae39cac2;p=git.git diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c index 93d3d7eef..af72a12a5 100644 --- a/builtin-for-each-ref.c +++ b/builtin-for-each-ref.c @@ -6,7 +6,6 @@ #include "tree.h" #include "blob.h" #include "quote.h" -#include /* Quoting styles */ #define QUOTE_NONE 0 @@ -59,6 +58,8 @@ static struct { { "taggername" }, { "taggeremail" }, { "taggerdate", FIELD_TIME }, + { "creator" }, + { "creatordate", FIELD_TIME }, { "subject" }, { "body" }, { "contents" }, @@ -401,6 +402,29 @@ static void grab_person(const char *who, struct atom_value *val, int deref, stru else if (!strcmp(name + wholen, "date")) grab_date(wholine, v); } + + /* For a tag or a commit object, if "creator" or "creatordate" is + * requested, do something special. + */ + if (strcmp(who, "tagger") && strcmp(who, "committer")) + return; /* "author" for commit object is not wanted */ + if (!wholine) + wholine = find_wholine(who, wholen, buf, sz); + if (!wholine) + return; + for (i = 0; i < used_atom_cnt; i++) { + const char *name = used_atom[i]; + struct atom_value *v = &val[i]; + if (!!deref != (*name == '*')) + continue; + if (deref) + name++; + + if (!strcmp(name, "creatordate")) + grab_date(wholine, v); + else if (!strcmp(name, "creator")) + v->s = copy_line(wholine); + } } static void find_subpos(const char *buf, unsigned long sz, const char **sub, const char **body) @@ -453,9 +477,9 @@ static void grab_sub_body_contents(struct atom_value *val, int deref, struct obj if (!strcmp(name, "subject")) v->s = copy_line(subpos); else if (!strcmp(name, "body")) - v->s = bodypos; + v->s = xstrdup(bodypos); else if (!strcmp(name, "contents")) - v->s = subpos; + v->s = xstrdup(subpos); } }