@matheusbsbs / matheus-bagliano / commits / 3175aa1ec2
Fork 0

for-each-ref: "creator" and "creatordate" fields

This adds "creator" (which is parallel to "tagger" or "committer") and "creatordate" (corresponds to "taggerdate" and "committerdate"). As other "date" fields, "creatordate" sorts numerically and displays human readably. This allows for example for sorting together heavyweigth and lightweight tags. Signed-off-by: Junio C Hamano <junkio@cox.net> Acked-by: Jakub Narebski <jnareb@gmail.com>

Junio C Hamano committed Oct 28, 2006 at 13:33 UTC 3175aa1ec28c8fb119058111a2f629425ef1aab0
1 file changed +25
builtin-for-each-ref.c
+25
@@ -59,6 +59,8 @@ static struct {
59 { "taggername" },
60 { "taggeremail" },
61 { "taggerdate", FIELD_TIME },
62 + { "creator" },
63 + { "creatordate", FIELD_TIME },
64 { "subject" },
65 { "body" },
66 { "contents" },
@@ -401,6 +403,29 @@ static void grab_person(const char *who, struct atom_value *val, int deref, stru
403 else if (!strcmp(name + wholen, "date"))
404 grab_date(wholine, v);
405 }
406 +
407 + /* For a tag or a commit object, if "creator" or "creatordate" is
408 + * requested, do something special.
409 + */
410 + if (strcmp(who, "tagger") && strcmp(who, "committer"))
411 + return; /* "author" for commit object is not wanted */
412 + if (!wholine)
413 + wholine = find_wholine(who, wholen, buf, sz);
414 + if (!wholine)
415 + return;
416 + for (i = 0; i < used_atom_cnt; i++) {
417 + const char *name = used_atom[i];
418 + struct atom_value *v = &val[i];
419 + if (!!deref != (*name == '*'))
420 + continue;
421 + if (deref)
422 + name++;
423 +
424 + if (!strcmp(name, "creatordate"))
425 + grab_date(wholine, v);
426 + else if (!strcmp(name, "creator"))
427 + v->s = copy_line(wholine);
428 + }
429 }
430
431 static void find_subpos(const char *buf, unsigned long sz, const char **sub, const char **body)