diff options
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | 2007-01-08 01:59:54 +0100 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-01-09 03:04:04 -0800 |
commit | 883d60fa97c6397450fb129634054e0a6101baac (patch) | |
tree | 5596e3bc152a71b2fc9ba3161217740bb4d77b6d /builtin-reflog.c | |
parent | 1295228d1fdda17c2ef62e712649c962c3da5eb7 (diff) | |
download | git-883d60fa97c6397450fb129634054e0a6101baac.tar.gz |
Sanitize for_each_reflog_ent()
It used to ignore the return value of the helper function; now, it
expects it to return 0, and stops iteration upon non-zero return
values; this value is then passed on as the return value of
for_each_reflog_ent().
Further, it makes no sense to force the parsing upon the helper
functions; for_each_reflog_ent() now calls the helper function with
old and new sha1, the email, the timestamp & timezone, and the message.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-reflog.c')
-rw-r--r-- | builtin-reflog.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/builtin-reflog.c b/builtin-reflog.c index a967117661..ca22452e64 100644 --- a/builtin-reflog.c +++ b/builtin-reflog.c @@ -195,19 +195,12 @@ static int keep_entry(struct commit **it, unsigned char *sha1) } static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1, - char *data, void *cb_data) + const char *email, unsigned long timestamp, int tz, + const char *message, void *cb_data) { struct expire_reflog_cb *cb = cb_data; - unsigned long timestamp; - char *cp, *ep; struct commit *old, *new; - cp = strchr(data, '>'); - if (!cp || *++cp != ' ') - goto prune; - timestamp = strtoul(cp, &ep, 10); - if (*ep != ' ') - goto prune; if (timestamp < cb->cmd->expire_total) goto prune; @@ -221,15 +214,20 @@ static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1, (new && !in_merge_bases(new, cb->ref_commit)))) goto prune; - if (cb->newlog) - fprintf(cb->newlog, "%s %s %s", - sha1_to_hex(osha1), sha1_to_hex(nsha1), data); + if (cb->newlog) { + char sign = (tz < 0) ? '-' : '+'; + int zone = (tz < 0) ? (-tz) : tz; + fprintf(cb->newlog, "%s %s %s %lu %c%04d\t%s", + sha1_to_hex(osha1), sha1_to_hex(nsha1), + email, timestamp, sign, zone, + message); + } if (cb->cmd->verbose) - printf("keep %s", data); + printf("keep %s", message); return 0; prune: if (!cb->newlog || cb->cmd->verbose) - printf("%sprune %s", cb->newlog ? "" : "would ", data); + printf("%sprune %s", cb->newlog ? "" : "would ", message); return 0; } |