mirror of
https://github.com/git/git.git
synced 2024-11-14 13:13:01 +01:00
a31d066524
The tests using the fuzz_conflict helper function (tests 5-6)
fail on cygwin in the same way they used to on MinGW, prior
to commit ca02ad3
. The solution is also the same; passing the
-b (--binary) option to sed, using the SED_OPTIONS variable.
We introduce a new prerequisite SED_STRIPS_CR to use in the
conditional initialisation of SED_OPTIONS, rather than MINGW.
The new prerequisite is set in test-lib.sh for both MinGW and
Cygwin.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Acked-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
191 lines
3.8 KiB
Bash
Executable file
191 lines
3.8 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='CRLF merge conflict across text=auto change
|
|
|
|
* [master] remove .gitattributes
|
|
! [side] add line from b
|
|
--
|
|
+ [side] add line from b
|
|
* [master] remove .gitattributes
|
|
* [master^] add line from a
|
|
* [master~2] normalize file
|
|
*+ [side^] Initial
|
|
'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_have_prereq SED_STRIPS_CR && SED_OPTIONS=-b
|
|
|
|
test_expect_success setup '
|
|
git config core.autocrlf false &&
|
|
|
|
echo first line | append_cr >file &&
|
|
echo first line >control_file &&
|
|
echo only line >inert_file &&
|
|
|
|
git add file control_file inert_file &&
|
|
test_tick &&
|
|
git commit -m "Initial" &&
|
|
git tag initial &&
|
|
git branch side &&
|
|
|
|
echo "* text=auto" >.gitattributes &&
|
|
touch file &&
|
|
git add .gitattributes file &&
|
|
test_tick &&
|
|
git commit -m "normalize file" &&
|
|
|
|
echo same line | append_cr >>file &&
|
|
echo same line >>control_file &&
|
|
git add file control_file &&
|
|
test_tick &&
|
|
git commit -m "add line from a" &&
|
|
git tag a &&
|
|
|
|
git rm .gitattributes &&
|
|
rm file &&
|
|
git checkout file &&
|
|
test_tick &&
|
|
git commit -m "remove .gitattributes" &&
|
|
git tag c &&
|
|
|
|
git checkout side &&
|
|
echo same line | append_cr >>file &&
|
|
echo same line >>control_file &&
|
|
git add file control_file &&
|
|
test_tick &&
|
|
git commit -m "add line from b" &&
|
|
git tag b &&
|
|
|
|
git checkout master
|
|
'
|
|
|
|
test_expect_success 'set up fuzz_conflict() helper' '
|
|
fuzz_conflict() {
|
|
sed $SED_OPTIONS -e "s/^\([<>=]......\) .*/\1/" "$@"
|
|
}
|
|
'
|
|
|
|
test_expect_success 'Merge after setting text=auto' '
|
|
cat <<-\EOF >expected &&
|
|
first line
|
|
same line
|
|
EOF
|
|
|
|
git config merge.renormalize true &&
|
|
git rm -fr . &&
|
|
rm -f .gitattributes &&
|
|
git reset --hard a &&
|
|
git merge b &&
|
|
test_cmp expected file
|
|
'
|
|
|
|
test_expect_success 'Merge addition of text=auto' '
|
|
cat <<-\EOF >expected &&
|
|
first line
|
|
same line
|
|
EOF
|
|
|
|
git config merge.renormalize true &&
|
|
git rm -fr . &&
|
|
rm -f .gitattributes &&
|
|
git reset --hard b &&
|
|
git merge a &&
|
|
test_cmp expected file
|
|
'
|
|
|
|
test_expect_success 'Detect CRLF/LF conflict after setting text=auto' '
|
|
q_to_cr <<-\EOF >expected &&
|
|
<<<<<<<
|
|
first line
|
|
same line
|
|
=======
|
|
first lineQ
|
|
same lineQ
|
|
>>>>>>>
|
|
EOF
|
|
|
|
git config merge.renormalize false &&
|
|
rm -f .gitattributes &&
|
|
git reset --hard a &&
|
|
test_must_fail git merge b &&
|
|
fuzz_conflict file >file.fuzzy &&
|
|
test_cmp expected file.fuzzy
|
|
'
|
|
|
|
test_expect_success 'Detect LF/CRLF conflict from addition of text=auto' '
|
|
q_to_cr <<-\EOF >expected &&
|
|
<<<<<<<
|
|
first lineQ
|
|
same lineQ
|
|
=======
|
|
first line
|
|
same line
|
|
>>>>>>>
|
|
EOF
|
|
|
|
git config merge.renormalize false &&
|
|
rm -f .gitattributes &&
|
|
git reset --hard b &&
|
|
test_must_fail git merge a &&
|
|
fuzz_conflict file >file.fuzzy &&
|
|
test_cmp expected file.fuzzy
|
|
'
|
|
|
|
test_expect_failure 'checkout -m after setting text=auto' '
|
|
cat <<-\EOF >expected &&
|
|
first line
|
|
same line
|
|
EOF
|
|
|
|
git config merge.renormalize true &&
|
|
git rm -fr . &&
|
|
rm -f .gitattributes &&
|
|
git reset --hard initial &&
|
|
git checkout a -- . &&
|
|
git checkout -m b &&
|
|
test_cmp expected file
|
|
'
|
|
|
|
test_expect_failure 'checkout -m addition of text=auto' '
|
|
cat <<-\EOF >expected &&
|
|
first line
|
|
same line
|
|
EOF
|
|
|
|
git config merge.renormalize true &&
|
|
git rm -fr . &&
|
|
rm -f .gitattributes file &&
|
|
git reset --hard initial &&
|
|
git checkout b -- . &&
|
|
git checkout -m a &&
|
|
test_cmp expected file
|
|
'
|
|
|
|
test_expect_failure 'cherry-pick patch from after text=auto was added' '
|
|
append_cr <<-\EOF >expected &&
|
|
first line
|
|
same line
|
|
EOF
|
|
|
|
git config merge.renormalize true &&
|
|
git rm -fr . &&
|
|
git reset --hard b &&
|
|
test_must_fail git cherry-pick a >err 2>&1 &&
|
|
grep "[Nn]othing added" err &&
|
|
test_cmp expected file
|
|
'
|
|
|
|
test_expect_success 'Test delete/normalize conflict' '
|
|
git checkout -f side &&
|
|
git rm -fr . &&
|
|
rm -f .gitattributes &&
|
|
git reset --hard initial &&
|
|
git rm file &&
|
|
git commit -m "remove file" &&
|
|
git checkout master &&
|
|
git reset --hard a^ &&
|
|
git merge side
|
|
'
|
|
|
|
test_done
|