Skip to content

Commit 33e9f1c

Browse files
Samuel Lijingitster
authored andcommitted
t7501: add merge conflict tests for dry run
The behavior of git commit when doing a dry run changes if there are unfixed/fixed merge conflits, but the test suite currently only asserts that `git commit --dry-run` succeeds when all merge conflicts are fixed. Add tests to document the behavior of all flags which imply a dry run when (1) there is at least one unfixed merge conflict and (2) when all merge conflicts are all fixed. Signed-off-by: Samuel Lijin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e6986ab commit 33e9f1c

File tree

1 file changed

+40
-5
lines changed

1 file changed

+40
-5
lines changed

t/t7501-commit.sh

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,8 @@ test_expect_success '--only works on to-be-born branch' '
664664
test_cmp expected actual
665665
'
666666

667-
test_expect_success '--dry-run with conflicts fixed from a merge' '
667+
# set up env for tests of --dry-run given fixed/unfixed merge conflicts
668+
test_expect_success 'setup env with unfixed merge conflicts' '
668669
# setup two branches with conflicting information
669670
# in the same file, resolve the conflict,
670671
# call commit with --dry-run
@@ -677,11 +678,45 @@ test_expect_success '--dry-run with conflicts fixed from a merge' '
677678
git checkout -b branch-2 HEAD^1 &&
678679
echo "commit-2-state" >test-file &&
679680
git commit -m "commit 2" -i test-file &&
680-
! $(git merge --no-commit commit-1) &&
681-
echo "commit-2-state" >test-file &&
681+
test_expect_code 1 git merge --no-commit commit-1
682+
'
683+
684+
test_expect_success '--dry-run with unfixed merge conflicts' '
685+
test_expect_code 1 git commit --dry-run
686+
'
687+
688+
test_expect_success '--short with unfixed merge conflicts' '
689+
test_expect_code 1 git commit --short
690+
'
691+
692+
test_expect_success '--porcelain with unfixed merge conflicts' '
693+
test_expect_code 1 git commit --porcelain
694+
'
695+
696+
test_expect_success '--long with unfixed merge conflicts' '
697+
test_expect_code 1 git commit --long
698+
'
699+
700+
test_expect_success '--dry-run with conflicts fixed from a merge' '
701+
echo "merge-conflicts-fixed" >test-file &&
682702
git add test-file &&
683-
git commit --dry-run &&
684-
git commit -m "conflicts fixed from merge."
703+
git commit --dry-run
704+
'
705+
706+
test_expect_failure '--short with conflicts fixed from a merge' '
707+
git commit --short
708+
'
709+
710+
test_expect_failure '--porcelain with conflicts fixed from a merge' '
711+
git commit --porcelain
712+
'
713+
714+
test_expect_success '--long with conflicts fixed from a merge' '
715+
git commit --long
716+
'
717+
718+
test_expect_success '--message with conflicts fixed from a merge' '
719+
git commit --message "conflicts fixed from merge."
685720
'
686721

687722
test_done

0 commit comments

Comments
 (0)