reflog-walk: refactor the branch@{num} formatting
We'll use the same output in an upcoming commit, so refactor its formatting (which was duplicated anyway) into a separate function. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
dd2e794a21
commit
72b103fec7
@ -241,36 +241,46 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)
|
|||||||
commit->object.flags &= ~(ADDED | SEEN | SHOWN);
|
commit->object.flags &= ~(ADDED | SEEN | SHOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_reflog_message(struct reflog_walk_info *info, int oneline,
|
void get_reflog_selector(struct strbuf *sb,
|
||||||
|
struct reflog_walk_info *reflog_info,
|
||||||
|
enum date_mode dmode)
|
||||||
|
{
|
||||||
|
struct commit_reflog *commit_reflog = reflog_info->last_commit_reflog;
|
||||||
|
struct reflog_info *info;
|
||||||
|
|
||||||
|
if (!commit_reflog)
|
||||||
|
return;
|
||||||
|
|
||||||
|
strbuf_addf(sb, "%s@{", commit_reflog->reflogs->ref);
|
||||||
|
if (commit_reflog->flag || dmode) {
|
||||||
|
info = &commit_reflog->reflogs->items[commit_reflog->recno+1];
|
||||||
|
strbuf_addstr(sb, show_date(info->timestamp, info->tz, dmode));
|
||||||
|
} else {
|
||||||
|
strbuf_addf(sb, "%d", commit_reflog->reflogs->nr
|
||||||
|
- 2 - commit_reflog->recno);
|
||||||
|
}
|
||||||
|
|
||||||
|
strbuf_addch(sb, '}');
|
||||||
|
}
|
||||||
|
|
||||||
|
void show_reflog_message(struct reflog_walk_info *reflog_info, int oneline,
|
||||||
enum date_mode dmode)
|
enum date_mode dmode)
|
||||||
{
|
{
|
||||||
if (info && info->last_commit_reflog) {
|
if (reflog_info && reflog_info->last_commit_reflog) {
|
||||||
struct commit_reflog *commit_reflog = info->last_commit_reflog;
|
struct commit_reflog *commit_reflog = reflog_info->last_commit_reflog;
|
||||||
struct reflog_info *info;
|
struct reflog_info *info;
|
||||||
|
struct strbuf selector = STRBUF_INIT;
|
||||||
|
|
||||||
info = &commit_reflog->reflogs->items[commit_reflog->recno+1];
|
info = &commit_reflog->reflogs->items[commit_reflog->recno+1];
|
||||||
|
get_reflog_selector(&selector, reflog_info, dmode);
|
||||||
if (oneline) {
|
if (oneline) {
|
||||||
printf("%s@{", commit_reflog->reflogs->ref);
|
printf("%s: %s", selector.buf, info->message);
|
||||||
if (commit_reflog->flag || dmode)
|
|
||||||
printf("%s", show_date(info->timestamp,
|
|
||||||
info->tz,
|
|
||||||
dmode));
|
|
||||||
else
|
|
||||||
printf("%d", commit_reflog->reflogs->nr
|
|
||||||
- 2 - commit_reflog->recno);
|
|
||||||
printf("}: %s", info->message);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("Reflog: %s@{", commit_reflog->reflogs->ref);
|
printf("Reflog: %s (%s)\nReflog message: %s",
|
||||||
if (commit_reflog->flag || dmode)
|
selector.buf, info->email, info->message);
|
||||||
printf("%s", show_date(info->timestamp,
|
|
||||||
info->tz,
|
|
||||||
dmode));
|
|
||||||
else
|
|
||||||
printf("%d", commit_reflog->reflogs->nr
|
|
||||||
- 2 - commit_reflog->recno);
|
|
||||||
printf("} (%s)\nReflog message: %s",
|
|
||||||
info->email, info->message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
strbuf_release(&selector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user