By using %r<char>, one may obtain information from the reflog when using --pretty=format in conjunction with git log -g or git rev-list --walk-reflogs. The following format codes are supported: %rp, %rP: abbreviated and full old commit hash %rm: reflog message %rn, %re, %rt, %rd, etc: all the formats that work for committer and author work with the reflog printer as well. Signed-off-by: Deskin Miller <deskinm@xxxxxxxxx> --- pretty.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 38 insertions(+), 0 deletions(-) diff --git a/pretty.c b/pretty.c index 6cd9149..9303958 100644 --- a/pretty.c +++ b/pretty.c @@ -7,6 +7,7 @@ #include "mailmap.h" #include "log-tree.h" #include "color.h" +#include "reflog-walk.h" static char *user_format; @@ -544,6 +545,40 @@ static void format_decoration(struct strbuf *sb, const struct commit *commit) strbuf_addch(sb, ')'); } +static size_t format_reflog_item(struct strbuf *sb, void *util, char part, + enum date_mode dmode) +{ + struct reflog_info *reflog_info = (struct reflog_info *)util; + struct strbuf buf = STRBUF_INIT; + ssize_t ret; + + if (!util) { + return 0; + } + + switch (part) { + case 'P': + strbuf_addstr(sb, sha1_to_hex(reflog_info->osha1)); + return 2; + case 'p': /* abbreviated commit hash */ + strbuf_addstr(sb, find_unique_abbrev(reflog_info->osha1, + DEFAULT_ABBREV)); + return 2; + case 'm': + /* don't print trailing newline */ + strbuf_add(sb, reflog_info->message, + strlen(reflog_info->message) - 1); + return 2; + } + + strbuf_addf(&buf, "%s %lu %+04d", reflog_info->email, + reflog_info->timestamp, reflog_info->tz); + ret = format_person_part(sb, part, buf.buf, buf.len, dmode); + strbuf_release(&buf); + return ret; + +} + static size_t format_commit_item(struct strbuf *sb, const char *placeholder, void *context) { @@ -650,6 +685,9 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder, case 'd': format_decoration(sb, commit); return 1; + case 'r': + return format_reflog_item(sb, commit->util, placeholder[1], + c->dmode); } /* For the rest we have to parse the commit header. */ -- 1.6.2.rc0.90.g0753 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html