summaryrefslogtreecommitdiff
path: root/reflog-walk.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-07-07 09:16:21 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-07-09 17:00:48 (GMT)
commitde239446b69f3b453050af8091e07aa5433421cc (patch)
tree0712033a461f9d2084f6bc2eec2635ddcab6d4ef /reflog-walk.c
parentd08565bf2dd78aa34c68c94f1931539c1c8c5322 (diff)
downloadgit-de239446b69f3b453050af8091e07aa5433421cc.zip
git-de239446b69f3b453050af8091e07aa5433421cc.tar.gz
git-de239446b69f3b453050af8091e07aa5433421cc.tar.bz2
reflog-walk: apply --since/--until to reflog dates
When doing a reflog walk, we use the commit's date to do any date limiting. In earlier versions of Git, this could lead to nonsense results, since a skipped commit would truncate the traversal. So a sequence like: git commit ... git checkout week-old-branch git checkout - git log -g --since=1.day.ago would stop at the week-old-branch, even though the "git commit" entry further back is still interesting. As of the prior commit, which uses a parent-less traversal of the reflog, you get the whole reflog minus any commits whose dates do not match the specified options. This is arguably useful, as you could scan the reflogs for commits that originated in a certain range. But more likely a user doing a reflog walk wants to limit based on the reflog entries themselves. You can simulate --until with: git log -g @{1.day.ago} but there's no way to ask Git to traverse only back to a certain date. E.g.: # show me reflog entries from the past day git log -g --since=1.day.ago This patch teaches the revision machinery to prefer the reflog entry dates to the commit dates when doing a reflog walk. Technically this is a change in behavior that affects plumbing, but the previous behavior was so buggy that it's unlikely anyone was relying on it. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'reflog-walk.c')
-rw-r--r--reflog-walk.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/reflog-walk.c b/reflog-walk.c
index fbee9e0..74ebe51 100644
--- a/reflog-walk.c
+++ b/reflog-walk.c
@@ -264,6 +264,18 @@ const char *get_reflog_ident(struct reflog_walk_info *reflog_info)
return info->email;
}
+timestamp_t get_reflog_timestamp(struct reflog_walk_info *reflog_info)
+{
+ struct commit_reflog *commit_reflog = reflog_info->last_commit_reflog;
+ struct reflog_info *info;
+
+ if (!commit_reflog)
+ return 0;
+
+ info = &commit_reflog->reflogs->items[commit_reflog->recno+1];
+ return info->timestamp;
+}
+
void show_reflog_message(struct reflog_walk_info *reflog_info, int oneline,
const struct date_mode *dmode, int force_date)
{