Fix log -g this@{upstream}
It showed the correct objects but walked a wrong reflog. Again, tests are from Jeff King. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Jan 26, 2010 at 13:48 UTC
105e47339794ec2c862338d7a25df77b7d72385e
2 files changed
+43
-4
revision.c
+14
-4
@@ -134,10 +134,20 @@ static void add_pending_object_with_mode(struct rev_info *revs, struct object *o
134
{
135
if (revs->no_walk && (obj->flags & UNINTERESTING))
136
revs->no_walk = 0;
137
- if (revs->reflog_info && obj->type == OBJ_COMMIT &&
138
- add_reflog_for_walk(revs->reflog_info,
139
- (struct commit *)obj, name))
140
- return;
137
+ if (revs->reflog_info && obj->type == OBJ_COMMIT) {
138
+ struct strbuf buf = STRBUF_INIT;
139
+ int len = interpret_branch_name(name, &buf);
140
+ int st;
141
+
142
+ if (0 < len && name[len] && buf.len)
143
+ strbuf_addstr(&buf, name + len);
144
+ st = add_reflog_for_walk(revs->reflog_info,
145
+ (struct commit *)obj,
146
+ buf.buf[0] ? buf.buf: name);
147
+ strbuf_release(&buf);
148
+ if (st)
149
+ return;
150
+ }
151
add_object_array_with_mode(obj, name, &revs->pending, mode);
152
}
153
t/t1507-rev-parse-upstream.sh
+29
@@ -107,4 +107,33 @@ test_expect_success 'checkout other@{u}' '
107
test_cmp expect actual
108
'
109
110
+cat >expect <<EOF
111
+commit 8f489d01d0cc65c3b0f09504ec50b5ed02a70bd5
112
+Reflog: master@{0} (C O Mitter <committer@example.com>)
113
+Reflog message: branch: Created from HEAD
114
+Author: A U Thor <author@example.com>
115
+Date: Thu Apr 7 15:15:13 2005 -0700
116
+
117
+ 3
118
+EOF
119
+test_expect_success 'log -g other@{u}' '
120
+ git log -1 -g other@{u} >actual &&
121
+ test_cmp expect actual
122
+'
123
+
124
+cat >expect <<EOF
125
+commit 8f489d01d0cc65c3b0f09504ec50b5ed02a70bd5
126
+Reflog: master@{Thu Apr 7 15:17:13 2005 -0700} (C O Mitter <committer@example.com>)
127
+Reflog message: branch: Created from HEAD
128
+Author: A U Thor <author@example.com>
129
+Date: Thu Apr 7 15:15:13 2005 -0700
130
+
131
+ 3
132
+EOF
133
+
134
+test_expect_success 'log -g other@{u}@{now}' '
135
+ git log -1 -g other@{u}@{now} >actual &&
136
+ test_cmp expect actual
137
+'
138
+
139
test_done