Skip to content

Commit 518ec69

Browse files
committed
Merge branch 'ps/commit-with-message-syntax-fix' into jch
The syntax ":/<text>" to name the latest commit with the matching text was broken with a recent change, which has been corrected. * ps/commit-with-message-syntax-fix: object-name: fix reversed ordering with ":/<text>" revisions
2 parents d739167 + 0ff919e commit 518ec69

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

object-name.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,7 @@ static int get_oid_oneline(struct repository *r,
14021402
const char *prefix, struct object_id *oid,
14031403
const struct commit_list *list)
14041404
{
1405-
struct commit_list *copy = NULL;
1405+
struct commit_list *copy = NULL, **copy_tail = &copy;
14061406
const struct commit_list *l;
14071407
int found = 0;
14081408
int negative = 0;
@@ -1424,7 +1424,7 @@ static int get_oid_oneline(struct repository *r,
14241424

14251425
for (l = list; l; l = l->next) {
14261426
l->item->object.flags |= ONELINE_SEEN;
1427-
commit_list_insert(l->item, &copy);
1427+
copy_tail = &commit_list_insert(l->item, copy_tail)->next;
14281428
}
14291429
while (copy) {
14301430
const char *p, *buf;

t/t1500-rev-parse.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,4 +309,19 @@ test_expect_success '--short= truncates to the actual hash length' '
309309
test_cmp expect actual
310310
'
311311

312+
test_expect_success ':/ and HEAD^{/} favor more recent matching commits' '
313+
test_when_finished "rm -rf repo" &&
314+
git init repo &&
315+
(
316+
cd repo &&
317+
test_commit common-old &&
318+
test_commit --no-tag common-new &&
319+
git rev-parse HEAD >expect &&
320+
git rev-parse :/common >actual &&
321+
test_cmp expect actual &&
322+
git rev-parse HEAD^{/common} >actual &&
323+
test_cmp expect actual
324+
)
325+
'
326+
312327
test_done

0 commit comments

Comments
 (0)