Skip to content
Open
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
33 changes: 33 additions & 0 deletions t/t6010-merge-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,37 @@ test_expect_success 'merge-base --octopus --all for complex tree' '
test_cmp expected actual
'

# These reuse the E---D---C---B---A history plus the G and H merges set up
# in "set up G and H" above: E is an ancestor of A, while G and H are on
# diverged branches.
test_expect_success '--is-ancestor with an ancestor and a descendant' '
git merge-base --is-ancestor $E $A &&
test_expect_code 1 git merge-base --is-ancestor $A $E
'

test_expect_success '--is-ancestor treats a commit as its own ancestor' '
git merge-base --is-ancestor $A $A
'

test_expect_success '--is-ancestor with diverged commits' '
test_expect_code 1 git merge-base --is-ancestor $G $H &&
test_expect_code 1 git merge-base --is-ancestor $H $G
'

test_expect_success '--is-ancestor exits 128 on a bad commit' '
test_expect_code 128 git merge-base --is-ancestor $A no-such-commit &&
test_expect_code 128 git merge-base --is-ancestor no-such-commit $A
'

test_expect_success '--is-ancestor requires exactly two commits' '
test_expect_code 129 git merge-base --is-ancestor &&
test_expect_code 129 git merge-base --is-ancestor $A &&
test_expect_code 128 git merge-base --is-ancestor $E $A $B
'

test_expect_success '--is-ancestor and --all cannot be used together' '
test_expect_code 128 git merge-base --is-ancestor --all $E $A 2>err &&
test_grep "options .--is-ancestor. and .--all. cannot be used together" err
'

test_done
Loading