<commit_before>#!/bin/sh

test_description='git merge

Testing a custom strategy.'

. ./test-lib.sh

cat >git-merge-theirs <<EOF
#!$SHELL_PATH
eval git read-tree --reset -u \\\$\$#
EOF
chmod +x git-merge-theirs
PATH=.:$PATH
export PATH

test_expect_success 'setup' '
	echo c0 >c0.c &&
	git add c0.c &&
	git commit -m c0 &&
	git tag c0 &&
	echo c1 >c1.c &&
	git add c1.c &&
	git commit -m c1 &&
	git tag c1 &&
	git reset --hard c0 &&
	echo c1c1 >c1.c &&
	echo c2 >c2.c &&
	git add c1.c c2.c &&
	git commit -m c2 &&
	git tag c2
'

test_expect_success 'merge c2 with a custom strategy' '
	git reset --hard c1 &&
	git merge -s theirs c2 &&
	test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" &&
	test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" &&
	test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" &&
	test "$(git rev-parse c2^{tree})" = "$(git rev-parse HEAD^{tree})" &&
	git diff --exit-code &&
	git diff --exit-code c2 HEAD &&
	git diff --exit-code c2 &&
	test -f c0.c &&
	grep c1c1 c1.c &&
	test -f c2.c
'

test_done<commit_msg>t7606 (merge-theirs): modernize style<commit_after>#!/bin/sh

test_description="git merge

Testing a custom strategy.

*   (HEAD, master) Merge commit 'c2'
|\
| * (tag: c2) c2
* | (tag: c1) c1
|/
* (tag: c0) c0
"

. ./test-lib.sh

test_expect_success 'set up custom strategy' '
	cat >git-merge-theirs <<-EOF &&
	#!$SHELL_PATH
	eval git read-tree --reset -u \\\$\$#
	EOF

	chmod +x git-merge-theirs &&
	PATH=.:$PATH &&
	export PATH
'

test_expect_success 'setup' '
	test_commit c0 c0.c &&
	test_commit c1 c1.c &&
	git reset --keep c0 &&
	echo c1c1 >c1.c &&
	git add c1.c &&
	test_commit c2 c2.c
'

test_expect_success 'merge c2 with a custom strategy' '
	git reset --hard c1 &&

	git rev-parse c1 >head.old &&
	git rev-parse c2 >second-parent.expected &&
	git rev-parse c2^{tree} >tree.expected &&
	git merge -s theirs c2 &&

	git rev-parse HEAD >head &&
	git rev-parse HEAD^1 >first-parent &&
	git rev-parse HEAD^2 >second-parent &&
	git rev-parse HEAD^{tree} >tree &&
	git update-index --refresh &&
	git diff --exit-code &&
	git diff --exit-code c2 HEAD &&
	git diff --exit-code c2 &&

	! test_cmp head.old head &&
	test_cmp head.old first-parent &&
	test_cmp second-parent.expected second-parent &&
	test_cmp tree.expected tree &&
	test -f c0.c &&
	grep c1c1 c1.c &&
	test -f c2.c
'

test_done
{'fraction_non_alphanumeric': 0.16852010265183917, 'fraction_numerical': 0.03122326775021386, 'mean_word_length': 3.060763888888889, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1170303', 'n_tokens_mistral': 993, 'n_tokens_neox': 962, 'n_words': 286}