Fix a test failure (t9500-*.sh) on cygwin

On filesystems where it is appropriate to set core.filemode
to false, test 29 ("commitdiff(0): mode change") fails when
git-commit does not notice a file (execute) permission change.

A fix requires noting the new file execute permission in the
index with a "git update-index --chmod=+x", prior to the commit.
Add a function (note_chmod) which implements this idea, and
insert a call in each test that modifies the x permission.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ramsay Jones 2007-09-11 19:16:51 +01:00 committed by Junio C Hamano
parent 05cc2ffc57
commit 060fe57184

View File

@ -58,6 +58,14 @@ gitweb_run () {
# gitweb.log is left for debugging # gitweb.log is left for debugging
} }
safe_chmod () {
chmod "$1" "$2" &&
if [ "$(git config --get core.filemode)" = false ]
then
git update-index --chmod="$1" "$2"
fi
}
. ./test-lib.sh . ./test-lib.sh
perl -MEncode -e 'decode_utf8("", Encode::FB_CROAK)' >/dev/null 2>&1 || { perl -MEncode -e 'decode_utf8("", Encode::FB_CROAK)' >/dev/null 2>&1 || {
@ -229,7 +237,7 @@ test_debug 'cat gitweb.log'
test_expect_success \ test_expect_success \
'commitdiff(0): mode change' \ 'commitdiff(0): mode change' \
'chmod a+x new_file && 'safe_chmod +x new_file &&
git commit -a -m "Mode changed." && git commit -a -m "Mode changed." &&
gitweb_run "p=.git;a=commitdiff"' gitweb_run "p=.git;a=commitdiff"'
test_debug 'cat gitweb.log' test_debug 'cat gitweb.log'
@ -268,7 +276,7 @@ test_debug 'cat gitweb.log'
test_expect_success \ test_expect_success \
'commitdiff(0): mode change and modified' \ 'commitdiff(0): mode change and modified' \
'echo "New line" >> file2 && 'echo "New line" >> file2 &&
chmod a+x file2 && safe_chmod +x file2 &&
git commit -a -m "Mode change and modification." && git commit -a -m "Mode change and modification." &&
gitweb_run "p=.git;a=commitdiff"' gitweb_run "p=.git;a=commitdiff"'
test_debug 'cat gitweb.log' test_debug 'cat gitweb.log'
@ -295,7 +303,7 @@ test_expect_success \
'commitdiff(0): renamed, mode change and modified' \ 'commitdiff(0): renamed, mode change and modified' \
'git mv file3 file2 && 'git mv file3 file2 &&
echo "Propter nomen suum." >> file2 && echo "Propter nomen suum." >> file2 &&
chmod a+x file2 && safe_chmod +x file2 &&
git commit -a -m "File rename, mode change and modification." && git commit -a -m "File rename, mode change and modification." &&
gitweb_run "p=.git;a=commitdiff"' gitweb_run "p=.git;a=commitdiff"'
test_debug 'cat gitweb.log' test_debug 'cat gitweb.log'
@ -412,10 +420,10 @@ test_expect_success \
git add 03-new && git add 03-new &&
git mv 04-rename-from 04-rename-to && git mv 04-rename-from 04-rename-to &&
echo "Changed" >> 04-rename-to && echo "Changed" >> 04-rename-to &&
chmod a+x 05-mode-change && safe_chmod +x 05-mode-change &&
rm -f 06-file-or-symlink && ln -s 01-change 06-file-or-symlink && rm -f 06-file-or-symlink && ln -s 01-change 06-file-or-symlink &&
echo "Changed and have mode changed" > 07-change-mode-change && echo "Changed and have mode changed" > 07-change-mode-change &&
chmod a+x 07-change-mode-change && safe_chmod +x 07-change-mode-change &&
git commit -a -m "Large commit" && git commit -a -m "Large commit" &&
git checkout master' git checkout master'