Skip to content

Commit fe48efb

Browse files
newrengitster
authored andcommitted
t6038: make tests fail for the right reason
t6038 had a pair of tests that were expected to fail, but weren't failing for the expected reason. Both were meant to do a merge that could be done cleanly after renormalization, but were supposed to fail for lack of renormalization. Unfortunately, both tests had staged changes, and checkout -m would abort due to the presence of those staged changes before even attempting a merge. Fix this first issue by utilizing git-restore instead of git-checkout, so that the index is left alone and just the working directory gets the changes we want. However, there is a second issue with these tests. Technically, they just wanted to verify that after renormalization, no conflicts would be present. This could have been checked for by grepping for a lack of conflict markers, but the test instead tried to compare the working directory files to an expected result. Unfortunately, the setting of "text=auto" without setting core.eol to any value meant that the content of the file (in particular, the line endings) would be platform-dependent and the tests could only pass on some platforms. Replace the existing comparison with a call to 'git diff --no-index --ignore-cr-at-eol' to verify that the contents, other than possible carriage returns in the file, match the expected results and in particular that the file has no conflicts from the checkout -m operation. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 85b4e0a commit fe48efb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

t/t6038-merge-text-auto.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ test_expect_failure 'checkout -m after setting text=auto' '
168168
git rm -fr . &&
169169
rm -f .gitattributes &&
170170
git reset --hard initial &&
171-
git checkout a -- . &&
171+
git restore --source=a -- . &&
172172
git checkout -m b &&
173-
compare_files expected file
173+
git diff --no-index --ignore-cr-at-eol expected file
174174
'
175175

176176
test_expect_failure 'checkout -m addition of text=auto' '
@@ -183,9 +183,9 @@ test_expect_failure 'checkout -m addition of text=auto' '
183183
git rm -fr . &&
184184
rm -f .gitattributes file &&
185185
git reset --hard initial &&
186-
git checkout b -- . &&
186+
git restore --source=b -- . &&
187187
git checkout -m a &&
188-
compare_files expected file
188+
git diff --no-index --ignore-cr-at-eol expected file
189189
'
190190

191191
test_expect_failure 'cherry-pick patch from after text=auto was added' '

0 commit comments

Comments
 (0)