Skip to content

Commit

Permalink
Add a test for checking whether gitattributes is honored by checkout.
Browse files Browse the repository at this point in the history
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 <gitster@pobox.com>
  • Loading branch information
Kristian Amlie authored and Junio C Hamano committed Mar 20, 2009
1 parent 06f33c1 commit b997045
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions t/t0020-crlf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,37 @@ test_expect_success 'in-tree .gitattributes (4)' '
}
'

test_expect_success 'checkout with existing .gitattributes' '
git config core.autocrlf true &&
git config --unset core.safecrlf &&
echo ".file2 -crlfQ" | q_to_cr >> .gitattributes &&
git add .gitattributes &&
git commit -m initial &&
echo ".file -crlfQ" | q_to_cr >> .gitattributes &&
echo "contents" > .file &&
git add .gitattributes .file &&
git commit -m second &&
git checkout master~1 &&
git checkout master &&
test "$(git diff-files --raw)" = ""
'

test_expect_success 'checkout when deleting .gitattributes' '
git rm .gitattributes &&
echo "contentsQ" | q_to_cr > .file2 &&
git add .file2 &&
git commit -m third
git checkout master~1 &&
git checkout master &&
remove_cr .file2 >/dev/null
'

test_expect_success 'invalid .gitattributes (must not crash)' '
echo "three +crlf" >>.gitattributes &&
Expand Down

0 comments on commit b997045

Please sign in to comment.