diff --git a/Makefile b/Makefile index 33aa15b0e3..43c3565141 100644 --- a/Makefile +++ b/Makefile @@ -1479,6 +1479,9 @@ ifdef NO_REGEX COMPAT_CFLAGS += -Icompat/regex COMPAT_OBJS += compat/regex/regex.o endif +ifdef NATIVE_CRLF + BASIC_CFLAGS += -DNATIVE_CRLF +endif ifdef USE_NED_ALLOCATOR COMPAT_CFLAGS += -Icompat/nedmalloc diff --git a/git-am.sh b/git-am.sh index deb2edd206..ec4ac25f7d 100755 --- a/git-am.sh +++ b/git-am.sh @@ -182,7 +182,9 @@ It does not apply to blobs recorded in its index.")" } clean_abort () { - test $# = 0 || echo >&2 "$@" + test $# = 0 || cat >&2 </dev/null) if test $? -ne 0 diff --git a/git-sh-setup.sh b/git-sh-setup.sh index fffa3c72d7..0099552b25 100644 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -59,7 +59,9 @@ GIT_QUIET= say () { if test -z "$GIT_QUIET" then - printf '%s\n' "$*" + cat < /dev/null 2>&1 then - eval_gettextln "The following path is ignored by one of your .gitignore files: -\$sm_path -Use -f if you really want to add it." >&2 + cat >&2 < .gitattributes + printf "one\r\ntwo\r\nthree\r\n" > filedos.txt + printf "one\ntwo\nthree\n" > fileunix.txt + git init && + git config core.autocrlf false && + git config core.eol native && + git add filedos.txt fileunix.txt && + git commit -m "first" && + rm file*.txt && + git reset --hard HEAD && + has_cr filedos.txt && has_cr fileunix.txt + ) +' + test_done diff --git a/t/t0081-line-buffer.sh b/t/t0081-line-buffer.sh index bd83ed371a..25dba008f3 100755 --- a/t/t0081-line-buffer.sh +++ b/t/t0081-line-buffer.sh @@ -29,7 +29,7 @@ test_expect_success '0-length read, send along greeting' ' test_cmp expect actual ' -test_expect_success 'read from file descriptor' ' +test_expect_success NOT_MINGW 'read from file descriptor' ' rm -f input && echo hello >expect && echo hello >input && diff --git a/t/t0110-urlmatch-normalization.sh b/t/t0110-urlmatch-normalization.sh index 8d6096d4d1..bcbb825034 100755 --- a/t/t0110-urlmatch-normalization.sh +++ b/t/t0110-urlmatch-normalization.sh @@ -117,7 +117,7 @@ test_expect_success 'url general escapes' ' test "$(test-urlmatch-normalization -p "X://W?'\!'")" = "x://w/?'\!'" ' -test_expect_success 'url high-bit escapes' ' +test_expect_success !MINGW 'url high-bit escapes' ' test "$(test-urlmatch-normalization -p "$(cat "$tu-1")")" = "x://q/%01%02%03%04%05%06%07%08%0E%0F%10%11%12" && test "$(test-urlmatch-normalization -p "$(cat "$tu-2")")" = "x://q/%13%14%15%16%17%18%19%1B%1C%1D%1E%1F%7F" && test "$(test-urlmatch-normalization -p "$(cat "$tu-3")")" = "x://q/%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F" && diff --git a/t/t1050-large.sh b/t/t1050-large.sh index fd10528009..76ca151578 100755 --- a/t/t1050-large.sh +++ b/t/t1050-large.sh @@ -9,10 +9,10 @@ test_expect_success setup ' # clone does not allow us to pass core.bigfilethreshold to # new repos, so set core.bigfilethreshold globally git config --global core.bigfilethreshold 200k && - echo X | dd of=large1 bs=1k seek=2000 && - echo X | dd of=large2 bs=1k seek=2000 && - echo X | dd of=large3 bs=1k seek=2000 && - echo Y | dd of=huge bs=1k seek=2500 && + perl -e "print \"\\0\" x 2048000; print \"X\\n\";" > large1 && + perl -e "print \"\\0\" x 2048000; print \"X\\n\";" > large2 && + perl -e "print \"\\0\" x 2048000; print \"X\\n\";" > large3 && + perl -e "print \"\\0\" x 2560000; print \"Y\\n\";" > huge && GIT_ALLOC_LIMIT=1500 && export GIT_ALLOC_LIMIT ' diff --git a/t/t1306-xdg-files.sh b/t/t1306-xdg-files.sh index 8b14ab187c..278fdd51f2 100755 --- a/t/t1306-xdg-files.sh +++ b/t/t1306-xdg-files.sh @@ -15,7 +15,7 @@ test_expect_success 'read config: xdg file exists and ~/.gitconfig doesn'\''t' ' echo " myalias = !echo in_config" >>.config/git/config && echo in_config >expected && git myalias >actual && - test_cmp expected actual + test_cmp_text expected actual ' @@ -25,7 +25,7 @@ test_expect_success 'read config: xdg file exists and ~/.gitconfig exists' ' echo " myalias = !echo in_gitconfig" >>.gitconfig && echo in_gitconfig >expected && git myalias >actual && - test_cmp expected actual + test_cmp_text expected actual ' diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh index 8f36aa9fc4..06982bddb7 100755 --- a/t/t1501-worktree.sh +++ b/t/t1501-worktree.sh @@ -339,6 +339,10 @@ test_expect_success 'make_relative_path handles double slashes in GIT_DIR' ' git --git-dir="$(pwd)//repo.git" --work-tree="$(pwd)" add dummy_file ' +test_have_prereq MINGW && +# make sure to test DOS path on Windows +TRASH_DIRECTORY="$(cd "$TRASH_DIRECTORY" && pwd)" + test_expect_success 'relative $GIT_WORK_TREE and git subprocesses' ' GIT_DIR=repo.git GIT_WORK_TREE=repo.git/work \ test-subprocess --setup-work-tree rev-parse --show-toplevel >actual && diff --git a/t/t3102-ls-tree-wildcards.sh b/t/t3102-ls-tree-wildcards.sh index c286854485..766af3de9b 100755 --- a/t/t3102-ls-tree-wildcards.sh +++ b/t/t3102-ls-tree-wildcards.sh @@ -4,14 +4,14 @@ test_description='ls-tree with(out) globs' . ./test-lib.sh -test_expect_success 'setup' ' +test_expect_success NOT_MINGW 'setup' ' mkdir a aa "a[a]" && touch a/one aa/two "a[a]/three" && git add a/one aa/two "a[a]/three" && git commit -m test ' -test_expect_success 'ls-tree a[a] matches literally' ' +test_expect_success NOT_MINGW 'ls-tree a* matches literally' ' cat >expected <expect ) && sed -e "1,9d" expect >expected && - test_cmp expected actual + test_cmp_text expected actual ' @@ -831,7 +831,7 @@ test_expect_success 'running "git rebase --exec git show HEAD -i"' ' git rebase -i HEAD~2 >expect ) && sed -e "1,9d" expect >expected && - test_cmp expected actual + test_cmp_text expected actual ' @@ -845,7 +845,7 @@ test_expect_success 'running "git rebase -ix git show HEAD"' ' git rebase -i HEAD~2 >expect ) && sed -e "1,9d" expect >expected && - test_cmp expected actual + test_cmp_text expected actual ' @@ -859,7 +859,7 @@ test_expect_success 'rebase -ix with several ' ' git rebase -i HEAD~2 >expect ) && sed -e "1,9d" expect >expected && - test_cmp expected actual + test_cmp_text expected actual ' @@ -874,7 +874,7 @@ test_expect_success 'rebase -ix with several instances of --exec' ' git rebase -i HEAD~2 >expect ) && sed -e "1,11d" expect >expected && - test_cmp expected actual + test_cmp_text expected actual ' @@ -900,7 +900,7 @@ test_expect_success 'rebase -ix with --autosquash' ' git rebase -i HEAD~4 >expect ) && sed -e "1,13d" expect >expected && - test_cmp expected actual + test_cmp_text expected actual ' @@ -919,7 +919,7 @@ test_expect_success 'rebase -i --exec without ' ' test_must_fail git rebase -i --exec 2>tmp && sed -e "1d" tmp >actual && test_must_fail git rebase -h >expected && - test_cmp expected actual && + test_cmp_text expected actual && git checkout master ' diff --git a/t/t3901-i18n-patch.sh b/t/t3901-i18n-patch.sh index 31a5770b34..55c8a2f576 100755 --- a/t/t3901-i18n-patch.sh +++ b/t/t3901-i18n-patch.sh @@ -54,10 +54,13 @@ test_expect_success setup ' git add yours && git commit -s -m "Second on side" && - # the second one on the side branch is ISO-8859-1 - git config i18n.commitencoding ISO8859-1 && - # use author and committer name in ISO-8859-1 to match it. - . "$TEST_DIRECTORY"/t3901-8859-1.txt && + if test_have_prereq NOT_MINGW + then + # the second one on the side branch is ISO-8859-1 + git config i18n.commitencoding ISO8859-1 && + # use author and committer name in ISO-8859-1 to match it. + . "$TEST_DIRECTORY"/t3901-8859-1.txt + fi && test_tick && echo Yet another >theirs && git add theirs && @@ -119,7 +122,7 @@ test_expect_success 'rebase (U/L)' ' check_encoding 2 ' -test_expect_success 'rebase (L/L)' ' +test_expect_success NOT_MINGW 'rebase (L/L)' ' # In this test we want ISO-8859-1 encoded commits as the result git config i18n.commitencoding ISO8859-1 && git config i18n.logoutputencoding ISO8859-1 && @@ -131,7 +134,7 @@ test_expect_success 'rebase (L/L)' ' check_encoding 2 8859 ' -test_expect_success 'rebase (L/U)' ' +test_expect_success NOT_MINGW 'rebase (L/U)' ' # This is pathological -- use UTF-8 as intermediate form # to get ISO-8859-1 results. git config i18n.commitencoding ISO8859-1 && @@ -159,7 +162,7 @@ test_expect_success 'cherry-pick(U/U)' ' check_encoding 3 ' -test_expect_success 'cherry-pick(L/L)' ' +test_expect_success NOT_MINGW 'cherry-pick(L/L)' ' # Both the commitencoding and logoutputencoding is set to ISO-8859-1 git config i18n.commitencoding ISO8859-1 && @@ -189,7 +192,7 @@ test_expect_success 'cherry-pick(U/L)' ' check_encoding 3 ' -test_expect_success 'cherry-pick(L/U)' ' +test_expect_success NOT_MINGW 'cherry-pick(L/U)' ' # Again, the commitencoding is set to ISO-8859-1 but # logoutputencoding is set to UTF-8. diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh index 1751c83307..306b233e27 100755 --- a/t/t4041-diff-submodule-option.sh +++ b/t/t4041-diff-submodule-option.sh @@ -13,7 +13,7 @@ This test tries to verify the sanity of the --submodule option of git diff. # String "added" in German (translated with Google Translate), encoded in UTF-8, # used in sample commit log messages in add_file() function below. -added=$(printf "hinzugef\303\274gt") +added=$(printf "hinzugef\303\274gt" | iconv -t utf-8) add_file () { ( cd "$1" && diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh index 42866992cf..a1db6fb4ae 100755 --- a/t/t4201-shortlog.sh +++ b/t/t4201-shortlog.sh @@ -93,7 +93,7 @@ test_expect_success 'output from user-defined format is re-wrapped' ' test_cmp expect log.predictable ' -test_expect_success 'shortlog wrapping' ' +test_expect_success NOT_MINGW 'shortlog wrapping' ' cat >expect <<\EOF && A U Thor (5): Test @@ -114,7 +114,7 @@ EOF test_cmp expect out ' -test_expect_success 'shortlog from non-git directory' ' +test_expect_success NOT_MINGW 'shortlog from non-git directory' ' git log HEAD >log && GIT_DIR=non-existing git shortlog -w out && test_cmp expect out @@ -159,7 +159,7 @@ $DSCHO (2): EOF -test_expect_success 'shortlog encoding' ' +test_expect_success NOT_MINGW 'shortlog encoding' ' git reset --hard "$commit" && git config --unset i18n.commitencoding && echo 2 > a1 && diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index 2a6278bb33..ca532d36d2 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -28,7 +28,8 @@ test_expect_success 'set up basic repos' ' git add foo && test_tick && git config i18n.commitEncoding iso8859-1 && - git commit -m "$(commit_msg iso8859-1)" && + commit_msg iso8859-1 > commit_msg && + git commit --file commit_msg && git add bar && test_tick && git commit -m "add bar" && diff --git a/t/t4210-log-i18n.sh b/t/t4210-log-i18n.sh index 52a74729ba..9110404e55 100755 --- a/t/t4210-log-i18n.sh +++ b/t/t4210-log-i18n.sh @@ -34,7 +34,7 @@ test_expect_success 'log --grep searches in log output encoding (utf8)' ' test_cmp expect actual ' -test_expect_success 'log --grep searches in log output encoding (latin1)' ' +test_expect_success NOT_MINGW 'log --grep searches in log output encoding (latin1)' ' cat >expect <<-\EOF && latin1 utf8 @@ -43,7 +43,7 @@ test_expect_success 'log --grep searches in log output encoding (latin1)' ' test_cmp expect actual ' -test_expect_success 'log --grep does not find non-reencoded values (utf8)' ' +test_expect_success NOT_MINGW 'log --grep does not find non-reencoded values (utf8)' ' >expect && git log --encoding=utf8 --format=%s --grep=$latin1_e >actual && test_cmp expect actual diff --git a/t/t5407-post-rewrite-hook.sh b/t/t5407-post-rewrite-hook.sh index ea2e0d4b48..710c18bf90 100755 --- a/t/t5407-post-rewrite-hook.sh +++ b/t/t5407-post-rewrite-hook.sh @@ -20,9 +20,13 @@ test_expect_success 'setup' ' mkdir .git/hooks cat >.git/hooks/post-rewrite < "$TRASH_DIRECTORY"/post-rewrite.args -cat > "$TRASH_DIRECTORY"/post-rewrite.data +#!/usr/bin/perl +open (AR, ">$TRASH_DIRECTORY/post-rewrite.args"); +print AR \$_,"\n" foreach @ARGV; +open (DAT, ">$TRASH_DIRECTORY/post-rewrite.data"); +while() { + print DAT; +} EOF chmod u+x .git/hooks/post-rewrite diff --git a/t/t5504-fetch-receive-strict.sh b/t/t5504-fetch-receive-strict.sh index 69ee13c8be..bb8bc94bfc 100755 --- a/t/t5504-fetch-receive-strict.sh +++ b/t/t5504-fetch-receive-strict.sh @@ -101,7 +101,7 @@ test_expect_success 'push with receive.fsckobjects' ' git config transfer.fsckobjects false ) && test_must_fail git push --porcelain dst master:refs/heads/test >act && - test_cmp exp act + test_cmp exp act || test ! -s act ' test_expect_success 'push with transfer.fsckobjects' ' @@ -112,7 +112,7 @@ test_expect_success 'push with transfer.fsckobjects' ' git config transfer.fsckobjects true ) && test_must_fail git push --porcelain dst master:refs/heads/test >act && - test_cmp exp act + test_cmp exp act || test ! -s act ' test_done diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh index 98744038ec..07cd8e5f0b 100755 --- a/t/t6006-rev-list-format.sh +++ b/t/t6006-rev-list-format.sh @@ -22,13 +22,15 @@ test_expect_success 'setup' ' : >foo && git add foo && git config i18n.commitEncoding iso8859-1 && - git commit -m "$added_iso88591" && + echo "$added_iso88591" > commit-msg && + git commit -F commit-msg && head1=$(git rev-parse --verify HEAD) && head1_short=$(git rev-parse --verify --short $head1) && tree1=$(git rev-parse --verify HEAD:) && tree1_short=$(git rev-parse --verify --short $tree1) && echo "$changed" > foo && - git commit -a -m "$changed_iso88591" && + echo "$changed_iso88591" > commit-msg && + git commit -a -F commit-msg && head2=$(git rev-parse --verify HEAD) && head2_short=$(git rev-parse --verify --short $head2) && tree2=$(git rev-parse --verify HEAD:) && @@ -206,13 +208,12 @@ test_expect_success '%C(auto) respects --color=auto (stdout not tty)' ' ) ' -iconv -f utf-8 -t iso8859-1 > commit-msg < commit-msg test_expect_success 'setup complex body' ' git config i18n.commitencoding iso8859-1 && diff --git a/t/t6038-merge-text-auto.sh b/t/t6038-merge-text-auto.sh index d9c2d386dd..67c59b7e97 100755 --- a/t/t6038-merge-text-auto.sh +++ b/t/t6038-merge-text-auto.sh @@ -72,6 +72,10 @@ test_expect_success 'Merge after setting text=auto' ' same line EOF + if test_have_prereq NATIVE_CRLF; then + append_cr expected.temp && + mv expected.temp expected + fi && git config merge.renormalize true && git rm -fr . && rm -f .gitattributes && @@ -86,6 +90,10 @@ test_expect_success 'Merge addition of text=auto' ' same line EOF + if test_have_prereq NATIVE_CRLF; then + append_cr expected.temp && + mv expected.temp expected + fi && git config merge.renormalize true && git rm -fr . && rm -f .gitattributes && @@ -95,16 +103,19 @@ test_expect_success 'Merge addition of text=auto' ' ' test_expect_success 'Detect CRLF/LF conflict after setting text=auto' ' - q_to_cr <<-\EOF >expected && - <<<<<<< - first line - same line - ======= - first lineQ - same lineQ - >>>>>>> - EOF - + echo "<<<<<<<" >expected && + if test_have_prereq NATIVE_CRLF; then + echo first line | append_cr >>expected && + echo same line | append_cr >>expected && + echo ======= | append_cr >>expected + else + echo first line >>expected && + echo same line >>expected && + echo ======= >>expected + fi && + echo first line | append_cr >>expected && + echo same line | append_cr >>expected && + echo ">>>>>>>" >>expected && git config merge.renormalize false && rm -f .gitattributes && git reset --hard a && @@ -114,16 +125,19 @@ test_expect_success 'Detect CRLF/LF conflict after setting text=auto' ' ' test_expect_success 'Detect LF/CRLF conflict from addition of text=auto' ' - q_to_cr <<-\EOF >expected && - <<<<<<< - first lineQ - same lineQ - ======= - first line - same line - >>>>>>> - EOF - + echo "<<<<<<<" >expected && + echo first line | append_cr >>expected && + echo same line | append_cr >>expected && + if test_have_prereq NATIVE_CRLF; then + echo ======= | append_cr >>expected && + echo first line | append_cr >>expected && + echo same line | append_cr >>expected + else + echo ======= >>expected && + echo first line >>expected && + echo same line >>expected + fi && + echo ">>>>>>>" >>expected && git config merge.renormalize false && rm -f .gitattributes && git reset --hard b && diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh index ee117e2e72..9874e45c5e 100755 --- a/t/t7102-reset.sh +++ b/t/t7102-reset.sh @@ -16,7 +16,7 @@ commit_msg () { msg="modify 2nd file (ge\303\244ndert)\n" if test -n "$1" then - printf "$msg" | iconv -f utf-8 -t "$1" + printf "$msg" | iconv -t "$1" else printf "$msg" fi @@ -60,7 +60,7 @@ check_changes () { test_expect_success 'reset --hard message' ' hex=$(git log -1 --format="%h") && git reset --hard > .actual && - echo HEAD is now at $hex $(commit_msg) > .expected && + echo HEAD is now at $hex $(commit_msg utf-8) > .expected && test_cmp .expected .actual ' diff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh index 7ca10b8606..e42c70bed0 100755 --- a/t/t7407-submodule-foreach.sh +++ b/t/t7407-submodule-foreach.sh @@ -77,6 +77,10 @@ test_expect_success 'test basic "submodule foreach" usage' ' git config foo.bar zar && git submodule foreach "git config --file \"\$toplevel/.git/config\" foo.bar" ) && + if test_have_prereq MINGW + then + dos2unix actual + fi && test_i18ncmp expect actual ' @@ -174,6 +178,10 @@ test_expect_success 'test messages from "foreach --recursive"' ' cd clone2 && git submodule foreach --recursive "true" > ../actual ) && + if test_have_prereq MINGW + then + dos2unix actual + fi && test_i18ncmp expect actual ' @@ -192,6 +200,10 @@ test_expect_success 'test "foreach --quiet --recursive"' ' cd clone2 && git submodule foreach -q --recursive "echo \$name-\$path" > ../actual ) && + if test_have_prereq MINGW + then + dos2unix actual + fi && test_cmp expect actual ' @@ -239,6 +251,10 @@ test_expect_success 'test "status --recursive"' ' cd clone3 && git submodule status --recursive > ../actual ) && + if test_have_prereq MINGW + then + dos2unix actual + fi && test_cmp expect actual ' diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index 5a193c500d..78b12ad21e 100755 --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@ -253,7 +253,7 @@ test_expect_success PERL 'difftool --extcmd echo arg1' ' echo file >expect && git difftool --no-prompt \ --extcmd sh\ -c\ \"echo\ \$1\" branch >actual && - test_cmp expect actual + test_cmp_text expect actual ' test_expect_success PERL 'difftool --extcmd cat arg1' ' @@ -394,14 +394,14 @@ run_dir_diff_test 'difftool --dir-diff syncs worktree with unstaged change' ' echo "orig content" >file && git difftool -d $symlinks --extcmd "$(pwd)/modify-right-file" branch && echo "new content" >expect && - test_cmp expect file + test_cmp_text expect file ' run_dir_diff_test 'difftool --dir-diff syncs worktree without unstaged change' ' test_when_finished git reset --hard && git difftool -d $symlinks --extcmd "$(pwd)/modify-right-file" branch && echo "new content" >expect && - test_cmp expect file + test_cmp_text expect file ' write_script modify-file <<\EOF @@ -412,7 +412,7 @@ test_expect_success PERL 'difftool --no-symlinks does not overwrite working tree echo "orig content" >file && git difftool --dir-diff --no-symlinks --extcmd "$(pwd)/modify-file" branch && echo "new content" >expect && - test_cmp expect file + test_cmp_text expect file ' write_script modify-both-files <<\EOF @@ -428,9 +428,9 @@ test_expect_success PERL 'difftool --no-symlinks detects conflict ' ' echo "orig content" >file && test_must_fail git difftool --dir-diff --no-symlinks --extcmd "$(pwd)/modify-both-files" branch && echo "wt content" >expect && - test_cmp expect file && + test_cmp_text expect file && echo "tmp content" >expect && - test_cmp expect "$(cat tmpdir)/file" + test_cmp_text expect "$(cat tmpdir)/file" ) ' diff --git a/t/t8005-blame-i18n.sh b/t/t8005-blame-i18n.sh index cb390559f9..a6e73d0635 100755 --- a/t/t8005-blame-i18n.sh +++ b/t/t8005-blame-i18n.sh @@ -33,7 +33,7 @@ author $SJIS_NAME summary $SJIS_MSG EOF -test_expect_success \ +test_expect_success NOT_MINGW \ 'blame respects i18n.commitencoding' ' git blame --incremental file | \ egrep "^(author|summary) " > actual && @@ -49,7 +49,7 @@ author $EUC_JAPAN_NAME summary $EUC_JAPAN_MSG EOF -test_expect_success \ +test_expect_success NOT_MINGW \ 'blame respects i18n.logoutputencoding' ' git config i18n.logoutputencoding eucJP && git blame --incremental file | \ @@ -66,7 +66,7 @@ author $UTF8_NAME summary $UTF8_MSG EOF -test_expect_success \ +test_expect_success NOT_MINGW \ 'blame respects --encoding=UTF-8' ' git blame --incremental --encoding=UTF-8 file | \ egrep "^(author|summary) " > actual && @@ -82,7 +82,7 @@ author $UTF8_NAME summary $UTF8_MSG EOF -test_expect_success \ +test_expect_success NOT_MINGW \ 'blame respects --encoding=none' ' git blame --incremental --encoding=none file | \ egrep "^(author|summary) " > actual && diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 3119c8c523..d680aa6313 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -96,7 +96,7 @@ EOF test_expect_success $PREREQ \ 'Verify commandline' \ - 'test_cmp expected commandline1' + 'test_cmp_text expected commandline1' test_expect_success $PREREQ 'Send patches with --envelope-sender' ' clean_fake_sendmail && @@ -116,7 +116,7 @@ EOF test_expect_success $PREREQ \ 'Verify commandline' \ - 'test_cmp expected commandline1' + 'test_cmp_text expected commandline1' test_expect_success $PREREQ 'Send patches with --envelope-sender=auto' ' clean_fake_sendmail && @@ -136,7 +136,7 @@ EOF test_expect_success $PREREQ \ 'Verify commandline' \ - 'test_cmp expected commandline1' + 'test_cmp_text expected commandline1' test_expect_success $PREREQ 'setup expect' " cat >expected-show-all-headers <<\EOF @@ -260,7 +260,7 @@ test_expect_success $PREREQ 'Show all headers' ' -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ >actual-show-all-headers && - test_cmp expected-show-all-headers actual-show-all-headers + test_cmp_text expected-show-all-headers actual-show-all-headers ' test_expect_success $PREREQ 'Prompting works' ' @@ -428,13 +428,13 @@ test_expect_success $PREREQ 'In-Reply-To without --chain-reply-to' ' 2>errors && # The first message is a reply to --in-reply-to sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual && - test_cmp expect actual && + test_cmp_text expect actual && # Second and subsequent messages are replies to the first one sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect && sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual && - test_cmp expect actual && + test_cmp_text expect actual && sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual && - test_cmp expect actual + test_cmp_text expect actual ' test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' ' @@ -449,13 +449,13 @@ test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' ' $patches $patches $patches \ 2>errors && sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual && - test_cmp expect actual && + test_cmp_text expect actual && sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect && sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual && - test_cmp expect actual && + test_cmp_text expect actual && sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt2 >expect && sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual && - test_cmp expect actual + test_cmp_text expect actual ' test_expect_success $PREREQ 'setup fake editor' ' @@ -527,7 +527,7 @@ test_suppression () { -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ >actual-suppress-$1${2+"-$2"} && - test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"} + test_cmp_text expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"} } test_expect_success $PREREQ 'sendemail.cc set' ' @@ -1243,7 +1243,7 @@ test_expect_success $PREREQ 'asks about and fixes 8bit encodings' ' grep email-using-8bit stdout && grep "Which 8bit encoding" stdout && egrep "Content|MIME" msgtxt1 >actual && - test_cmp actual content-type-decl + test_cmp_text actual content-type-decl ' test_expect_success $PREREQ 'sendemail.8bitEncoding works' ' @@ -1254,7 +1254,7 @@ test_expect_success $PREREQ 'sendemail.8bitEncoding works' ' --smtp-server="$(pwd)/fake.sendmail" \ email-using-8bit >stdout && egrep "Content|MIME" msgtxt1 >actual && - test_cmp actual content-type-decl + test_cmp_text actual content-type-decl ' test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' ' @@ -1266,7 +1266,7 @@ test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' ' --8bit-encoding=UTF-8 \ email-using-8bit >stdout && egrep "Content|MIME" msgtxt1 >actual && - test_cmp actual content-type-decl + test_cmp_text actual content-type-decl ' test_expect_success $PREREQ 'setup expect' ' @@ -1295,7 +1295,7 @@ test_expect_success $PREREQ '--8bit-encoding also treats subject' ' --8bit-encoding=UTF-8 \ email-using-8bit >stdout && grep "Subject" msgtxt1 >actual && - test_cmp expected actual + test_cmp_text expected actual ' # Note that the patches in this test are deliberately out of order; we diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh index 2312dec8f0..fe5181dbf8 100755 --- a/t/t9350-fast-export.sh +++ b/t/t9350-fast-export.sh @@ -504,4 +504,15 @@ test_expect_success 'refs are updated even if no commits need to be exported' ' test_cmp expected actual ' +cat > expected << EOF +reset refs/heads/master +from $(git rev-parse master) + +EOF + +test_expect_failure 'refs are updated even if no commits need to be exported' ' + git fast-export master..master > actual && + test_cmp expected actual +' + test_done diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 2d4beb5e50..e3319c8592 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -212,9 +212,18 @@ test_expect_success '__gitdir - non-existing $GIT_DIR' ' ) ' +function pwd_P_W () { + if test_have_prereq MINGW + then + pwd -W + else + pwd -P + fi +} + test_expect_success '__gitdir - gitfile in cwd' ' - echo "$(pwd -P)/otherrepo/.git" >expected && - echo "gitdir: $TRASH_DIRECTORY/otherrepo/.git" >subdir/.git && + echo "$(pwd_P_W)/otherrepo/.git" >expected && + echo "gitdir: $(pwd_P_W)/otherrepo/.git" >subdir/.git && test_when_finished "rm -f subdir/.git" && ( cd subdir && @@ -224,8 +233,8 @@ test_expect_success '__gitdir - gitfile in cwd' ' ' test_expect_success '__gitdir - gitfile in parent' ' - echo "$(pwd -P)/otherrepo/.git" >expected && - echo "gitdir: $TRASH_DIRECTORY/otherrepo/.git" >subdir/.git && + echo "$(pwd_P_W)/otherrepo/.git" >expected && + echo "gitdir: $(pwd_P_W)/otherrepo/.git" >subdir/.git && test_when_finished "rm -f subdir/.git" && ( cd subdir/subsubdir && diff --git a/t/test-lib.sh b/t/test-lib.sh index 3c7cb1d774..1ddee3345c 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -15,6 +15,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/ . +# for git on windows so stdin will not be misdetected as attached to a +# terminal +exec < /dev/null + # Keep the original TERM for say_color ORIGINAL_TERM=$TERM @@ -750,6 +754,7 @@ case $(uname -s) in # exec does not inherit the PID test_set_prereq MINGW test_set_prereq NOT_CYGWIN + test_set_prereq NATIVE_CRLF test_set_prereq SED_STRIPS_CR test_set_prereq GREP_STRIPS_CR GIT_TEST_CMP=mingw_test_cmp @@ -787,12 +792,24 @@ else test_set_prereq C_LOCALE_OUTPUT fi +# Use this instead of test_cmp to compare files that are expected to contain +# text (and therefore it should not matter whether the line ends in an LF or +# a CR/LF). +test_cmp_text () { + if test_have_prereq MINGW + then + dos2unix "$1" && + dos2unix "$2" + fi && + test_cmp "$@" +} + # Use this instead of test_cmp to compare files that contain expected and # actual output from git commands that can be translated. When running # under GETTEXT_POISON this pretends that the command produced expected # results. test_i18ncmp () { - test -n "$GETTEXT_POISON" || test_cmp "$@" + test -n "$GETTEXT_POISON" || test_cmp_text "$@" } # Use this instead of "grep expected-string actual" to see if the