Skip to content

Commit b997045

Browse files
Kristian Amliegitster
authored andcommitted
Add a test for checking whether gitattributes is honored by checkout.
The original bug will not honor new entries in gitattributes if they are changed in the same checkout as the files they affect. It will also keep using .gitattributes, even if it is deleted in the same commit as the files it affects. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 06f33c1 commit b997045

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

t/t0020-crlf.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,37 @@ test_expect_success 'in-tree .gitattributes (4)' '
429429
}
430430
'
431431

432+
test_expect_success 'checkout with existing .gitattributes' '
433+
434+
git config core.autocrlf true &&
435+
git config --unset core.safecrlf &&
436+
echo ".file2 -crlfQ" | q_to_cr >> .gitattributes &&
437+
git add .gitattributes &&
438+
git commit -m initial &&
439+
echo ".file -crlfQ" | q_to_cr >> .gitattributes &&
440+
echo "contents" > .file &&
441+
git add .gitattributes .file &&
442+
git commit -m second &&
443+
444+
git checkout master~1 &&
445+
git checkout master &&
446+
test "$(git diff-files --raw)" = ""
447+
448+
'
449+
450+
test_expect_success 'checkout when deleting .gitattributes' '
451+
452+
git rm .gitattributes &&
453+
echo "contentsQ" | q_to_cr > .file2 &&
454+
git add .file2 &&
455+
git commit -m third
456+
457+
git checkout master~1 &&
458+
git checkout master &&
459+
remove_cr .file2 >/dev/null
460+
461+
'
462+
432463
test_expect_success 'invalid .gitattributes (must not crash)' '
433464
434465
echo "three +crlf" >>.gitattributes &&

0 commit comments

Comments
 (0)