|
4 | 4 | #include "git2/reflog.h" |
5 | 5 | #include "reflog.h" |
6 | 6 |
|
7 | | - |
| 7 | +static const char *merge_reflog_message = "commit (merge): Merge commit"; |
8 | 8 | static const char *new_ref = "refs/heads/test-reflog"; |
9 | 9 | static const char *current_master_tip = "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"; |
10 | 10 | #define commit_msg "commit: bla bla" |
@@ -448,3 +448,45 @@ void test_refs_reflog_reflog__logallrefupdates_nonbare_set_false(void) |
448 | 448 |
|
449 | 449 | assert_no_reflog_update(); |
450 | 450 | } |
| 451 | + |
| 452 | +void test_refs_reflog_reflog__show_merge_for_merge_commits(void) |
| 453 | +{ |
| 454 | + git_oid b1_oid; |
| 455 | + git_oid b2_oid; |
| 456 | + git_oid merge_commit_oid; |
| 457 | + git_commit *b1_commit; |
| 458 | + git_commit *b2_commit; |
| 459 | + git_signature *s; |
| 460 | + git_commit *parent_commits[2]; |
| 461 | + git_tree *tree; |
| 462 | + git_reflog *log; |
| 463 | + const git_reflog_entry *entry; |
| 464 | + |
| 465 | + cl_git_pass(git_signature_now(&s, "alice", "alice@example.com")); |
| 466 | + |
| 467 | + cl_git_pass(git_reference_name_to_id(&b1_oid, g_repo, "HEAD")); |
| 468 | + cl_git_pass(git_reference_name_to_id(&b2_oid, g_repo, "refs/heads/test")); |
| 469 | + |
| 470 | + cl_git_pass(git_commit_lookup(&b1_commit, g_repo, &b1_oid)); |
| 471 | + cl_git_pass(git_commit_lookup(&b2_commit, g_repo, &b2_oid)); |
| 472 | + |
| 473 | + parent_commits[0] = b1_commit; |
| 474 | + parent_commits[1] = b2_commit; |
| 475 | + |
| 476 | + cl_git_pass(git_commit_tree(&tree, b1_commit)); |
| 477 | + |
| 478 | + cl_git_pass(git_commit_create(&merge_commit_oid, |
| 479 | + g_repo, "HEAD", s, s, NULL, |
| 480 | + "Merge commit", tree, |
| 481 | + 2, (const struct git_commit **) parent_commits)); |
| 482 | + |
| 483 | + cl_git_pass(git_reflog_read(&log, g_repo, "HEAD")); |
| 484 | + entry = git_reflog_entry_byindex(log, 0); |
| 485 | + cl_assert_equal_s(merge_reflog_message, git_reflog_entry_message(entry)); |
| 486 | + |
| 487 | + git_reflog_free(log); |
| 488 | + git_tree_free(tree); |
| 489 | + git_commit_free(b1_commit); |
| 490 | + git_commit_free(b2_commit); |
| 491 | + git_signature_free(s); |
| 492 | +} |
0 commit comments