summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--reflog-walk.c12
-rw-r--r--reflog-walk.h1
-rw-r--r--revision.c19
-rwxr-xr-xt/t1414-reflog-walk.sh26
4 files changed, 55 insertions, 3 deletions
diff --git a/reflog-walk.c b/reflog-walk.c
index fbee9e0126..74ebe5148f 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)
{
diff --git a/reflog-walk.h b/reflog-walk.h
index 373388cd14..7553c448fe 100644
--- a/reflog-walk.h
+++ b/reflog-walk.h
@@ -13,6 +13,7 @@ extern void show_reflog_message(struct reflog_walk_info *info, int,
extern void get_reflog_message(struct strbuf *sb,
struct reflog_walk_info *reflog_info);
extern const char *get_reflog_ident(struct reflog_walk_info *reflog_info);
+extern timestamp_t get_reflog_timestamp(struct reflog_walk_info *reflog_info);
extern void get_reflog_selector(struct strbuf *sb,
struct reflog_walk_info *reflog_info,
const struct date_mode *dmode, int force_date,
diff --git a/revision.c b/revision.c
index 587199739a..41b4375c3c 100644
--- a/revision.c
+++ b/revision.c
@@ -2965,6 +2965,18 @@ static inline int want_ancestry(const struct rev_info *revs)
return (revs->rewrite_parents || revs->children.name);
}
+/*
+ * Return a timestamp to be used for --since/--until comparisons for this
+ * commit, based on the revision options.
+ */
+static timestamp_t comparison_date(const struct rev_info *revs,
+ struct commit *commit)
+{
+ return revs->reflog_info ?
+ get_reflog_timestamp(revs->reflog_info) :
+ commit->date;
+}
+
enum commit_action get_commit_action(struct rev_info *revs, struct commit *commit)
{
if (commit->object.flags & SHOWN)
@@ -2975,8 +2987,9 @@ enum commit_action get_commit_action(struct rev_info *revs, struct commit *commi
return commit_show;
if (commit->object.flags & UNINTERESTING)
return commit_ignore;
- if (revs->min_age != -1 && (commit->date > revs->min_age))
- return commit_ignore;
+ if (revs->min_age != -1 &&
+ comparison_date(revs, commit) > revs->min_age)
+ return commit_ignore;
if (revs->min_parents || (revs->max_parents >= 0)) {
int n = commit_list_count(commit->parents);
if ((n < revs->min_parents) ||
@@ -3130,7 +3143,7 @@ static struct commit *get_revision_1(struct rev_info *revs)
*/
if (!revs->limited) {
if (revs->max_age != -1 &&
- (commit->date < revs->max_age))
+ comparison_date(revs, commit) < revs->max_age)
continue;
if (revs->reflog_info)
diff --git a/t/t1414-reflog-walk.sh b/t/t1414-reflog-walk.sh
index eb10fefd40..feb1efd8ff 100755
--- a/t/t1414-reflog-walk.sh
+++ b/t/t1414-reflog-walk.sh
@@ -91,6 +91,32 @@ test_expect_success 'date-limiting does not interfere with other logs' '
test_cmp expect.all actual
'
+test_expect_success 'min/max age uses entry date to limit' '
+ # Flip between commits one and two so each ref update actually
+ # does something (and does not get optimized out). We know
+ # that the timestamps of those commits will be before our "min".
+
+ git update-ref -m before refs/heads/minmax one &&
+
+ test_tick &&
+ min=$test_tick &&
+ git update-ref -m min refs/heads/minmax two &&
+
+ test_tick &&
+ max=$test_tick &&
+ git update-ref -m max refs/heads/minmax one &&
+
+ test_tick &&
+ git update-ref -m after refs/heads/minmax two &&
+
+ cat >expect <<-\EOF &&
+ max
+ min
+ EOF
+ git log -g --since=$min --until=$max --format=%gs minmax >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'walk prefers reflog to ref tip' '
head=$(git rev-parse HEAD) &&
one=$(git rev-parse one) &&