summaryrefslogtreecommitdiff
path: root/reflog-walk.c
diff options
context:
space:
mode:
authorJonathan Maw <jonathan.maw@codethink.co.uk>2013-09-30 15:08:10 +0100
committerJonathan Maw <jonathan.maw@codethink.co.uk>2013-09-30 15:08:10 +0100
commit43efcf42382e87de4aa423e5e1607958ad1717d0 (patch)
tree7e19a0765b0dd6885fbdf69d3a8d0159a1b42de8 /reflog-walk.c
parent45d74c4b0fe38218b4569a90da7102cf48d616c2 (diff)
parentc7fd06b6411fb04eb4d9acd7f8822a288a50dc17 (diff)
downloadgit-43efcf42382e87de4aa423e5e1607958ad1717d0.tar.gz
Merge branch 'baserock/jonathanmaw/S9007/upgrade-git' into baserock/morphbaserock/morph
Reviewed-by: Lars Wirzenius <lars.wirzenius@codethink.co.uk> Reviewed-by: Daniel Silverstone <daniel.silverstone@codethink.co.uk>
Diffstat (limited to 'reflog-walk.c')
-rw-r--r--reflog-walk.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/reflog-walk.c b/reflog-walk.c
index 86d18843f5..b2fbdb2392 100644
--- a/reflog-walk.c
+++ b/reflog-walk.c
@@ -126,7 +126,12 @@ static void add_commit_info(struct commit *commit, void *util,
}
struct commit_reflog {
- int flag, recno;
+ int recno;
+ enum selector_type {
+ SELECTOR_NONE,
+ SELECTOR_INDEX,
+ SELECTOR_DATE
+ } selector;
struct complete_reflogs *reflogs;
};
@@ -150,6 +155,7 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
struct complete_reflogs *reflogs;
char *branch, *at = strchr(name, '@');
struct commit_reflog *commit_reflog;
+ enum selector_type selector = SELECTOR_NONE;
if (commit->object.flags & UNINTERESTING)
die ("Cannot walk reflogs for %s", name);
@@ -162,7 +168,10 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
if (*ep != '}') {
recno = -1;
timestamp = approxidate(at + 2);
+ selector = SELECTOR_DATE;
}
+ else
+ selector = SELECTOR_INDEX;
} else
recno = 0;
@@ -200,7 +209,6 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
commit_reflog = xcalloc(sizeof(struct commit_reflog), 1);
if (recno < 0) {
- commit_reflog->flag = 1;
commit_reflog->recno = get_reflog_recno_by_time(reflogs, timestamp);
if (commit_reflog->recno < 0) {
free(branch);
@@ -209,6 +217,7 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
}
} else
commit_reflog->recno = reflogs->nr - recno - 1;
+ commit_reflog->selector = selector;
commit_reflog->reflogs = reflogs;
add_commit_info(commit, commit_reflog, &info->reflogs);
@@ -247,7 +256,7 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)
void get_reflog_selector(struct strbuf *sb,
struct reflog_walk_info *reflog_info,
- enum date_mode dmode,
+ enum date_mode dmode, int force_date,
int shorten)
{
struct commit_reflog *commit_reflog = reflog_info->last_commit_reflog;
@@ -267,7 +276,8 @@ void get_reflog_selector(struct strbuf *sb,
}
strbuf_addf(sb, "%s@{", printed_ref);
- if (commit_reflog->flag || dmode) {
+ if (commit_reflog->selector == SELECTOR_DATE ||
+ (commit_reflog->selector == SELECTOR_NONE && force_date)) {
info = &commit_reflog->reflogs->items[commit_reflog->recno+1];
strbuf_addstr(sb, show_date(info->timestamp, info->tz, dmode));
} else {
@@ -308,7 +318,7 @@ const char *get_reflog_ident(struct reflog_walk_info *reflog_info)
}
void show_reflog_message(struct reflog_walk_info *reflog_info, int oneline,
- enum date_mode dmode)
+ enum date_mode dmode, int force_date)
{
if (reflog_info && reflog_info->last_commit_reflog) {
struct commit_reflog *commit_reflog = reflog_info->last_commit_reflog;
@@ -316,7 +326,7 @@ void show_reflog_message(struct reflog_walk_info *reflog_info, int oneline,
struct strbuf selector = STRBUF_INIT;
info = &commit_reflog->reflogs->items[commit_reflog->recno+1];
- get_reflog_selector(&selector, reflog_info, dmode, 0);
+ get_reflog_selector(&selector, reflog_info, dmode, force_date, 0);
if (oneline) {
printf("%s: %s", selector.buf, info->message);
}