Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Prefer younger merge bases over older ones. #1681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 25, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/commit_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ git_commit_list *git_commit_list_insert_by_date(git_commit_list_node *item, git_
git_commit_list *p;

while ((p = *pp) != NULL) {
if (git_commit_list_time_cmp(p->item, item) < 0)
if (git_commit_list_time_cmp(p->item, item) > 0)
break;

pp = &p->next;
Expand Down
12 changes: 12 additions & 0 deletions tests-clar/revwalk/mergebase.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ void test_revwalk_mergebase__no_common_ancestor_returns_ENOTFOUND(void)
cl_assert_equal_sz(4, behind);
}

void test_revwalk_mergebase__prefer_youngest_merge_base(void)
{
git_oid result, one, two, expected;

cl_git_pass(git_oid_fromstr(&one, "a4a7dce85cf63874e984719f4fdd239f5145052f "));
cl_git_pass(git_oid_fromstr(&two, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"));
cl_git_pass(git_oid_fromstr(&expected, "c47800c7266a2be04c571c04d5a6614691ea99bd"));

cl_git_pass(git_merge_base(&result, _repo, &one, &two));
cl_assert(git_oid_cmp(&result, &expected) == 0);
}

void test_revwalk_mergebase__no_off_by_one_missing(void)
{
git_oid result, one, two;
Expand Down