mirror of
https://github.com/git/git.git
synced 2024-12-11 10:54:21 +08:00
9e5da3d055
Commit 9472935d81
(add: introduce "--renormalize", 2017-11-16) taught
git-add to pass HASH_RENORMALIZE to add_to_index(), which then passes
the flag along to index_path(). However, the flags taken by
add_to_index() and the ones taken by index_path() are distinct
namespaces. We cannot take HASH_* flags in add_to_index(), because they
overlap with the ADD_CACHE_* flags we already take (in this case,
HASH_RENORMALIZE conflicts with ADD_CACHE_IGNORE_ERRORS).
We can solve this by adding a new ADD_CACHE_RENORMALIZE flag, and using
it to set HASH_RENORMALIZE within add_to_index(). In order to make it
clear that these two flags come from distinct sets, let's also change
the name "newflags" in the function to "hash_flags".
Reported-by: Dmitriy Smirnov <dmitriy.smirnov@jetbrains.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
40 lines
981 B
Bash
Executable File
40 lines
981 B
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='CRLF renormalization'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success setup '
|
|
git config core.autocrlf false &&
|
|
printf "LINEONE\nLINETWO\nLINETHREE\n" >LF.txt &&
|
|
printf "LINEONE\r\nLINETWO\r\nLINETHREE\r\n" >CRLF.txt &&
|
|
printf "LINEONE\r\nLINETWO\nLINETHREE\n" >CRLF_mix_LF.txt &&
|
|
git add . &&
|
|
git commit -m initial
|
|
'
|
|
|
|
test_expect_success 'renormalize CRLF in repo' '
|
|
echo "*.txt text=auto" >.gitattributes &&
|
|
git add --renormalize "*.txt" &&
|
|
cat >expect <<-\EOF &&
|
|
i/lf w/crlf attr/text=auto CRLF.txt
|
|
i/lf w/lf attr/text=auto LF.txt
|
|
i/lf w/mixed attr/text=auto CRLF_mix_LF.txt
|
|
EOF
|
|
git ls-files --eol |
|
|
sed -e "s/ / /g" -e "s/ */ /g" |
|
|
sort >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success 'ignore-errors not mistaken for renormalize' '
|
|
git reset --hard &&
|
|
echo "*.txt text=auto" >.gitattributes &&
|
|
git ls-files --eol >expect &&
|
|
git add --ignore-errors "*.txt" &&
|
|
git ls-files --eol >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_done
|