diff options
| author | Junio C Hamano <gitster@pobox.com> | 2024-09-16 14:22:53 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-09-16 14:22:54 -0700 |
| commit | 6e2a18cb049e35e4a13847c4b720c9d5f1dce5b9 (patch) | |
| tree | 9dc645e657a95dbd805e5869a0b99a27ff357399 /t | |
| parent | Merge branch 'cp/unit-test-reftable-stack' (diff) | |
| parent | apply: support --ours, --theirs, and --union for three-way merges (diff) | |
| download | git-6e2a18cb049e35e4a13847c4b720c9d5f1dce5b9.tar.gz git-6e2a18cb049e35e4a13847c4b720c9d5f1dce5b9.zip | |
Merge branch 'ah/apply-3way-ours'
"git apply --3way" learned to take "--ours" and other options.
* ah/apply-3way-ours:
apply: support --ours, --theirs, and --union for three-way merges
Diffstat (limited to 't')
| -rwxr-xr-x | t/t4108-apply-threeway.sh | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/t/t4108-apply-threeway.sh b/t/t4108-apply-threeway.sh index 3211e1e65f..c6302163d8 100755 --- a/t/t4108-apply-threeway.sh +++ b/t/t4108-apply-threeway.sh @@ -82,6 +82,46 @@ test_expect_success 'apply with --3way with merge.conflictStyle = diff3' ' test_apply_with_3way ' +test_apply_with_3way_favoritism () { + apply_arg=$1 + merge_arg=$2 + + # Merging side should be similar to applying this patch + git diff ...side >P.diff && + + # The corresponding conflicted merge + git reset --hard && + git checkout main^0 && + git merge --no-commit $merge_arg side && + git ls-files -s >expect.ls && + print_sanitized_conflicted_diff >expect.diff && + + # should apply successfully + git reset --hard && + git checkout main^0 && + git apply --index --3way $apply_arg P.diff && + git ls-files -s >actual.ls && + print_sanitized_conflicted_diff >actual.diff && + + # The result should resemble the corresponding merge + test_cmp expect.ls actual.ls && + test_cmp expect.diff actual.diff +} + +test_expect_success 'apply with --3way --ours' ' + test_apply_with_3way_favoritism --ours -Xours +' + +test_expect_success 'apply with --3way --theirs' ' + test_apply_with_3way_favoritism --theirs -Xtheirs +' + +test_expect_success 'apply with --3way --union' ' + echo "* merge=union" >.gitattributes && + test_apply_with_3way_favoritism --union && + rm .gitattributes +' + test_expect_success 'apply with --3way with rerere enabled' ' test_config rerere.enabled true && |
