diff options
author | Junio C Hamano <gitster@pobox.com> | 2024-12-15 17:54:30 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-12-15 17:54:30 -0800 |
commit | 4007617fda480f18a879ee733a5bc6540e29352c (patch) | |
tree | 8e6ab2b2a7cb02bb0bf9105c72de9f03d7410f5c | |
parent | 67761be92776fec85c9638ba0fc357bc9bc0ac6d (diff) | |
parent | 0ff919e87a08b7ab81507917ca55eb613296d043 (diff) |
Merge branch 'ps/commit-with-message-syntax-fix'
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
-rw-r--r-- | object-name.c | 4 | ||||
-rwxr-xr-x | t/t1500-rev-parse.sh | 15 |
2 files changed, 17 insertions, 2 deletions
diff --git a/object-name.c b/object-name.c index 72298055b5..a563635a8c 100644 --- a/object-name.c +++ b/object-name.c @@ -1401,7 +1401,7 @@ static int get_oid_oneline(struct repository *r, const char *prefix, struct object_id *oid, const struct commit_list *list) { - struct commit_list *copy = NULL; + struct commit_list *copy = NULL, **copy_tail = © const struct commit_list *l; int found = 0; int negative = 0; @@ -1423,7 +1423,7 @@ static int get_oid_oneline(struct repository *r, for (l = list; l; l = l->next) { l->item->object.flags |= ONELINE_SEEN; - commit_list_insert(l->item, ©); + copy_tail = &commit_list_insert(l->item, copy_tail)->next; } while (copy) { const char *p, *buf; diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh index bf2a90df94..58a4583088 100755 --- a/t/t1500-rev-parse.sh +++ b/t/t1500-rev-parse.sh @@ -309,4 +309,19 @@ test_expect_success '--short= truncates to the actual hash length' ' test_cmp expect actual ' +test_expect_success ':/ and HEAD^{/} favor more recent matching commits' ' + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + test_commit common-old && + test_commit --no-tag common-new && + git rev-parse HEAD >expect && + git rev-parse :/common >actual && + test_cmp expect actual && + git rev-parse HEAD^{/common} >actual && + test_cmp expect actual + ) +' + test_done |