diff options
Diffstat (limited to 't')
207 files changed, 3439 insertions, 888 deletions
diff --git a/t/.gitattributes b/t/.gitattributes index 3bd959ae52..e7acedabe1 100644 --- a/t/.gitattributes +++ b/t/.gitattributes @@ -1,6 +1,8 @@ t[0-9][0-9][0-9][0-9]/* -whitespace +/chainlint/*.expect eol=lf /diff-lib/* eol=lf /t0110/url-* binary +/t3206/* eol=lf /t3900/*.txt eol=lf /t3901/*.txt eol=lf /t4034/*/* eol=lf @@ -315,6 +315,10 @@ packs on demand. This normally only happens when the object size is over 2GB. This variable forces the code path on any object larger than <n> bytes. +GIT_TEST_OE_DELTA_SIZE=<n> exercises the uncomon pack-objects code +path where deltas larger than this limit require extra memory +allocation for bookkeeping. + Naming Tests ------------ diff --git a/t/chainlint.sed b/t/chainlint.sed index 5f0882cb38..70df40e34b 100644 --- a/t/chainlint.sed +++ b/t/chainlint.sed @@ -61,6 +61,22 @@ # "else", and "fi" in if-then-else likewise must not end with "&&", thus # receives similar treatment. # +# Swallowing here-docs with arbitrary tags requires a bit of finesse. When a +# line such as "cat <<EOF >out" is seen, the here-doc tag is moved to the front +# of the line enclosed in angle brackets as a sentinel, giving "<EOF>cat >out". +# As each subsequent line is read, it is appended to the target line and a +# (whitespace-loose) back-reference match /^<(.*)>\n\1$/ is attempted to see if +# the content inside "<...>" matches the entirety of the newly-read line. For +# instance, if the next line read is "some data", when concatenated with the +# target line, it becomes "<EOF>cat >out\nsome data", and a match is attempted +# to see if "EOF" matches "some data". Since it doesn't, the next line is +# attempted. When a line consisting of only "EOF" (and possible whitespace) is +# encountered, it is appended to the target line giving "<EOF>cat >out\nEOF", +# in which case the "EOF" inside "<...>" does match the text following the +# newline, thus the closing here-doc tag has been found. The closing tag line +# and the "<...>" prefix on the target line are then discarded, leaving just +# the target line "cat >out". +# # To facilitate regression testing (and manual debugging), a ">" annotation is # applied to the line containing ")" which closes a subshell, ">>" to a line # closing a nested subshell, and ">>>" to a line closing both at once. This @@ -78,14 +94,17 @@ # here-doc -- swallow it to avoid false hits within its body (but keep the # command to which it was attached) -/<<[ ]*[-\\]*EOF[ ]*/ { - s/[ ]*<<[ ]*[-\\]*EOF// - h - :hereslurp +/<<[ ]*[-\\'"]*[A-Za-z0-9_]/ { + s/^\(.*\)<<[ ]*[-\\'"]*\([A-Za-z0-9_][A-Za-z0-9_]*\)['"]*/<\2>\1<</ + s/[ ]*<<// + :hered N - s/.*\n// - /^[ ]*EOF[ ]*$/!bhereslurp - x + /^<\([^>]*\)>.*\n[ ]*\1[ ]*$/!{ + s/\n.*$// + bhered + } + s/^<[^>]*>// + s/\n.*$// } # one-liner "(...) &&" @@ -112,9 +131,8 @@ b b :subshell -# bare "(" line? +# bare "(" line? -- stash for later printing /^[ ]*([ ]*$/ { - # stash for later printing h bnextline } @@ -131,17 +149,16 @@ s/.*\n// :slurp # incomplete line "...\" -/\\$/bincomplete -# multi-line quoted string "...\n..." -/^[^"]*"[^"]*$/bdqstring -# multi-line quoted string '...\n...' (but not contraction in string "it's so") -/^[^']*'[^']*$/{ +/\\$/bicmplte +# multi-line quoted string "...\n..."? +/"/bdqstring +# multi-line quoted string '...\n...'? (but not contraction in string "it's") +/'/{ /"[^'"]*'[^'"]*"/!bsqstring } +:folded # here-doc -- swallow it -/<<[ ]*[-\\]*EOF/bheredoc -/<<[ ]*[-\\]*EOT/bheredoc -/<<[ ]*[-\\]*INPUT_END/bheredoc +/<<[ ]*[-\\'"]*[A-Za-z0-9_]/bheredoc # comment or empty line -- discard since final non-comment, non-empty line # before closing ")", "done", "elsif", "else", or "fi" will need to be # re-visited to drop "suspect" marking since final line of those constructs @@ -154,7 +171,7 @@ s/.*\n// /"[^"]*#[^"]*"/!s/[ ]#.*$// } # one-liner "case ... esac" -/^[ ]*case[ ]*..*esac/bcheckchain +/^[ ]*case[ ]*..*esac/bchkchn # multi-line "case ... esac" /^[ ]*case[ ]..*[ ]in/bcase # multi-line "for ... done" or "while ... done" @@ -183,32 +200,32 @@ s/.*\n// /^[ ]*fi[ ]*[<>|]/bdone /^[ ]*fi[ ]*)/bdone # nested one-liner "(...) &&" -/^[ ]*(.*)[ ]*&&[ ]*$/bcheckchain +/^[ ]*(.*)[ ]*&&[ ]*$/bchkchn # nested one-liner "(...)" -/^[ ]*(.*)[ ]*$/bcheckchain +/^[ ]*(.*)[ ]*$/bchkchn # nested one-liner "(...) >x" (or "2>x" or "<x" or "|x") -/^[ ]*(.*)[ ]*[0-9]*[<>|]/bcheckchain +/^[ ]*(.*)[ ]*[0-9]*[<>|]/bchkchn # nested multi-line "(...\n...)" /^[ ]*(/bnest # multi-line "{...\n...}" /^[ ]*{/bblock # closing ")" on own line -- exit subshell -/^[ ]*)/bclosesolo +/^[ ]*)/bclssolo # "$((...))" -- arithmetic expansion; not closing ")" -/\$(([^)][^)]*))[^)]*$/bcheckchain +/\$(([^)][^)]*))[^)]*$/bchkchn # "$(...)" -- command substitution; not closing ")" -/\$([^)][^)]*)[^)]*$/bcheckchain +/\$([^)][^)]*)[^)]*$/bchkchn # multi-line "$(...\n...)" -- command substitution; treat as nested subshell -/\$([ ]*$/bnest +/\$([^)]*$/bnest # "=(...)" -- Bash array assignment; not closing ")" -/=(/bcheckchain +/=(/bchkchn # closing "...) &&" /)[ ]*&&[ ]*$/bclose # closing "...)" /)[ ]*$/bclose # closing "...) >x" (or "2>x" or "<x" or "|x") /)[ ]*[<>|]/bclose -:checkchain +:chkchn # mark suspect if line uses ";" internally rather than "&&" (but not ";" in a # string and not ";;" in one-liner "case...esac") /;/{ @@ -227,47 +244,53 @@ n bslurp # found incomplete line "...\" -- slurp up next line -:incomplete +:icmplte N s/\\\n// bslurp -# found multi-line double-quoted string "...\n..." -- slurp until end of string +# check for multi-line double-quoted string "...\n..." -- fold to one line :dqstring -s/"//g +# remove all quote pairs +s/"\([^"]*\)"/@!\1@!/g +# done if no dangling quote +/"/!bdqdone +# otherwise, slurp next line and try again N s/\n// -/"/!bdqstring -bcheckchain +bdqstring +:dqdone +s/@!/"/g +bfolded -# found multi-line single-quoted string '...\n...' -- slurp until end of string +# check for multi-line single-quoted string '...\n...' -- fold to one line :sqstring -s/'//g +# remove all quote pairs +s/'\([^']*\)'/@!\1@!/g +# done if no dangling quote +/'/!bsqdone +# otherwise, slurp next line and try again N s/\n// -/'/!bsqstring -bcheckchain +bsqstring +:sqdone +s/@!/'/g +bfolded # found here-doc -- swallow it to avoid false hits within its body (but keep -# the command to which it was attached); take care to handle here-docs nested -# within here-docs by only recognizing closing tag matching outer here-doc -# opening tag +# the command to which it was attached) :heredoc -/EOF/{ s/[ ]*<<[ ]*[-\\]*EOF//; s/^/EOF/; } -/EOT/{ s/[ ]*<<[ ]*[-\\]*EOT//; s/^/EOT/; } -/INPUT_END/{ s/[ ]*<<[ ]*[-\\]*INPUT_END//; s/^/INPUT_END/; } -:hereslurpsub +s/^\(.*\)<<[ ]*[-\\'"]*\([A-Za-z0-9_][A-Za-z0-9_]*\)['"]*/<\2>\1<</ +s/[ ]*<<// +:heredsub N -/^EOF.*\n[ ]*EOF[ ]*$/bhereclose -/^EOT.*\n[ ]*EOT[ ]*$/bhereclose -/^INPUT_END.*\n[ ]*INPUT_END[ ]*$/bhereclose -bhereslurpsub -:hereclose -s/^EOF// -s/^EOT// -s/^INPUT_END// +/^<\([^>]*\)>.*\n[ ]*\1[ ]*$/!{ + s/\n.*$// + bheredsub +} +s/^<[^>]*>// s/\n.*$// -bcheckchain +bfolded # found "case ... in" -- pass through untouched :case @@ -293,43 +316,43 @@ x # is 'done' or 'fi' cuddled with ")" to close subshell? /done.*)/bclose /fi.*)/bclose -bcheckchain +bchkchn # found nested multi-line "(...\n...)" -- pass through untouched :nest x -:nestslurp +:nstslurp n # closing ")" on own line -- stop nested slurp -/^[ ]*)/bnestclose +/^[ ]*)/bnstclose # comment -- not closing ")" if in comment -/^[ ]*#/bnestcontinue +/^[ ]*#/bnstcnt # "$((...))" -- arithmetic expansion; not closing ")" -/\$(([^)][^)]*))[^)]*$/bnestcontinue +/\$(([^)][^)]*))[^)]*$/bnstcnt # "$(...)" -- command substitution; not closing ")" -/\$([^)][^)]*)[^)]*$/bnestcontinue +/\$([^)][^)]*)[^)]*$/bnstcnt # closing "...)" -- stop nested slurp -/)/bnestclose -:nestcontinue +/)/bnstclose +:nstcnt x -bnestslurp -:nestclose +bnstslurp +:nstclose s/^/>>/ # is it "))" which closes nested and parent subshells? /)[ ]*)/bslurp -bcheckchain +bchkchn # found multi-line "{...\n...}" block -- pass through untouched :block x n # closing "}" -- stop block slurp -/}/bcheckchain +/}/bchkchn bblock # found closing ")" on own line -- drop "suspect" from final line of subshell # since that line legitimately lacks "&&" and exit subshell loop -:closesolo +:clssolo x s/?!AMP?!// p diff --git a/t/chainlint/here-doc-close-subshell.expect b/t/chainlint/here-doc-close-subshell.expect new file mode 100644 index 0000000000..f011e335e5 --- /dev/null +++ b/t/chainlint/here-doc-close-subshell.expect @@ -0,0 +1,2 @@ +( +> cat) diff --git a/t/chainlint/here-doc-close-subshell.test b/t/chainlint/here-doc-close-subshell.test new file mode 100644 index 0000000000..b857ff5467 --- /dev/null +++ b/t/chainlint/here-doc-close-subshell.test @@ -0,0 +1,5 @@ +( +# LINT: line contains here-doc and closes nested subshell + cat <<-\INPUT) + fizz + INPUT diff --git a/t/chainlint/here-doc-multi-line-command-subst.expect b/t/chainlint/here-doc-multi-line-command-subst.expect new file mode 100644 index 0000000000..e5fb752d2f --- /dev/null +++ b/t/chainlint/here-doc-multi-line-command-subst.expect @@ -0,0 +1,5 @@ +( + x=$(bobble && +?!AMP?!>> wiffle) + echo $x +>) diff --git a/t/chainlint/here-doc-multi-line-command-subst.test b/t/chainlint/here-doc-multi-line-command-subst.test new file mode 100644 index 0000000000..899bc5de8b --- /dev/null +++ b/t/chainlint/here-doc-multi-line-command-subst.test @@ -0,0 +1,9 @@ +( +# LINT: line contains here-doc and opens multi-line $(...) + x=$(bobble <<-\END && + fossil + vegetable + END + wiffle) + echo $x +) diff --git a/t/chainlint/here-doc-multi-line-string.expect b/t/chainlint/here-doc-multi-line-string.expect new file mode 100644 index 0000000000..32038a070c --- /dev/null +++ b/t/chainlint/here-doc-multi-line-string.expect @@ -0,0 +1,4 @@ +( +?!AMP?! cat && echo "multi-line string" + bap +>) diff --git a/t/chainlint/here-doc-multi-line-string.test b/t/chainlint/here-doc-multi-line-string.test new file mode 100644 index 0000000000..a53edbcc8d --- /dev/null +++ b/t/chainlint/here-doc-multi-line-string.test @@ -0,0 +1,8 @@ +( +# LINT: line contains here-doc and opens multi-line string + cat <<-\TXT && echo "multi-line + string" + fizzle + TXT + bap +) diff --git a/t/chainlint/here-doc.expect b/t/chainlint/here-doc.expect index 2328fe7753..534b065e38 100644 --- a/t/chainlint/here-doc.expect +++ b/t/chainlint/here-doc.expect @@ -1,3 +1,9 @@ boodle wobba gorgo snoot wafta snurb && +cat >foo && + +cat >bar && + +cat >boo && + horticulture diff --git a/t/chainlint/here-doc.test b/t/chainlint/here-doc.test index bd36f6e1d3..ad4ce8afd9 100644 --- a/t/chainlint/here-doc.test +++ b/t/chainlint/here-doc.test @@ -7,6 +7,27 @@ quoth the raven, nevermore... EOF +# LINT: swallow here-doc with arbitrary tag +cat <<-Arbitrary_Tag_42 >foo && +snoz +boz +woz +Arbitrary_Tag_42 + +# LINT: swallow 'quoted' here-doc +cat <<'FUMP' >bar && +snoz +boz +woz +FUMP + +# LINT: swallow "quoted" here-doc +cat <<"zump" >boo && +snoz +boz +woz +zump + # LINT: swallow here-doc (EOF is last line of test) horticulture <<\EOF gomez diff --git a/t/chainlint/multi-line-nested-command-substitution.expect b/t/chainlint/multi-line-nested-command-substitution.expect index 19c023b1c8..59b6c8b850 100644 --- a/t/chainlint/multi-line-nested-command-substitution.expect +++ b/t/chainlint/multi-line-nested-command-substitution.expect @@ -6,4 +6,13 @@ >> ) && echo ok >) | -sort +sort && +( + bar && + x=$(echo bar | + cat +>> ) && + y=$(echo baz | +>> fip) && + echo fail +>) diff --git a/t/chainlint/multi-line-nested-command-substitution.test b/t/chainlint/multi-line-nested-command-substitution.test index ca0620ab6b..300058341b 100644 --- a/t/chainlint/multi-line-nested-command-substitution.test +++ b/t/chainlint/multi-line-nested-command-substitution.test @@ -6,4 +6,13 @@ ) && echo ok ) | -sort +sort && +( + bar && + x=$(echo bar | + cat + ) && + y=$(echo baz | + fip) && + echo fail +) diff --git a/t/chainlint/multi-line-string.expect b/t/chainlint/multi-line-string.expect index 8334c4cc8e..170cb59993 100644 --- a/t/chainlint/multi-line-string.expect +++ b/t/chainlint/multi-line-string.expect @@ -1,9 +1,15 @@ ( - x=line 1 line 2 line 3" && -?!AMP?! y=line 1 line2' + x="line 1 line 2 line 3" && +?!AMP?! y='line 1 line2' foobar >) && ( echo "there's nothing to see here" && exit +>) && +( + echo "xyz" "abc def ghi" && + echo 'xyz' 'abc def ghi' && + echo 'xyz' "abc def ghi" && + barfoo >) diff --git a/t/chainlint/multi-line-string.test b/t/chainlint/multi-line-string.test index 14cb44d51c..287ab89705 100644 --- a/t/chainlint/multi-line-string.test +++ b/t/chainlint/multi-line-string.test @@ -12,4 +12,16 @@ # LINT: starting multi-line single-quoted string echo "there's nothing to see here" && exit +) && +( + echo "xyz" "abc + def + ghi" && + echo 'xyz' 'abc + def + ghi' && + echo 'xyz' "abc + def + ghi" && + barfoo ) diff --git a/t/chainlint/nested-here-doc.expect b/t/chainlint/nested-here-doc.expect index 559301e005..0c9ef1cfc6 100644 --- a/t/chainlint/nested-here-doc.expect +++ b/t/chainlint/nested-here-doc.expect @@ -1,3 +1,5 @@ +cat >foop && + ( cat && ?!AMP?! cat diff --git a/t/chainlint/nested-here-doc.test b/t/chainlint/nested-here-doc.test index 027e0bb3ff..f35404bf0f 100644 --- a/t/chainlint/nested-here-doc.test +++ b/t/chainlint/nested-here-doc.test @@ -1,3 +1,13 @@ +# LINT: inner "EOF" not misintrepreted as closing ARBITRARY here-doc +cat <<ARBITRARY >foop && +naddle +fub <<EOF + nozzle + noodle +EOF +formp +ARBITRARY + ( # LINT: inner "EOF" not misintrepreted as closing INPUT_END here-doc cat <<-\INPUT_END && diff --git a/t/chainlint/subshell-here-doc.expect b/t/chainlint/subshell-here-doc.expect index 19d5aff233..74723e7340 100644 --- a/t/chainlint/subshell-here-doc.expect +++ b/t/chainlint/subshell-here-doc.expect @@ -2,4 +2,10 @@ echo wobba gorgo snoot wafta snurb && ?!AMP?! cat >bip echo >bop +>) && +( + cat >bup && + cat >bup2 && + cat >bup3 && + meep >) diff --git a/t/chainlint/subshell-here-doc.test b/t/chainlint/subshell-here-doc.test index 9c3564c247..f6b3ba4214 100644 --- a/t/chainlint/subshell-here-doc.test +++ b/t/chainlint/subshell-here-doc.test @@ -20,4 +20,20 @@ wednesday pugsly EOF +) && +( +# LINT: swallow here-doc with arbitrary tag + cat <<-\ARBITRARY >bup && + glink + FIZZ + ARBITRARY + cat <<-'ARBITRARY2' >bup2 && + glink + FIZZ + ARBITRARY2 + cat <<-"ARBITRARY3" >bup3 && + glink + FIZZ + ARBITRARY3 + meep ) diff --git a/t/chainlint/t7900-subtree.expect b/t/chainlint/t7900-subtree.expect new file mode 100644 index 0000000000..c9913429e6 --- /dev/null +++ b/t/chainlint/t7900-subtree.expect @@ -0,0 +1,10 @@ +( + chks="sub1sub2sub3sub4" && + chks_sub=$(cat | sed 's,^,sub dir/,' +>>) && + chkms="main-sub1main-sub2main-sub3main-sub4" && + chkms_sub=$(cat | sed 's,^,sub dir/,' +>>) && + subfiles=$(git ls-files) && + check_equal "$subfiles" "$chkms$chks" +>) diff --git a/t/chainlint/t7900-subtree.test b/t/chainlint/t7900-subtree.test new file mode 100644 index 0000000000..277d8358df --- /dev/null +++ b/t/chainlint/t7900-subtree.test @@ -0,0 +1,22 @@ +( + chks="sub1 +sub2 +sub3 +sub4" && + chks_sub=$(cat <<TXT | sed 's,^,sub dir/,' +$chks +TXT +) && + chkms="main-sub1 +main-sub2 +main-sub3 +main-sub4" && + chkms_sub=$(cat <<TXT | sed 's,^,sub dir/,' +$chkms +TXT +) && + + subfiles=$(git ls-files) && + check_equal "$subfiles" "$chkms +$chks" +) diff --git a/t/check-non-portable-shell.pl b/t/check-non-portable-shell.pl index d5823f71d8..b45bdac688 100755 --- a/t/check-non-portable-shell.pl +++ b/t/check-non-portable-shell.pl @@ -41,6 +41,9 @@ while (<>) { /^\s*[^#]\s*which\s/ and err 'which is not portable (use type)'; /\btest\s+[^=]*==/ and err '"test a == b" is not portable (use =)'; /\bwc -l.*"\s*=/ and err '`"$(wc -l)"` is not portable (use test_line_count)'; + /\bhead\s+-c\b/ and err 'head -c is not portable (use test_copy_bytes BYTES <file >out)'; + /(?:\$\(seq|^\s*seq\b)/ and err 'seq is not portable (use test_seq)'; + /\bgrep\b.*--file\b/ and err 'grep --file FILE is not portable (use grep -f FILE)'; /\bexport\s+[A-Za-z0-9_]*=/ and err '"export FOO=bar" is not portable (use FOO=bar && export FOO)'; /^\s*([A-Z0-9_]+=(\w+|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and err '"FOO=bar shell_func" assignment extends beyond "shell_func"'; diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c index 0edafcfd65..db19131f71 100644 --- a/t/helper/test-tool.c +++ b/t/helper/test-tool.c @@ -43,6 +43,9 @@ static struct test_cmd cmds[] = { { "subprocess", cmd__subprocess }, { "urlmatch-normalization", cmd__urlmatch_normalization }, { "wildmatch", cmd__wildmatch }, +#ifdef GIT_WINDOWS_NATIVE + { "windows-named-pipe", cmd__windows_named_pipe }, +#endif { "write-cache", cmd__write_cache }, }; diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h index e926c416ea..4914001086 100644 --- a/t/helper/test-tool.h +++ b/t/helper/test-tool.h @@ -1,6 +1,8 @@ #ifndef __TEST_TOOL_H__ #define __TEST_TOOL_H__ +#include "git-compat-util.h" + int cmd__chmtime(int argc, const char **argv); int cmd__config(int argc, const char **argv); int cmd__ctype(int argc, const char **argv); @@ -37,6 +39,9 @@ int cmd__submodule_config(int argc, const char **argv); int cmd__subprocess(int argc, const char **argv); int cmd__urlmatch_normalization(int argc, const char **argv); int cmd__wildmatch(int argc, const char **argv); +#ifdef GIT_WINDOWS_NATIVE +int cmd__windows_named_pipe(int argc, const char **argv); +#endif int cmd__write_cache(int argc, const char **argv); #endif diff --git a/t/helper/test-windows-named-pipe.c b/t/helper/test-windows-named-pipe.c new file mode 100644 index 0000000000..b4b752b01a --- /dev/null +++ b/t/helper/test-windows-named-pipe.c @@ -0,0 +1,72 @@ +#include "test-tool.h" +#include "git-compat-util.h" +#include "strbuf.h" + +#ifdef GIT_WINDOWS_NATIVE +static const char *usage_string = "<pipe-filename>"; + +#define TEST_BUFSIZE (4096) + +int cmd__windows_named_pipe(int argc, const char **argv) +{ + const char *filename; + struct strbuf pathname = STRBUF_INIT; + int err; + HANDLE h; + BOOL connected; + char buf[TEST_BUFSIZE + 1]; + + if (argc < 2) + goto print_usage; + filename = argv[1]; + if (strchr(filename, '/') || strchr(filename, '\\')) + goto print_usage; + strbuf_addf(&pathname, "//./pipe/%s", filename); + + /* + * Create a single instance of the server side of the named pipe. + * This will allow exactly one client instance to connect to it. + */ + h = CreateNamedPipeA( + pathname.buf, + PIPE_ACCESS_INBOUND | FILE_FLAG_FIRST_PIPE_INSTANCE, + PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, + PIPE_UNLIMITED_INSTANCES, + TEST_BUFSIZE, TEST_BUFSIZE, 0, NULL); + if (h == INVALID_HANDLE_VALUE) { + err = err_win_to_posix(GetLastError()); + fprintf(stderr, "CreateNamedPipe failed: %s\n", + strerror(err)); + return err; + } + + connected = ConnectNamedPipe(h, NULL) + ? TRUE + : (GetLastError() == ERROR_PIPE_CONNECTED); + if (!connected) { + err = err_win_to_posix(GetLastError()); + fprintf(stderr, "ConnectNamedPipe failed: %s\n", + strerror(err)); + CloseHandle(h); + return err; + } + + while (1) { + DWORD nbr; + BOOL success = ReadFile(h, buf, TEST_BUFSIZE, &nbr, NULL); + if (!success || nbr == 0) + break; + buf[nbr] = 0; + + write(1, buf, nbr); + } + + DisconnectNamedPipe(h); + CloseHandle(h); + return 0; + +print_usage: + fprintf(stderr, "usage: %s %s\n", argv[0], usage_string); + return 1; +} +#endif diff --git a/t/lib-gpg.sh b/t/lib-gpg.sh index a5d3b2cbaa..3fe02876c1 100755 --- a/t/lib-gpg.sh +++ b/t/lib-gpg.sh @@ -38,7 +38,33 @@ then "$TEST_DIRECTORY"/lib-gpg/ownertrust && gpg --homedir "${GNUPGHOME}" </dev/null >/dev/null 2>&1 \ --sign -u committer@example.com && - test_set_prereq GPG + test_set_prereq GPG && + # Available key info: + # * see t/lib-gpg/gpgsm-gen-key.in + # To generate new certificate: + # * no passphrase + # gpgsm --homedir /tmp/gpghome/ \ + # -o /tmp/gpgsm.crt.user \ + # --generate-key \ + # --batch t/lib-gpg/gpgsm-gen-key.in + # To import certificate: + # gpgsm --homedir /tmp/gpghome/ \ + # --import /tmp/gpgsm.crt.user + # To export into a .p12 we can later import: + # gpgsm --homedir /tmp/gpghome/ \ + # -o t/lib-gpg/gpgsm_cert.p12 \ + # --export-secret-key-p12 "committer@example.com" + echo | gpgsm --homedir "${GNUPGHOME}" 2>/dev/null \ + --passphrase-fd 0 --pinentry-mode loopback \ + --import "$TEST_DIRECTORY"/lib-gpg/gpgsm_cert.p12 && + gpgsm --homedir "${GNUPGHOME}" 2>/dev/null -K \ + | grep fingerprint: | cut -d" " -f4 | tr -d '\n' > \ + ${GNUPGHOME}/trustlist.txt && + echo " S relax" >> ${GNUPGHOME}/trustlist.txt && + (gpgconf --kill gpg-agent >/dev/null 2>&1 || : ) && + echo hello | gpgsm --homedir "${GNUPGHOME}" >/dev/null \ + -u committer@example.com -o /dev/null --sign - 2>&1 && + test_set_prereq GPGSM ;; esac fi diff --git a/t/lib-gpg/gpgsm-gen-key.in b/t/lib-gpg/gpgsm-gen-key.in new file mode 100644 index 0000000000..a7fd87c069 --- /dev/null +++ b/t/lib-gpg/gpgsm-gen-key.in @@ -0,0 +1,8 @@ +Key-Type: RSA +Key-Length: 2048 +Key-Usage: sign +Serial: random +Name-DN: CN=C O Mitter, O=Example, SN=C O, GN=Mitter +Name-Email: committer@example.com +Not-Before: 1970-01-01 00:00:00 +Not-After: 3000-01-01 00:00:00 diff --git a/t/lib-gpg/gpgsm_cert.p12 b/t/lib-gpg/gpgsm_cert.p12 Binary files differnew file mode 100644 index 0000000000..94ffad0d31 --- /dev/null +++ b/t/lib-gpg/gpgsm_cert.p12 diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh index 25a77ee5cb..2ca9fb69d6 100644 --- a/t/lib-rebase.sh +++ b/t/lib-rebase.sh @@ -14,8 +14,8 @@ # specified line. # # "<cmd> <lineno>" -- add a line with the specified command -# ("squash", "fixup", "edit", "reword" or "drop") and the SHA1 taken -# from the specified line. +# ("pick", "squash", "fixup", "edit", "reword" or "drop") and the +# SHA1 taken from the specified line. # # "exec_cmd_with_args" -- add an "exec cmd with args" line. # @@ -47,7 +47,7 @@ set_fake_editor () { action=pick for line in $FAKE_LINES; do case $line in - squash|fixup|edit|reword|drop) + pick|squash|fixup|edit|reword|drop) action="$line";; exec*) echo "$line" | sed 's/_/ /g' >> "$1";; diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh index 5b56b23166..016391723c 100755 --- a/t/lib-submodule-update.sh +++ b/t/lib-submodule-update.sh @@ -235,7 +235,7 @@ reset_work_tree_to_interested () { then mkdir -p submodule_update/.git/modules/sub1/modules && cp -r submodule_update_repo/.git/modules/sub1/modules/sub2 submodule_update/.git/modules/sub1/modules/sub2 - # core.worktree is unset for sub2 as it is not checked out + GIT_WORK_TREE=. git -C submodule_update/.git/modules/sub1/modules/sub2 config --unset core.worktree fi && # indicate we are interested in the submodule: git -C submodule_update config submodule.sub1.url "bogus" && @@ -709,8 +709,7 @@ test_submodule_recursing_with_args_common() { git branch -t remove_sub1 origin/remove_sub1 && $command remove_sub1 && test_superproject_content origin/remove_sub1 && - ! test -e sub1 && - test_must_fail git config -f .git/modules/sub1/config core.worktree + ! test -e sub1 ) ' # ... absorbing a .git directory along the way. diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh index 34859fe4a5..850f651e4e 100755 --- a/t/t0000-basic.sh +++ b/t/t0000-basic.sh @@ -116,7 +116,7 @@ check_sub_test_lib_test () { name="$1" # stdin is the expected output from the test ( cd "$name" && - ! test -s err && + test_must_be_empty err && sed -e 's/^> //' -e 's/Z$//' >expect && test_cmp expect out ) diff --git a/t/t0001-init.sh b/t/t0001-init.sh index ca85aae51e..182da069f1 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@ -167,9 +167,8 @@ test_expect_success 'reinit' ' ) && test_i18ngrep "Initialized empty" again/out1 && test_i18ngrep "Reinitialized existing" again/out2 && - >again/empty && - test_i18ncmp again/empty again/err1 && - test_i18ncmp again/empty again/err2 + test_must_be_empty again/err1 && + test_must_be_empty again/err2 ' test_expect_success 'init with --template' ' diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh index 5c37c2e1f8..22499bce5f 100755 --- a/t/t0003-attributes.sh +++ b/t/t0003-attributes.sh @@ -208,9 +208,8 @@ test_expect_success 'attribute test: --all option' ' ' test_expect_success 'attribute test: --cached option' ' - : >empty && git check-attr --cached --stdin --all <stdin-all | sort >actual && - test_cmp empty actual && + test_must_be_empty actual && git add .gitattributes a/.gitattributes a/b/.gitattributes && git check-attr --cached --stdin --all <stdin-all | sort >actual && test_cmp specified-all actual diff --git a/t/t0008-ignores.sh b/t/t0008-ignores.sh index c03f155a35..1744cee5e9 100755 --- a/t/t0008-ignores.sh +++ b/t/t0008-ignores.sh @@ -807,10 +807,9 @@ test_expect_success 'trailing whitespace is ignored' ' cat >expect <<EOF && whitespace/untracked EOF - : >err.expect && git ls-files -o -X ignore whitespace >actual 2>err && test_cmp expect actual && - test_cmp err.expect err + test_must_be_empty err ' test_expect_success !MINGW 'quoting allows trailing whitespace' ' @@ -820,10 +819,9 @@ test_expect_success !MINGW 'quoting allows trailing whitespace' ' >whitespace/untracked && echo "whitespace/trailing\\ \\ " >ignore && echo whitespace/untracked >expect && - : >err.expect && git ls-files -o -X ignore whitespace >actual 2>err && test_cmp expect actual && - test_cmp err.expect err + test_must_be_empty err ' test_expect_success !MINGW,!CYGWIN 'correct handling of backslashes' ' @@ -845,10 +843,9 @@ test_expect_success !MINGW,!CYGWIN 'correct handling of backslashes' ' whitespace/trailing 6 \\a\\Z EOF echo whitespace/untracked >expect && - >err.expect && git ls-files -o -X ignore whitespace >actual 2>err && test_cmp expect actual && - test_cmp err.expect err + test_must_be_empty err ' test_expect_success 'info/exclude trumps core.excludesfile' ' diff --git a/t/t0019/parse_json.perl b/t/t0019/parse_json.perl index ca4e5bfa78..fea87fb81b 100644 --- a/t/t0019/parse_json.perl +++ b/t/t0019/parse_json.perl @@ -34,6 +34,9 @@ sub dump_item { } elsif (ref($value) eq 'HASH') { print "$label_in hash\n"; dump_hash($label_in, $value); + } elsif (ref $value) { + my $bool = $value ? 1 : 0; + print "$label_in $bool\n"; } elsif (defined $value) { print "$label_in $value\n"; } else { diff --git a/t/t0020-crlf.sh b/t/t0020-crlf.sh index 5f056982a5..854da0ae16 100755 --- a/t/t0020-crlf.sh +++ b/t/t0020-crlf.sh @@ -160,7 +160,7 @@ test_expect_success 'checkout with autocrlf=input' ' git config core.autocrlf input && git read-tree --reset -u HEAD && test_must_fail has_cr one && - test_must_fail has_cr two && + test_must_fail has_cr dir/two && git update-index -- one dir/two && test "$one" = $(git hash-object --stdin <one) && test "$two" = $(git hash-object --stdin <dir/two) && diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh index 6a213608cc..308cd28f3b 100755 --- a/t/t0021-conversion.sh +++ b/t/t0021-conversion.sh @@ -583,7 +583,7 @@ test_expect_success PERL 'process filter should restart after unexpected write f git checkout --quiet --no-progress . 2>git-stderr.log && grep "smudge write error at" git-stderr.log && - grep "error: external filter" git-stderr.log && + test_i18ngrep "error: external filter" git-stderr.log && cat >expected.log <<-EOF && START diff --git a/t/t0028-working-tree-encoding.sh b/t/t0028-working-tree-encoding.sh index 12b8eb963a..7e87b5a200 100755 --- a/t/t0028-working-tree-encoding.sh +++ b/t/t0028-working-tree-encoding.sh @@ -203,7 +203,11 @@ test_expect_success 'error if encoding garbage is already in Git' ' test_i18ngrep "error: BOM is required" err.out ' -test_expect_success 'check roundtrip encoding' ' +test_lazy_prereq ICONV_SHIFT_JIS ' + iconv -f UTF-8 -t SHIFT-JIS </dev/null +' + +test_expect_success ICONV_SHIFT_JIS 'check roundtrip encoding' ' test_when_finished "rm -f roundtrip.shift roundtrip.utf16" && test_when_finished "git reset --hard HEAD" && diff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh index bbf3e39e3d..5ce47e8af5 100755 --- a/t/t0030-stripspace.sh +++ b/t/t0030-stripspace.sh @@ -110,31 +110,30 @@ test_expect_success \ test_expect_success \ 'only consecutive blank lines should be completely removed' ' - > expect && printf "\n" | git stripspace >actual && - test_cmp expect actual && + test_must_be_empty actual && printf "\n\n\n" | git stripspace >actual && - test_cmp expect actual && + test_must_be_empty actual && printf "$sss\n$sss\n$sss\n" | git stripspace >actual && - test_cmp expect actual && + test_must_be_empty actual && printf "$sss$sss\n$sss\n\n" | git stripspace >actual && - test_cmp expect actual && + test_must_be_empty actual && printf "\n$sss\n$sss$sss\n" | git stripspace >actual && - test_cmp expect actual && + test_must_be_empty actual && printf "$sss$sss$sss$sss\n\n\n" | git stripspace >actual && - test_cmp expect actual && + test_must_be_empty actual && printf "\n$sss$sss$sss$sss\n\n" | git stripspace >actual && - test_cmp expect actual && + test_must_be_empty actual && printf "\n\n$sss$sss$sss$sss\n" | git stripspace >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success \ @@ -321,22 +320,20 @@ test_expect_success \ test_expect_success \ 'spaces with newline at end should be replaced with empty string' ' - printf "" >expect && - echo | git stripspace >actual && - test_cmp expect actual && + test_must_be_empty actual && echo "$sss" | git stripspace >actual && - test_cmp expect actual && + test_must_be_empty actual && echo "$sss$sss" | git stripspace >actual && - test_cmp expect actual && + test_must_be_empty actual && echo "$sss$sss$sss" | git stripspace >actual && - test_cmp expect actual && + test_must_be_empty actual && echo "$sss$sss$sss$sss" | git stripspace >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success \ @@ -350,19 +347,17 @@ test_expect_success \ test_expect_success \ 'spaces without newline at end should be replaced with empty string' ' - printf "" >expect && - printf "" | git stripspace >actual && - test_cmp expect actual && + test_must_be_empty actual && printf "$sss$sss" | git stripspace >actual && - test_cmp expect actual && + test_must_be_empty actual && printf "$sss$sss$sss" | git stripspace >actual && - test_cmp expect actual && + test_must_be_empty actual && printf "$sss$sss$sss$sss" | git stripspace >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success \ diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh index 04d474c84f..5b0560fa20 100755 --- a/t/t0040-parse-options.sh +++ b/t/t0040-parse-options.sh @@ -286,11 +286,9 @@ test_expect_success 'OPT_CALLBACK() and OPT_BIT() work' ' test_cmp expect output ' ->expect - test_expect_success 'OPT_CALLBACK() and callback errors work' ' test_must_fail test-parse-options --no-length >output 2>output.err && - test_i18ncmp expect output && + test_must_be_empty output && test_must_be_empty output.err ' diff --git a/t/t0051-windows-named-pipe.sh b/t/t0051-windows-named-pipe.sh new file mode 100755 index 0000000000..10ac92d225 --- /dev/null +++ b/t/t0051-windows-named-pipe.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +test_description='Windows named pipes' + +. ./test-lib.sh + +test_expect_success MINGW 'o_append write to named pipe' ' + GIT_TRACE="$(pwd)/expect" git status >/dev/null 2>&1 && + { test-tool windows-named-pipe t0051 >actual 2>&1 & } && + pid=$! && + sleep 1 && + GIT_TRACE=//./pipe/t0051 git status >/dev/null 2>warning && + wait $pid && + test_cmp expect actual +' + +test_done diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh index 21a8b53132..cd74c0a471 100755 --- a/t/t0060-path-utils.sh +++ b/t/t0060-path-utils.sh @@ -330,6 +330,9 @@ test_submodule_relative_url "(null)" "../foo" "../submodule" "../submodule" test_submodule_relative_url "(null)" "./foo/bar" "../submodule" "foo/submodule" test_submodule_relative_url "(null)" "./foo" "../submodule" "submodule" test_submodule_relative_url "(null)" "//somewhere else/repo" "../subrepo" "//somewhere else/subrepo" +test_submodule_relative_url "(null)" "//somewhere else/repo" "../../subrepo" "//subrepo" +test_submodule_relative_url "(null)" "//somewhere else/repo" "../../../subrepo" "/subrepo" +test_submodule_relative_url "(null)" "//somewhere else/repo" "../../../../subrepo" "subrepo" test_submodule_relative_url "(null)" "$(pwd)/subsuper_update_r" "../subsubsuper_update_r" "$(pwd)/subsubsuper_update_r" test_submodule_relative_url "(null)" "$(pwd)/super_update_r2" "../subsuper_update_r" "$(pwd)/subsuper_update_r" test_submodule_relative_url "(null)" "$(pwd)/." "../." "$(pwd)/." @@ -344,10 +347,20 @@ test_submodule_relative_url "(null)" "file:///tmp/repo" "../subrepo" "file:///tm test_submodule_relative_url "(null)" "foo/bar" "../submodule" "foo/submodule" test_submodule_relative_url "(null)" "foo" "../submodule" "submodule" test_submodule_relative_url "(null)" "helper:://hostname/repo" "../subrepo" "helper:://hostname/subrepo" +test_submodule_relative_url "(null)" "helper:://hostname/repo" "../../subrepo" "helper:://subrepo" +test_submodule_relative_url "(null)" "helper:://hostname/repo" "../../../subrepo" "helper::/subrepo" +test_submodule_relative_url "(null)" "helper:://hostname/repo" "../../../../subrepo" "helper::subrepo" +test_submodule_relative_url "(null)" "helper:://hostname/repo" "../../../../../subrepo" "helper:subrepo" +test_submodule_relative_url "(null)" "helper:://hostname/repo" "../../../../../../subrepo" ".:subrepo" test_submodule_relative_url "(null)" "ssh://hostname/repo" "../subrepo" "ssh://hostname/subrepo" +test_submodule_relative_url "(null)" "ssh://hostname/repo" "../../subrepo" "ssh://subrepo" +test_submodule_relative_url "(null)" "ssh://hostname/repo" "../../../subrepo" "ssh:/subrepo" +test_submodule_relative_url "(null)" "ssh://hostname/repo" "../../../../subrepo" "ssh:subrepo" +test_submodule_relative_url "(null)" "ssh://hostname/repo" "../../../../../subrepo" ".:subrepo" test_submodule_relative_url "(null)" "ssh://hostname:22/repo" "../subrepo" "ssh://hostname:22/subrepo" test_submodule_relative_url "(null)" "user@host:path/to/repo" "../subrepo" "user@host:path/to/subrepo" test_submodule_relative_url "(null)" "user@host:repo" "../subrepo" "user@host:subrepo" +test_submodule_relative_url "(null)" "user@host:repo" "../../subrepo" ".:subrepo" test_expect_success 'match .gitmodules' ' test-tool path-utils is_dotgitmodules \ diff --git a/t/t0061-run-command.sh b/t/t0061-run-command.sh index c887ed5b45..3e131c5325 100755 --- a/t/t0061-run-command.sh +++ b/t/t0061-run-command.sh @@ -11,7 +11,6 @@ cat >hello-script <<-EOF #!$SHELL_PATH cat hello-script EOF ->empty test_expect_success 'start_command reports ENOENT' ' test-tool run-command start-command-ENOENT ./does-not-exist @@ -23,7 +22,7 @@ test_expect_success 'run_command can run a command' ' test-tool run-command run-command ./hello.sh >actual 2>err && test_cmp hello-script actual && - test_cmp empty err + test_must_be_empty err ' test_expect_success !MINGW 'run_command can run a script without a #! line' ' @@ -34,7 +33,7 @@ test_expect_success !MINGW 'run_command can run a script without a #! line' ' test-tool run-command run-command ./hello >actual 2>err && test_cmp hello-script actual && - test_cmp empty err + test_must_be_empty err ' test_expect_success 'run_command does not try to execute a directory' ' @@ -47,7 +46,7 @@ test_expect_success 'run_command does not try to execute a directory' ' PATH=$PWD/bin1:$PWD/bin2:$PATH \ test-tool run-command run-command greet >actual 2>err && test_cmp bin2/greet actual && - test_cmp empty err + test_must_be_empty err ' test_expect_success POSIXPERM 'run_command passes over non-executable file' ' @@ -64,7 +63,7 @@ test_expect_success POSIXPERM 'run_command passes over non-executable file' ' PATH=$PWD/bin1:$PWD/bin2:$PATH \ test-tool run-command run-command greet >actual 2>err && test_cmp bin2/greet actual && - test_cmp empty err + test_must_be_empty err ' test_expect_success POSIXPERM 'run_command reports EACCES' ' diff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh index 28ea93f509..94fcb4a78e 100755 --- a/t/t0090-cache-tree.sh +++ b/t/t0090-cache-tree.sh @@ -161,6 +161,24 @@ test_expect_success PERL 'commit --interactive gives cache-tree on partial commi test_cache_tree ' +test_expect_success PERL 'commit -p with shrinking cache-tree' ' + mkdir -p deep/subdir && + echo content >deep/subdir/file && + git add deep && + git commit -m add && + git rm -r deep && + + before=$(wc -c <.git/index) && + git commit -m delete -p && + after=$(wc -c <.git/index) && + + # double check that the index shrank + test $before -gt $after && + + # and that our index was not corrupted + git fsck +' + test_expect_success 'commit in child dir has cache-tree' ' mkdir dir && >dir/child.t && @@ -239,7 +257,7 @@ test_expect_success 'no phantom error when switching trees' ' >newdir/one && git add newdir/one && git checkout 2>errors && - ! test -s errors + test_must_be_empty errors ' test_expect_success 'switching trees does not invalidate shared index' ' diff --git a/t/t0203-gettext-setlocale-sanity.sh b/t/t0203-gettext-setlocale-sanity.sh index 71b0d74b4d..0ce1f22eff 100755 --- a/t/t0203-gettext-setlocale-sanity.sh +++ b/t/t0203-gettext-setlocale-sanity.sh @@ -11,7 +11,7 @@ test_expect_success 'git show a ISO-8859-1 commit under C locale' ' . "$TEST_DIRECTORY"/t3901/8859-1.txt && test_commit "iso-c-commit" iso-under-c && git show >out 2>err && - ! test -s err && + test_must_be_empty err && grep -q "iso-c-commit" out ' @@ -19,7 +19,7 @@ test_expect_success GETTEXT_LOCALE 'git show a ISO-8859-1 commit under a UTF-8 l . "$TEST_DIRECTORY"/t3901/8859-1.txt && test_commit "iso-utf8-commit" iso-under-utf8 && LANGUAGE=is LC_ALL="$is_IS_locale" git show >out 2>err && - ! test -s err && + test_must_be_empty err && grep -q "iso-utf8-commit" out ' diff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh index 03bd31e9f2..82eaaea0f4 100755 --- a/t/t0300-credentials.sh +++ b/t/t0300-credentials.sh @@ -294,8 +294,7 @@ test_expect_success 'helpers can abort the process' ' -c credential.helper="!f() { echo quit=1; }; f" \ -c credential.helper="verbatim foo bar" \ credential fill >stdout && - >expect && - test_cmp expect stdout + test_must_be_empty stdout ' test_expect_success 'empty helper spec resets helper list' ' diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh index 4984ca583d..0ab02c337d 100755 --- a/t/t0410-partial-clone.sh +++ b/t/t0410-partial-clone.sh @@ -170,6 +170,18 @@ test_expect_success 'fetching of missing objects' ' git verify-pack --verbose "$IDX" | grep "$HASH" ' +test_expect_success 'fetching of missing objects works with ref-in-want enabled' ' + # ref-in-want requires protocol version 2 + git -C server config protocol.version 2 && + git -C server config uploadpack.allowrefinwant 1 && + git -C repo config protocol.version 2 && + + rm -rf repo/.git/objects/* && + rm -f trace && + GIT_TRACE_PACKET="$(pwd)/trace" git -C repo cat-file -p "$HASH" && + grep "git< fetch=.*ref-in-want" trace +' + test_expect_success 'rev-list stops traversal at missing and promised commit' ' rm -rf repo && test_create_repo repo && @@ -271,28 +283,91 @@ test_expect_success 'rev-list accepts missing and promised objects on command li git -C repo rev-list --exclude-promisor-objects --objects "$COMMIT" "$TREE" "$BLOB" ' -test_expect_success 'gc does not repack promisor objects' ' +test_expect_success 'gc repacks promisor objects separately from non-promisor objects' ' rm -rf repo && test_create_repo repo && - test_commit -C repo my_commit && + test_commit -C repo one && + test_commit -C repo two && - TREE_HASH=$(git -C repo rev-parse HEAD^{tree}) && - HASH=$(printf "$TREE_HASH\n" | pack_as_from_promisor) && + TREE_ONE=$(git -C repo rev-parse one^{tree}) && + printf "$TREE_ONE\n" | pack_as_from_promisor && + TREE_TWO=$(git -C repo rev-parse two^{tree}) && + printf "$TREE_TWO\n" | pack_as_from_promisor && git -C repo config core.repositoryformatversion 1 && git -C repo config extensions.partialclone "arbitrary string" && git -C repo gc && - # Ensure that the promisor packfile still exists, and remove it - test -e repo/.git/objects/pack/pack-$HASH.pack && - rm repo/.git/objects/pack/pack-$HASH.* && - - # Ensure that the single other pack contains the commit, but not the tree + # Ensure that exactly one promisor packfile exists, and that it + # contains the trees but not the commits + ls repo/.git/objects/pack/pack-*.promisor >promisorlist && + test_line_count = 1 promisorlist && + PROMISOR_PACKFILE=$(sed "s/.promisor/.pack/" <promisorlist) && + git verify-pack $PROMISOR_PACKFILE -v >out && + grep "$TREE_ONE" out && + grep "$TREE_TWO" out && + ! grep "$(git -C repo rev-parse one)" out && + ! grep "$(git -C repo rev-parse two)" out && + + # Remove the promisor packfile and associated files + rm $(sed "s/.promisor//" <promisorlist).* && + + # Ensure that the single other pack contains the commits, but not the + # trees ls repo/.git/objects/pack/pack-*.pack >packlist && test_line_count = 1 packlist && git verify-pack repo/.git/objects/pack/pack-*.pack -v >out && - grep "$(git -C repo rev-parse HEAD)" out && - ! grep "$TREE_HASH" out + grep "$(git -C repo rev-parse one)" out && + grep "$(git -C repo rev-parse two)" out && + ! grep "$TREE_ONE" out && + ! grep "$TREE_TWO" out +' + +test_expect_success 'gc does not repack promisor objects if there are none' ' + rm -rf repo && + test_create_repo repo && + test_commit -C repo one && + + git -C repo config core.repositoryformatversion 1 && + git -C repo config extensions.partialclone "arbitrary string" && + git -C repo gc && + + # Ensure that only one pack exists + ls repo/.git/objects/pack/pack-*.pack >packlist && + test_line_count = 1 packlist +' + +repack_and_check () { + rm -rf repo2 && + cp -r repo repo2 && + git -C repo2 repack $1 -d && + git -C repo2 fsck && + + git -C repo2 cat-file -e $2 && + git -C repo2 cat-file -e $3 +} + +test_expect_success 'repack -d does not irreversibly delete promisor objects' ' + rm -rf repo && + test_create_repo repo && + git -C repo config core.repositoryformatversion 1 && + git -C repo config extensions.partialclone "arbitrary string" && + + git -C repo commit --allow-empty -m one && + git -C repo commit --allow-empty -m two && + git -C repo commit --allow-empty -m three && + git -C repo commit --allow-empty -m four && + ONE=$(git -C repo rev-parse HEAD^^^) && + TWO=$(git -C repo rev-parse HEAD^^) && + THREE=$(git -C repo rev-parse HEAD^) && + + printf "$TWO\n" | pack_as_from_promisor && + printf "$THREE\n" | pack_as_from_promisor && + delete_object repo "$ONE" && + + repack_and_check -a "$TWO" "$THREE" && + repack_and_check -A "$TWO" "$THREE" && + repack_and_check -l "$TWO" "$THREE" ' test_expect_success 'gc stops traversal when a missing but promised object is reached' ' diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh index 13dd510b2e..7f19d591f2 100755 --- a/t/t1006-cat-file.sh +++ b/t/t1006-cat-file.sh @@ -550,8 +550,8 @@ test_expect_success 'git cat-file --batch --follow-symlink returns correct sha a test_expect_success 'cat-file --batch-all-objects shows all objects' ' # make new repos so we know the full set of objects; we will # also make sure that there are some packed and some loose - # objects, some referenced and some not, and that there are - # some available only via alternates. + # objects, some referenced and some not, some duplicates, and that + # there are some available only via alternates. git init all-one && ( cd all-one && @@ -567,10 +567,23 @@ test_expect_success 'cat-file --batch-all-objects shows all objects' ' cd all-two && echo local-unref | git hash-object -w --stdin ) >>expect.unsorted && + git -C all-two rev-parse HEAD:file | + git -C all-two pack-objects .git/objects/pack/pack && sort <expect.unsorted >expect && git -C all-two cat-file --batch-all-objects \ --batch-check="%(objectname)" >actual && test_cmp expect actual ' +# The only user-visible difference is that the objects are no longer sorted, +# and the resulting sort order is undefined. So we can only check that it +# produces the same objects as the ordered case, but that at least exercises +# the code. +test_expect_success 'cat-file --unordered works' ' + git -C all-two cat-file --batch-all-objects --unordered \ + --batch-check="%(objectname)" >actual.unsorted && + sort <actual.unsorted >actual && + test_cmp expect actual +' + test_done diff --git a/t/t1011-read-tree-sparse-checkout.sh b/t/t1011-read-tree-sparse-checkout.sh index 0c6f48f302..ba71b159ba 100755 --- a/t/t1011-read-tree-sparse-checkout.sh +++ b/t/t1011-read-tree-sparse-checkout.sh @@ -227,12 +227,11 @@ test_expect_success 'index removal and worktree narrowing at the same time' ' ' test_expect_success 'read-tree --reset removes outside worktree' ' - >empty && echo init.t >.git/info/sparse-checkout && git checkout -f top && git reset --hard removed && git ls-files sub/added >result && - test_cmp empty result + test_must_be_empty result ' test_expect_success 'print errors when failed to update worktree' ' diff --git a/t/t1015-read-index-unmerged.sh b/t/t1015-read-index-unmerged.sh new file mode 100755 index 0000000000..55d22da32c --- /dev/null +++ b/t/t1015-read-index-unmerged.sh @@ -0,0 +1,123 @@ +#!/bin/sh + +test_description='Test various callers of read_index_unmerged' +. ./test-lib.sh + +test_expect_success 'setup modify/delete + directory/file conflict' ' + test_create_repo df_plus_modify_delete && + ( + cd df_plus_modify_delete && + + test_write_lines a b c d e f g h >letters && + git add letters && + git commit -m initial && + + git checkout -b modify && + # Throw in letters.txt for sorting order fun + # ("letters.txt" sorts between "letters" and "letters/file") + echo i >>letters && + echo "version 2" >letters.txt && + git add letters letters.txt && + git commit -m modified && + + git checkout -b delete HEAD^ && + git rm letters && + mkdir letters && + >letters/file && + echo "version 1" >letters.txt && + git add letters letters.txt && + git commit -m deleted + ) +' + +test_expect_success 'read-tree --reset cleans unmerged entries' ' + test_when_finished "git -C df_plus_modify_delete clean -f" && + test_when_finished "git -C df_plus_modify_delete reset --hard" && + ( + cd df_plus_modify_delete && + + git checkout delete^0 && + test_must_fail git merge modify && + + git read-tree --reset HEAD && + git ls-files -u >conflicts && + test_must_be_empty conflicts + ) +' + +test_expect_success 'One reset --hard cleans unmerged entries' ' + test_when_finished "git -C df_plus_modify_delete clean -f" && + test_when_finished "git -C df_plus_modify_delete reset --hard" && + ( + cd df_plus_modify_delete && + + git checkout delete^0 && + test_must_fail git merge modify && + + git reset --hard && + test_path_is_missing .git/MERGE_HEAD && + git ls-files -u >conflicts && + test_must_be_empty conflicts + ) +' + +test_expect_success 'setup directory/file conflict + simple edit/edit' ' + test_create_repo df_plus_edit_edit && + ( + cd df_plus_edit_edit && + + test_seq 1 10 >numbers && + git add numbers && + git commit -m initial && + + git checkout -b d-edit && + mkdir foo && + echo content >foo/bar && + git add foo && + echo 11 >>numbers && + git add numbers && + git commit -m "directory and edit" && + + git checkout -b f-edit d-edit^1 && + echo content >foo && + git add foo && + echo eleven >>numbers && + git add numbers && + git commit -m "file and edit" + ) +' + +test_expect_success 'git merge --abort succeeds despite D/F conflict' ' + test_when_finished "git -C df_plus_edit_edit clean -f" && + test_when_finished "git -C df_plus_edit_edit reset --hard" && + ( + cd df_plus_edit_edit && + + git checkout f-edit^0 && + test_must_fail git merge d-edit^0 && + + git merge --abort && + test_path_is_missing .git/MERGE_HEAD && + git ls-files -u >conflicts && + test_must_be_empty conflicts + ) +' + +test_expect_success 'git am --skip succeeds despite D/F conflict' ' + test_when_finished "git -C df_plus_edit_edit clean -f" && + test_when_finished "git -C df_plus_edit_edit reset --hard" && + ( + cd df_plus_edit_edit && + + git checkout f-edit^0 && + git format-patch -1 d-edit && + test_must_fail git am -3 0001*.patch && + + git am --skip && + test_path_is_missing .git/rebase-apply && + git ls-files -u >conflicts && + test_must_be_empty conflicts + ) +' + +test_done diff --git a/t/t1300-config.sh b/t/t1300-config.sh index 24706ba412..cdf1fed5d1 100755 --- a/t/t1300-config.sh +++ b/t/t1300-config.sh @@ -346,12 +346,9 @@ test_expect_success 'working --list' ' git config --list > output && test_cmp expect output ' -cat > expect << EOF -EOF - test_expect_success '--list without repo produces empty output' ' git --git-dir=nonexistent config --list >output && - test_cmp expect output + test_must_be_empty output ' cat > expect << EOF @@ -1218,6 +1215,93 @@ test_expect_success 'last one wins: three level vars' ' test_cmp expect actual ' +test_expect_success 'old-fashioned settings are case insensitive' ' + test_when_finished "rm -f testConfig testConfig_expect testConfig_actual" && + + cat >testConfig_actual <<-EOF && + [V.A] + r = value1 + EOF + q_to_tab >testConfig_expect <<-EOF && + [V.A] + Qr = value2 + EOF + git config -f testConfig_actual "v.a.r" value2 && + test_cmp testConfig_expect testConfig_actual && + + cat >testConfig_actual <<-EOF && + [V.A] + r = value1 + EOF + q_to_tab >testConfig_expect <<-EOF && + [V.A] + QR = value2 + EOF + git config -f testConfig_actual "V.a.R" value2 && + test_cmp testConfig_expect testConfig_actual && + + cat >testConfig_actual <<-EOF && + [V.A] + r = value1 + EOF + q_to_tab >testConfig_expect <<-EOF && + [V.A] + r = value1 + Qr = value2 + EOF + git config -f testConfig_actual "V.A.r" value2 && + test_cmp testConfig_expect testConfig_actual && + + cat >testConfig_actual <<-EOF && + [V.A] + r = value1 + EOF + q_to_tab >testConfig_expect <<-EOF && + [V.A] + r = value1 + Qr = value2 + EOF + git config -f testConfig_actual "v.A.r" value2 && + test_cmp testConfig_expect testConfig_actual +' + +test_expect_success 'setting different case sensitive subsections ' ' + test_when_finished "rm -f testConfig testConfig_expect testConfig_actual" && + + cat >testConfig_actual <<-EOF && + [V "A"] + R = v1 + [K "E"] + Y = v1 + [a "b"] + c = v1 + [d "e"] + f = v1 + EOF + q_to_tab >testConfig_expect <<-EOF && + [V "A"] + Qr = v2 + [K "E"] + Qy = v2 + [a "b"] + Qc = v2 + [d "e"] + f = v1 + [d "E"] + Qf = v2 + EOF + # exact match + git config -f testConfig_actual a.b.c v2 && + # match section and subsection, key is cased differently. + git config -f testConfig_actual K.E.y v2 && + # section and key are matched case insensitive, but subsection needs + # to match; When writing out new values only the key is adjusted + git config -f testConfig_actual v.A.r v2 && + # subsection is not matched: + git config -f testConfig_actual d.E.f v2 && + test_cmp testConfig_expect testConfig_actual +' + for VAR in a .a a. a.0b a."b c". a."b c".0d do test_expect_success "git -c $VAR=VAL rejects invalid '$VAR'" ' diff --git a/t/t1305-config-include.sh b/t/t1305-config-include.sh index f035ee40a3..635918505d 100755 --- a/t/t1305-config-include.sh +++ b/t/t1305-config-include.sh @@ -310,7 +310,7 @@ test_expect_success 'include cycles are detected' ' cycle EOF test_must_fail git config --get-all test.value 2>stderr && - grep "exceeded maximum include depth" stderr + test_i18ngrep "exceeded maximum include depth" stderr ' test_done diff --git a/t/t1306-xdg-files.sh b/t/t1306-xdg-files.sh index 8b14ab187c..21e139a313 100755 --- a/t/t1306-xdg-files.sh +++ b/t/t1306-xdg-files.sh @@ -114,11 +114,10 @@ test_expect_success 'Exclusion in a non-XDG global ignore file' ' ' test_expect_success 'Checking XDG ignore file when HOME is unset' ' - >expected && (sane_unset HOME && git config --unset core.excludesfile && git ls-files --exclude-standard --ignored >actual) && - test_cmp expected actual + test_must_be_empty actual ' test_expect_success 'Checking attributes in the XDG attributes file' ' @@ -132,10 +131,9 @@ test_expect_success 'Checking attributes in the XDG attributes file' ' ' test_expect_success 'Checking XDG attributes when HOME is unset' ' - >expected && (sane_unset HOME && git check-attr -a f >actual) && - test_cmp expected actual + test_must_be_empty actual ' test_expect_success '$XDG_CONFIG_HOME overrides $HOME/.config/git/attributes' ' diff --git a/t/t1308-config-set.sh b/t/t1308-config-set.sh index 3e00d1af01..d0a2727b85 100755 --- a/t/t1308-config-set.sh +++ b/t/t1308-config-set.sh @@ -233,7 +233,7 @@ test_expect_success 'check line errors for malformed values' ' test_expect_success 'error on modifying repo config without repo' ' nongit test_must_fail git config a.b c 2>err && - grep "not in a git directory" err + test_i18ngrep "not in a git directory" err ' cmdline_config="'foo.bar=from-cmdline'" diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index e1fd0f0ca8..02493f14ba 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -390,7 +390,7 @@ test_expect_success 'Query "master@{2005-05-26 23:33:01}" (middle of history wit test_when_finished "rm -f o e" && git rev-parse --verify "master@{2005-05-26 23:33:01}" >o 2>e && test $B = $(cat o) && - test "warning: Log for ref $m has gap after $gd." = "$(cat e)" + test_i18ngrep -F "warning: log for ref $m has gap after $gd" e ' test_expect_success 'Query "master@{2005-05-26 23:38:00}" (middle of history)' ' test_when_finished "rm -f o e" && @@ -408,7 +408,7 @@ test_expect_success 'Query "master@{2005-05-28}" (past end of history)' ' test_when_finished "rm -f o e" && git rev-parse --verify "master@{2005-05-28}" >o 2>e && test $D = $(cat o) && - test "warning: Log for ref $m unexpectedly ended on $ld." = "$(cat e)" + test_i18ngrep -F "warning: log for ref $m unexpectedly ended on $ld" e ' rm -f .git/$m .git/logs/$m expect @@ -462,7 +462,7 @@ test_expect_success 'git cat-file blob master@{2005-05-26 23:42}:F (expect OTHER test_expect_success 'given old value for missing pseudoref, do not create' ' test_must_fail git update-ref PSEUDOREF $A $B 2>err && test_path_is_missing .git/PSEUDOREF && - grep "could not read ref" err + test_i18ngrep "could not read ref" err ' test_expect_success 'create pseudoref' ' @@ -483,7 +483,7 @@ test_expect_success 'overwrite pseudoref with correct old value' ' test_expect_success 'do not overwrite pseudoref with wrong old value' ' test_must_fail git update-ref PSEUDOREF $D $E 2>err && test $C = $(cat .git/PSEUDOREF) && - grep "unexpected object ID" err + test_i18ngrep "unexpected object ID" err ' test_expect_success 'delete pseudoref' ' @@ -495,7 +495,7 @@ test_expect_success 'do not delete pseudoref with wrong old value' ' git update-ref PSEUDOREF $A && test_must_fail git update-ref -d PSEUDOREF $B 2>err && test $A = $(cat .git/PSEUDOREF) && - grep "unexpected object ID" err + test_i18ngrep "unexpected object ID" err ' test_expect_success 'delete pseudoref with correct old value' ' @@ -512,7 +512,7 @@ test_expect_success 'do not overwrite pseudoref with old OID zero' ' test_when_finished git update-ref -d PSEUDOREF && test_must_fail git update-ref PSEUDOREF $B $Z 2>err && test $A = $(cat .git/PSEUDOREF) && - grep "already exists" err + test_i18ngrep "already exists" err ' # Test --stdin @@ -650,7 +650,7 @@ test_expect_success 'stdin fails with duplicate refs' ' create $a $m EOF test_must_fail git update-ref --stdin <stdin 2>err && - grep "fatal: multiple updates for ref '"'"'$a'"'"' not allowed." err + test_i18ngrep "fatal: multiple updates for ref '"'"'$a'"'"' not allowed" err ' test_expect_success 'stdin create ref works' ' @@ -807,6 +807,37 @@ test_expect_success 'stdin delete symref works option no-deref' ' test_cmp expect actual ' +test_expect_success 'stdin update symref works flag --no-deref' ' + git symbolic-ref TESTSYMREFONE $b && + git symbolic-ref TESTSYMREFTWO $b && + cat >stdin <<-EOF && + update TESTSYMREFONE $a $b + update TESTSYMREFTWO $a $b + EOF + git update-ref --no-deref --stdin <stdin && + git rev-parse TESTSYMREFONE TESTSYMREFTWO >expect && + git rev-parse $a $a >actual && + test_cmp expect actual && + git rev-parse $m~1 >expect && + git rev-parse $b >actual && + test_cmp expect actual +' + +test_expect_success 'stdin delete symref works flag --no-deref' ' + git symbolic-ref TESTSYMREFONE $b && + git symbolic-ref TESTSYMREFTWO $b && + cat >stdin <<-EOF && + delete TESTSYMREFONE $b + delete TESTSYMREFTWO $b + EOF + git update-ref --no-deref --stdin <stdin && + test_must_fail git rev-parse --verify -q TESTSYMREFONE && + test_must_fail git rev-parse --verify -q TESTSYMREFTWO && + git rev-parse $m~1 >expect && + git rev-parse $b >actual && + test_cmp expect actual +' + test_expect_success 'stdin delete ref works with right old value' ' echo "delete $b $m~1" >stdin && git update-ref --stdin <stdin && @@ -1052,7 +1083,7 @@ test_expect_success 'stdin -z fails option with unknown name' ' test_expect_success 'stdin -z fails with duplicate refs' ' printf $F "create $a" "$m" "create $b" "$m" "create $a" "$m" >stdin && test_must_fail git update-ref -z --stdin <stdin 2>err && - grep "fatal: multiple updates for ref '"'"'$a'"'"' not allowed." err + test_i18ngrep "fatal: multiple updates for ref '"'"'$a'"'"' not allowed" err ' test_expect_success 'stdin -z create ref works' ' @@ -1283,7 +1314,7 @@ test_expect_success 'fails with duplicate HEAD update' ' update HEAD $B EOF test_must_fail git update-ref --stdin <stdin 2>err && - grep "fatal: multiple updates for '\''HEAD'\'' (including one via its referent .refs/heads/target1.) are not allowed" err && + test_i18ngrep "fatal: multiple updates for '\''HEAD'\'' (including one via its referent .refs/heads/target1.) are not allowed" err && echo "refs/heads/target1" >expect && git symbolic-ref HEAD >actual && test_cmp expect actual && @@ -1300,7 +1331,7 @@ test_expect_success 'fails with duplicate ref update via symref' ' update refs/heads/symref2 $B EOF test_must_fail git update-ref --stdin <stdin 2>err && - grep "fatal: multiple updates for '\''refs/heads/target2'\'' (including one via symref .refs/heads/symref2.) are not allowed" err && + test_i18ngrep "fatal: multiple updates for '\''refs/heads/target2'\'' (including one via symref .refs/heads/symref2.) are not allowed" err && echo "refs/heads/target2" >expect && git symbolic-ref refs/heads/symref2 >actual && test_cmp expect actual && diff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh index 30354fd26c..5d955c3bff 100755 --- a/t/t1403-show-ref.sh +++ b/t/t1403-show-ref.sh @@ -26,26 +26,22 @@ test_expect_success 'show-ref' ' git show-ref refs/tags/A >actual && test_cmp expect actual && - >expect && - test_must_fail git show-ref D >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'show-ref -q' ' - >expect && - git show-ref -q A >actual && - test_cmp expect actual && + test_must_be_empty actual && git show-ref -q tags/A >actual && - test_cmp expect actual && + test_must_be_empty actual && git show-ref -q refs/tags/A >actual && - test_cmp expect actual && + test_must_be_empty actual && test_must_fail git show-ref -q D >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'show-ref --verify' ' @@ -54,32 +50,28 @@ test_expect_success 'show-ref --verify' ' git show-ref --verify refs/tags/A >actual && test_cmp expect actual && - >expect && - test_must_fail git show-ref --verify A >actual && - test_cmp expect actual && + test_must_be_empty actual && test_must_fail git show-ref --verify tags/A >actual && - test_cmp expect actual && + test_must_be_empty actual && test_must_fail git show-ref --verify D >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'show-ref --verify -q' ' - >expect && - git show-ref --verify -q refs/tags/A >actual && - test_cmp expect actual && + test_must_be_empty actual && test_must_fail git show-ref --verify -q A >actual && - test_cmp expect actual && + test_must_be_empty actual && test_must_fail git show-ref --verify -q tags/A >actual && - test_cmp expect actual && + test_must_be_empty actual && test_must_fail git show-ref --verify -q D >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'show-ref -d' ' @@ -113,19 +105,17 @@ test_expect_success 'show-ref -d' ' git show-ref -d --verify refs/heads/master >actual && test_cmp expect actual && - >expect && - test_must_fail git show-ref -d --verify master >actual && - test_cmp expect actual && + test_must_be_empty actual && test_must_fail git show-ref -d --verify heads/master >actual && - test_cmp expect actual && + test_must_be_empty actual && test_must_fail git show-ref --verify -d A C >actual && - test_cmp expect actual && + test_must_be_empty actual && test_must_fail git show-ref --verify -d tags/A tags/C >actual && - test_cmp expect actual + test_must_be_empty actual ' @@ -178,10 +168,8 @@ test_expect_success 'show-ref --verify HEAD' ' git show-ref --verify HEAD >actual && test_cmp expect actual && - >expect && - git show-ref --verify -q HEAD >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'show-ref --verify with dangling ref' ' diff --git a/t/t1404-update-ref-errors.sh b/t/t1404-update-ref-errors.sh index 3a887b5113..2a42a589a4 100755 --- a/t/t1404-update-ref-errors.sh +++ b/t/t1404-update-ref-errors.sh @@ -27,7 +27,7 @@ test_update_rejected () { fi && printf "create $prefix/%s $C\n" $create >input && test_must_fail git update-ref --stdin <input 2>output.err && - grep -F "$error" output.err && + test_i18ngrep -F "$error" output.err && git for-each-ref $prefix >actual && test_cmp unchanged actual } @@ -103,7 +103,7 @@ df_test() { printf "%s\n" "delete $delname" "create $addname $D" fi >commands && test_must_fail git update-ref --stdin <commands 2>output.err && - test_cmp expected-err output.err && + test_i18ncmp expected-err output.err && printf "%s\n" "$C $delref" >expected-refs && git for-each-ref --format="%(objectname) %(refname)" $prefix/r >actual-refs && test_cmp expected-refs actual-refs diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh index 8293131001..388b0611d8 100755 --- a/t/t1410-reflog.sh +++ b/t/t1410-reflog.sh @@ -290,9 +290,8 @@ test_expect_success 'stale dirs do not cause d/f conflicts (reflogs off)' ' # same as before, but we only create a reflog for "one" if # it already exists, which it does not git -c core.logallrefupdates=false branch one master && - : >expect && git log -g --format="%gd %gs" one >actual && - test_cmp expect actual + test_must_be_empty actual ' # Triggering the bug detected by this test requires a newline to fall diff --git a/t/t1411-reflog-show.sh b/t/t1411-reflog-show.sh index 4d62ceef9c..985daf1def 100755 --- a/t/t1411-reflog-show.sh +++ b/t/t1411-reflog-show.sh @@ -136,13 +136,12 @@ test_expect_success '--date magic does not override explicit @{0} syntax' ' test_cmp expect actual ' -: >expect test_expect_success 'empty reflog file' ' git branch empty && git reflog expire --expire=all refs/heads/empty && git log -g empty >actual && - test_cmp expect actual + test_must_be_empty actual ' # This guards against the alternative of showing the diffs vs. the diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index 91fd71444d..0f2dd26f74 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -16,8 +16,7 @@ test_expect_success setup ' git checkout HEAD^0 && test_commit B fileB two && git tag -d A B && - git reflog expire --expire=now --all && - >empty + git reflog expire --expire=now --all ' test_expect_success 'loose objects borrowed from alternate are not missing' ' @@ -29,12 +28,12 @@ test_expect_success 'loose objects borrowed from alternate are not missing' ' test_commit C fileC one && git fsck --no-dangling >../actual 2>&1 ) && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'HEAD is part of refs, valid objects appear valid' ' git fsck >actual 2>&1 && - test_cmp empty actual + test_must_be_empty actual ' # Corruption tests follow. Make sure to remove all traces of the @@ -346,12 +345,12 @@ test_expect_success 'tag with NUL in header' ' test_expect_success 'cleaned up' ' git fsck >actual 2>&1 && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'rev-list --verify-objects' ' git rev-list --verify-objects --all >/dev/null 2>out && - test_cmp empty out + test_must_be_empty out ' test_expect_success 'rev-list --verify-objects with bad sha1' ' @@ -372,7 +371,7 @@ test_expect_success 'rev-list --verify-objects with bad sha1' ' test_might_fail git rev-list --verify-objects refs/heads/bogus >/dev/null 2>out && cat out && - grep -q "error: sha1 mismatch 63ffffffffffffffffffffffffffffffffffffff" out + test_i18ngrep -q "error: sha1 mismatch 63ffffffffffffffffffffffffffffffffffffff" out ' test_expect_success 'force fsck to ignore double author' ' diff --git a/t/t1501-work-tree.sh b/t/t1501-work-tree.sh index afcdfafe45..3498d3d55e 100755 --- a/t/t1501-work-tree.sh +++ b/t/t1501-work-tree.sh @@ -41,7 +41,7 @@ test_expect_success 'setup: helper for testing rev-parse' ' # rev-parse --show-prefix should output # a single newline when at the top of the work tree, # but we test for that separately. - test -z "$4" && ! test -s actual.prefix || + test -z "$4" && test_must_be_empty actual.prefix || test_cmp expected.prefix actual.prefix fi } diff --git a/t/t1507-rev-parse-upstream.sh b/t/t1507-rev-parse-upstream.sh index 349f6e10af..fa3e499641 100755 --- a/t/t1507-rev-parse-upstream.sh +++ b/t/t1507-rev-parse-upstream.sh @@ -138,8 +138,7 @@ test_expect_success 'branch -d other@{u}' ' git checkout -t -b other master && git branch -d @{u} && git for-each-ref refs/heads/master >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'checkout other@{u}' ' diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh index 972bd9c785..9974457f56 100755 --- a/t/t1510-repo-setup.sh +++ b/t/t1510-repo-setup.sh @@ -234,14 +234,14 @@ test_expect_success '#0: nonbare repo, no explicit configuration' ' try_repo 0 unset unset unset "" unset \ .git "$here/0" "$here/0" "(null)" \ .git "$here/0" "$here/0" sub/ 2>message && - ! test -s message + test_must_be_empty message ' test_expect_success '#1: GIT_WORK_TREE without explicit GIT_DIR is accepted' ' try_repo 1 "$here" unset unset "" unset \ "$here/1/.git" "$here" "$here" 1/ \ "$here/1/.git" "$here" "$here" 1/sub/ 2>message && - ! test -s message + test_must_be_empty message ' test_expect_success '#2: worktree defaults to cwd with explicit GIT_DIR' ' @@ -268,7 +268,7 @@ test_expect_success '#4: core.worktree without GIT_DIR set is accepted' ' try_case 4 unset unset \ .git "$here/4/sub" "$here/4" "(null)" \ "$here/4/.git" "$here/4/sub" "$here/4/sub" "(null)" 2>message && - ! test -s message + test_must_be_empty message ' test_expect_success '#5: core.worktree + GIT_WORK_TREE is accepted' ' @@ -279,7 +279,7 @@ test_expect_success '#5: core.worktree + GIT_WORK_TREE is accepted' ' try_repo 5a .. unset "$here/5a" "" unset \ "$here/5a/.git" "$here" "$here" 5a/ \ "$here/5a/.git" "$here/5a" "$here/5a" sub/ && - ! test -s message + test_must_be_empty message ' test_expect_success '#6: setting GIT_DIR brings core.worktree to life' ' @@ -376,7 +376,7 @@ test_expect_success '#9: GIT_WORK_TREE accepted with gitfile' ' try_repo 9 wt unset unset gitfile unset \ "$here/9.git" "$here/9/wt" "$here/9" "(null)" \ "$here/9.git" "$here/9/sub/wt" "$here/9/sub" "(null)" 2>message && - ! test -s message + test_must_be_empty message ' test_expect_success '#10: GIT_DIR can point to gitfile' ' @@ -402,7 +402,7 @@ test_expect_success '#12: core.worktree with gitfile is accepted' ' try_repo 12 unset unset "$here/12" gitfile unset \ "$here/12.git" "$here/12" "$here/12" "(null)" \ "$here/12.git" "$here/12" "$here/12" sub/ 2>message && - ! test -s message + test_must_be_empty message ' test_expect_success '#13: core.worktree+GIT_WORK_TREE accepted (with gitfile)' ' @@ -410,7 +410,7 @@ test_expect_success '#13: core.worktree+GIT_WORK_TREE accepted (with gitfile)' ' try_repo 13 non-existent-too unset non-existent gitfile unset \ "$here/13.git" "$here/13/non-existent-too" "$here/13" "(null)" \ "$here/13.git" "$here/13/sub/non-existent-too" "$here/13/sub" "(null)" 2>message && - ! test -s message + test_must_be_empty message ' # case #14. @@ -565,7 +565,7 @@ test_expect_success '#17: GIT_WORK_TREE without explicit GIT_DIR is accepted (ba try_repo 17c "$here/17c" unset unset "" true \ .git "$here/17c" "$here/17c" "(null)" \ "$here/17c/.git" "$here/17c" "$here/17c" sub/ 2>message && - ! test -s message + test_must_be_empty message ' test_expect_success '#18: bare .git named by GIT_DIR has no worktree' ' @@ -594,7 +594,7 @@ test_expect_success '#20a: core.worktree without GIT_DIR accepted (inside .git)' "$here/20a/.git" "$here/20a" "$here/20a" .git/wt/ && try_case 20a/.git/wt/sub unset unset \ "$here/20a/.git" "$here/20a" "$here/20a" .git/wt/sub/ && - ! test -s message + test_must_be_empty message ' test_expect_success '#20b/c: core.worktree and core.bare conflict' ' @@ -626,7 +626,7 @@ test_expect_success '#21: setup, core.worktree warns before overriding core.bare export GIT_WORK_TREE && git status >/dev/null ) 2>message && - ! test -s message + test_must_be_empty message ' run_wt_tests 21 @@ -742,7 +742,7 @@ test_expect_success '#25: GIT_WORK_TREE accepted if GIT_DIR unset (bare gitfile try_repo 25 "$here/25" unset unset gitfile true \ "$here/25.git" "$here/25" "$here/25" "(null)" \ "$here/25.git" "$here/25" "$here/25" "sub/" 2>message && - ! test -s message + test_must_be_empty message ' test_expect_success '#26: bare repo has no worktree (GIT_DIR -> gitfile case)' ' @@ -780,7 +780,7 @@ test_expect_success '#29: setup' ' export GIT_WORK_TREE && git status ) 2>message && - ! test -s message + test_must_be_empty message ' run_wt_tests 29 gitfile diff --git a/t/t1600-index.sh b/t/t1600-index.sh index c4422312f4..42962ed7d4 100755 --- a/t/t1600-index.sh +++ b/t/t1600-index.sh @@ -41,8 +41,7 @@ test_expect_success 'no warning with bogus GIT_INDEX_VERSION and existing index' GIT_INDEX_VERSION=1 && export GIT_INDEX_VERSION && git add a 2>actual.err && - >expect.err && - test_i18ncmp expect.err actual.err + test_must_be_empty actual.err ) ' diff --git a/t/t1700-split-index.sh b/t/t1700-split-index.sh index 39133bcbc8..b3b4d83eaf 100755 --- a/t/t1700-split-index.sh +++ b/t/t1700-split-index.sh @@ -143,9 +143,7 @@ test_expect_success 'remove file not in base index' ' test_expect_success 'remove file in base index' ' git update-index --force-remove one && git ls-files --stage >ls-files.actual && - cat >ls-files.expect <<-EOF && - EOF - test_cmp ls-files.expect ls-files.actual && + test_must_be_empty ls-files.actual && test-tool dump-split-index .git/index | sed "/^own/d" >actual && cat >expect <<-EOF && diff --git a/t/t2013-checkout-submodule.sh b/t/t2013-checkout-submodule.sh index 6ef15738e4..8f86b5f4b2 100755 --- a/t/t2013-checkout-submodule.sh +++ b/t/t2013-checkout-submodule.sh @@ -44,7 +44,7 @@ test_expect_success '"checkout <submodule>" honors diff.ignoreSubmodules' ' git config diff.ignoreSubmodules dirty && echo x> submodule/untracked && git checkout HEAD >actual 2>&1 && - ! test -s actual + test_must_be_empty actual ' test_expect_success '"checkout <submodule>" honors submodule.*.ignore from .gitmodules' ' @@ -52,7 +52,7 @@ test_expect_success '"checkout <submodule>" honors submodule.*.ignore from .gitm git config -f .gitmodules submodule.submodule.path submodule && git config -f .gitmodules submodule.submodule.ignore untracked && git checkout HEAD >actual 2>&1 && - ! test -s actual + test_must_be_empty actual ' test_expect_success '"checkout <submodule>" honors submodule.*.ignore from .git/config' ' @@ -60,7 +60,7 @@ test_expect_success '"checkout <submodule>" honors submodule.*.ignore from .git/ git config submodule.submodule.path submodule && git config submodule.submodule.ignore all && git checkout HEAD >actual 2>&1 && - ! test -s actual + test_must_be_empty actual ' KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS=1 diff --git a/t/t2024-checkout-dwim.sh b/t/t2024-checkout-dwim.sh index 26dc3f1fc0..69b6774d10 100755 --- a/t/t2024-checkout-dwim.sh +++ b/t/t2024-checkout-dwim.sh @@ -24,9 +24,8 @@ test_branch_upstream () { } status_uno_is_clean () { - >status.expect && git status -uno --porcelain >status.actual && - test_cmp status.expect status.actual + test_must_be_empty status.actual } test_expect_success 'setup' ' @@ -87,8 +86,13 @@ test_expect_success 'checkout of branch from multiple remotes fails with advice' checkout foo 2>stderr && test_branch master && status_uno_is_clean && - test_i18ngrep ! "^hint: " stderr && - # Make sure the likes of checkout -p do not print this hint + test_i18ngrep ! "^hint: " stderr +' + +test_expect_success PERL 'checkout -p with multiple remotes does not print advice' ' + git checkout -B master && + test_might_fail git branch -D foo && + git checkout -p foo 2>stderr && test_i18ngrep ! "^hint: " stderr && status_uno_is_clean diff --git a/t/t2025-worktree-add.sh b/t/t2025-worktree-add.sh index be6e093142..07d292317c 100755 --- a/t/t2025-worktree-add.sh +++ b/t/t2025-worktree-add.sh @@ -252,6 +252,11 @@ test_expect_success 'add -B' ' test_cmp_rev master^ poodle ' +test_expect_success 'add --quiet' ' + git worktree add --quiet another-worktree master 2>actual && + test_must_be_empty actual +' + test_expect_success 'local clone from linked checkout' ' git clone --local here here-clone && ( cd here-clone && git fsck ) @@ -412,9 +417,8 @@ test_expect_success '"add" <path> <branch> dwims with checkout.defaultRemote' ' git fetch repo_upstream2 && test_must_fail git worktree add ../foo foo && git -c checkout.defaultRemote=repo_upstream worktree add ../foo foo && - >status.expect && git status -uno --porcelain >status.actual && - test_cmp status.expect status.actual + test_must_be_empty status.actual ) && ( cd foo && diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index 314c73c5a7..f764b7e3f5 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -88,9 +88,8 @@ test_expect_success 'non-qualified update in subdir updates from the root' ' echo even more >>sub2 && git add -u ) && - : >expect && git diff-files --name-only >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'replace a file with a symlink' ' diff --git a/t/t2202-add-addremove.sh b/t/t2202-add-addremove.sh index 17744e8c57..9ee659098c 100755 --- a/t/t2202-add-addremove.sh +++ b/t/t2202-add-addremove.sh @@ -48,8 +48,7 @@ test_expect_success 'Just "git add" is a no-op' ' >will-not-be-added && git add && git diff-index --name-status --cached HEAD >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ' test_done diff --git a/t/t2203-add-intent.sh b/t/t2203-add-intent.sh index e7a400b4c7..68e54d5c44 100755 --- a/t/t2203-add-intent.sh +++ b/t/t2203-add-intent.sh @@ -195,8 +195,7 @@ test_expect_success 'rename detection finds the right names' ' test_cmp expected.4 actual.4 && git diff --cached --stat >actual.5 && - : >expected.5 && - test_cmp expected.5 actual.5 + test_must_be_empty actual.5 ) ' @@ -241,8 +240,7 @@ test_expect_success 'diff-files/diff-cached shows ita as new/not-new files' ' echo " create mode 100644 new-ita" >expected && test_cmp expected actual && git diff --cached --summary >actual2 && - : >expected2 && - test_cmp expected2 actual2 + test_must_be_empty actual2 ' diff --git a/t/t2204-add-ignored.sh b/t/t2204-add-ignored.sh index 8340ac2f07..2e07365bbb 100755 --- a/t/t2204-add-ignored.sh +++ b/t/t2204-add-ignored.sh @@ -31,7 +31,7 @@ do rm -f .git/index && test_must_fail git add "$i" 2>err && git ls-files "$i" >out && - ! test -s out + test_must_be_empty out ' test_expect_success "complaints for ignored $i output" ' @@ -42,7 +42,7 @@ do rm -f .git/index && test_must_fail git add "$i" file 2>err && git ls-files "$i" >out && - ! test -s out + test_must_be_empty out ' test_expect_success "complaints for ignored $i with unignored file output" ' test_i18ngrep -e "Use -f if" err @@ -57,7 +57,7 @@ do cd dir && test_must_fail git add "$i" 2>err && git ls-files "$i" >out && - ! test -s out + test_must_be_empty out ) ' @@ -77,7 +77,7 @@ do cd sub && test_must_fail git add "$i" 2>err && git ls-files "$i" >out && - ! test -s out + test_must_be_empty out ) ' diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh index 3fc484e8c3..1ec7cb57c7 100755 --- a/t/t3001-ls-files-others-exclude.sh +++ b/t/t3001-ls-files-others-exclude.sh @@ -210,8 +210,7 @@ test_expect_success 'subdirectory ignore (toplevel)' ' cd top && git ls-files -o --exclude-standard ) >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'subdirectory ignore (l1/l2)' ' @@ -219,8 +218,7 @@ test_expect_success 'subdirectory ignore (l1/l2)' ' cd top/l1/l2 && git ls-files -o --exclude-standard ) >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'subdirectory ignore (l1)' ' @@ -228,8 +226,7 @@ test_expect_success 'subdirectory ignore (l1)' ' cd top/l1 && git ls-files -o --exclude-standard ) >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'show/hide empty ignored directory (setup)' ' @@ -251,8 +248,7 @@ test_expect_success 'hide empty ignored directory with --no-empty-directory' ' cd top && git ls-files -o -i --exclude l1 --directory --no-empty-directory ) >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'show/hide empty ignored sub-directory (setup)' ' @@ -277,14 +273,12 @@ test_expect_success 'hide empty ignored sub-directory with --no-empty-directory' cd top && git ls-files -o -i --exclude l1 --directory --no-empty-directory ) >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'pattern matches prefix completely' ' - : >expect && git ls-files -i -o --exclude "/three/a.3[abc]" >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'ls-files with "**" patterns' ' @@ -300,9 +294,8 @@ EOF test_expect_success 'ls-files with "**" patterns and no slashes' ' - : >expect && git ls-files -o -i --exclude "one**a.1" >actual && - test_cmp expect actual + test_must_be_empty actual ' test_done diff --git a/t/t3004-ls-files-basic.sh b/t/t3004-ls-files-basic.sh index 9c7adbdbe1..9fd5a1f188 100755 --- a/t/t3004-ls-files-basic.sh +++ b/t/t3004-ls-files-basic.sh @@ -8,16 +8,14 @@ command-line arguments. . ./test-lib.sh ->empty - test_expect_success 'ls-files in empty repository' ' git ls-files >actual && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'ls-files with nonexistent path' ' git ls-files doesnotexist >actual && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'ls-files with nonsense option' ' diff --git a/t/t3005-ls-files-relative.sh b/t/t3005-ls-files-relative.sh index 377869432e..209b4c7cd8 100755 --- a/t/t3005-ls-files-relative.sh +++ b/t/t3005-ls-files-relative.sh @@ -44,13 +44,13 @@ test_expect_success 'ls-files -c' ' cd top/sub && for f in ../y* do - echo "error: pathspec $sq$f$sq did not match any file(s) known to git." + echo "error: pathspec $sq$f$sq did not match any file(s) known to git" done >expect.err && echo "Did you forget to ${sq}git add${sq}?" >>expect.err && ls ../x* >expect.out && test_must_fail git ls-files -c --error-unmatch ../[xy]* >actual.out 2>actual.err && test_cmp expect.out actual.out && - test_cmp expect.err actual.err + test_i18ncmp expect.err actual.err ) ' @@ -59,13 +59,13 @@ test_expect_success 'ls-files -o' ' cd top/sub && for f in ../x* do - echo "error: pathspec $sq$f$sq did not match any file(s) known to git." + echo "error: pathspec $sq$f$sq did not match any file(s) known to git" done >expect.err && echo "Did you forget to ${sq}git add${sq}?" >>expect.err && ls ../y* >expect.out && test_must_fail git ls-files -o --error-unmatch ../[xy]* >actual.out 2>actual.err && test_cmp expect.out actual.out && - test_cmp expect.err actual.err + test_i18ncmp expect.err actual.err ) ' diff --git a/t/t3031-merge-criscross.sh b/t/t3031-merge-criscross.sh index e59b0a32d6..3824756a02 100755 --- a/t/t3031-merge-criscross.sh +++ b/t/t3031-merge-criscross.sh @@ -88,7 +88,7 @@ test_expect_success 'setup repo with criss-cross history' ' git branch G ' -test_expect_success 'recursive merge between F and G, causes segfault' ' +test_expect_success 'recursive merge between F and G does not cause segfault' ' git merge F ' diff --git a/t/t3035-merge-sparse.sh b/t/t3035-merge-sparse.sh index 0c0b433bd3..c4b4a94324 100755 --- a/t/t3035-merge-sparse.sh +++ b/t/t3035-merge-sparse.sh @@ -17,7 +17,6 @@ test_commit_this () { } test_expect_success 'setup' ' - : >empty && test_file checked-out init && test_file modify_delete modify_delete_init && test_commit_this init && @@ -38,7 +37,7 @@ test_expect_success 'reset --hard works after the conflict' ' test_expect_success 'is reset properly' ' git status --porcelain -- modify_delete >out && - test_cmp empty out && + test_must_be_empty out && test_path_is_missing modify_delete ' @@ -52,7 +51,7 @@ test_expect_success 'Merge abort works after the conflict' ' test_expect_success 'is aborted properly' ' git status --porcelain -- modify_delete >out && - test_cmp empty out && + test_must_be_empty out && test_path_is_missing modify_delete ' diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh index dce102130f..46aca0af10 100755 --- a/t/t3070-wildmatch.sh +++ b/t/t3070-wildmatch.sh @@ -101,8 +101,7 @@ match_with_ls_files() { match_stdout_stderr_cmp=" tr -d '\0' <actual.raw >actual && - >expect.err && - test_cmp expect.err actual.err && + test_must_be_empty actual.err && test_cmp expect actual" if test "$match_expect" = 'E' diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index dbca665da4..93f21ab078 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -1305,4 +1305,50 @@ test_expect_success 'tracking with unexpected .fetch refspec' ' ) ' +test_expect_success 'configured committerdate sort' ' + git init sort && + ( + cd sort && + git config branch.sort committerdate && + test_commit initial && + git checkout -b a && + test_commit a && + git checkout -b c && + test_commit c && + git checkout -b b && + test_commit b && + git branch >actual && + cat >expect <<-\EOF && + master + a + c + * b + EOF + test_cmp expect actual + ) +' + +test_expect_success 'option override configured sort' ' + ( + cd sort && + git config branch.sort committerdate && + git branch --sort=refname >actual && + cat >expect <<-\EOF && + a + * b + c + master + EOF + test_cmp expect actual + ) +' + +test_expect_success 'invalid sort parameter in configuration' ' + ( + cd sort && + git config branch.sort "v:notvalid" && + test_must_fail git branch + ) +' + test_done diff --git a/t/t3201-branch-contains.sh b/t/t3201-branch-contains.sh index 0ef1b6fdcc..0ea4fc4694 100755 --- a/t/t3201-branch-contains.sh +++ b/t/t3201-branch-contains.sh @@ -48,16 +48,14 @@ test_expect_success 'branch --contains master' ' test_expect_success 'branch --no-contains=master' ' git branch --no-contains=master >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'branch --no-contains master' ' git branch --no-contains master >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ' @@ -94,8 +92,7 @@ test_expect_success 'branch --contains with pattern implies --list' ' test_expect_success 'branch --no-contains with pattern implies --list' ' git branch --no-contains=master master >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ' @@ -123,8 +120,7 @@ test_expect_success 'branch --merged with pattern implies --list' ' test_expect_success 'side: branch --no-merged' ' git branch --no-merged >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ' @@ -152,8 +148,7 @@ test_expect_success 'master: branch --no-merged' ' test_expect_success 'branch --no-merged with pattern implies --list' ' git branch --no-merged=master master >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ' diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh new file mode 100755 index 0000000000..fb4c13a84a --- /dev/null +++ b/t/t3206-range-diff.sh @@ -0,0 +1,150 @@ +#!/bin/sh + +test_description='range-diff tests' + +. ./test-lib.sh + +# Note that because of the range-diff's heuristics, test_commit does more +# harm than good. We need some real history. + +test_expect_success 'setup' ' + git fast-import < "$TEST_DIRECTORY"/t3206/history.export +' + +test_expect_success 'simple A..B A..C (unmodified)' ' + git range-diff --no-color master..topic master..unmodified \ + >actual && + cat >expected <<-EOF && + 1: 4de457d = 1: 35b9b25 s/5/A/ + 2: fccce22 = 2: de345ab s/4/A/ + 3: 147e64e = 3: 9af6654 s/11/B/ + 4: a63e992 = 4: 2901f77 s/12/B/ + EOF + test_cmp expected actual +' + +test_expect_success 'simple B...C (unmodified)' ' + git range-diff --no-color topic...unmodified >actual && + # same "expected" as above + test_cmp expected actual +' + +test_expect_success 'simple A B C (unmodified)' ' + git range-diff --no-color master topic unmodified >actual && + # same "expected" as above + test_cmp expected actual +' + +test_expect_success 'trivial reordering' ' + git range-diff --no-color master topic reordered >actual && + cat >expected <<-EOF && + 1: 4de457d = 1: aca177a s/5/A/ + 3: 147e64e = 2: 14ad629 s/11/B/ + 4: a63e992 = 3: ee58208 s/12/B/ + 2: fccce22 = 4: 307b27a s/4/A/ + EOF + test_cmp expected actual +' + +test_expect_success 'removed a commit' ' + git range-diff --no-color master topic removed >actual && + cat >expected <<-EOF && + 1: 4de457d = 1: 7657159 s/5/A/ + 2: fccce22 < -: ------- s/4/A/ + 3: 147e64e = 2: 43d84d3 s/11/B/ + 4: a63e992 = 3: a740396 s/12/B/ + EOF + test_cmp expected actual +' + +test_expect_success 'added a commit' ' + git range-diff --no-color master topic added >actual && + cat >expected <<-EOF && + 1: 4de457d = 1: 2716022 s/5/A/ + 2: fccce22 = 2: b62accd s/4/A/ + -: ------- > 3: df46cfa s/6/A/ + 3: 147e64e = 4: 3e64548 s/11/B/ + 4: a63e992 = 5: 12b4063 s/12/B/ + EOF + test_cmp expected actual +' + +test_expect_success 'new base, A B C' ' + git range-diff --no-color master topic rebased >actual && + cat >expected <<-EOF && + 1: 4de457d = 1: cc9c443 s/5/A/ + 2: fccce22 = 2: c5d9641 s/4/A/ + 3: 147e64e = 3: 28cc2b6 s/11/B/ + 4: a63e992 = 4: 5628ab7 s/12/B/ + EOF + test_cmp expected actual +' + +test_expect_success 'new base, B...C' ' + # this syntax includes the commits from master! + git range-diff --no-color topic...rebased >actual && + cat >expected <<-EOF && + -: ------- > 1: a31b12e unrelated + 1: 4de457d = 2: cc9c443 s/5/A/ + 2: fccce22 = 3: c5d9641 s/4/A/ + 3: 147e64e = 4: 28cc2b6 s/11/B/ + 4: a63e992 = 5: 5628ab7 s/12/B/ + EOF + test_cmp expected actual +' + +test_expect_success 'changed commit' ' + git range-diff --no-color topic...changed >actual && + cat >expected <<-EOF && + 1: 4de457d = 1: a4b3333 s/5/A/ + 2: fccce22 = 2: f51d370 s/4/A/ + 3: 147e64e ! 3: 0559556 s/11/B/ + @@ -10,7 +10,7 @@ + 9 + 10 + -11 + -+B + ++BB + 12 + 13 + 14 + 4: a63e992 ! 4: d966c5c s/12/B/ + @@ -8,7 +8,7 @@ + @@ + 9 + 10 + - B + + BB + -12 + +B + 13 + EOF + test_cmp expected actual +' + +test_expect_success 'changed message' ' + git range-diff --no-color topic...changed-message >actual && + sed s/Z/\ /g >expected <<-EOF && + 1: 4de457d = 1: f686024 s/5/A/ + 2: fccce22 ! 2: 4ab067d s/4/A/ + @@ -2,6 +2,8 @@ + Z + Z s/4/A/ + Z + + Also a silly comment here! + + + Zdiff --git a/file b/file + Z--- a/file + Z+++ b/file + 3: 147e64e = 3: b9cb956 s/11/B/ + 4: a63e992 = 4: 8add5f1 s/12/B/ + EOF + test_cmp expected actual +' + +test_expect_success 'no commits on one side' ' + git commit --amend -m "new message" && + git range-diff master HEAD@{1} HEAD +' + +test_done diff --git a/t/t3206/history.export b/t/t3206/history.export new file mode 100644 index 0000000000..b8ffff0940 --- /dev/null +++ b/t/t3206/history.export @@ -0,0 +1,604 @@ +blob +mark :1 +data 51 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 + +reset refs/heads/removed +commit refs/heads/removed +mark :2 +author Thomas Rast <trast@inf.ethz.ch> 1374424921 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374484724 +0200 +data 8 +initial +M 100644 :1 file + +blob +mark :3 +data 51 +1 +2 +3 +4 +A +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 + +commit refs/heads/topic +mark :4 +author Thomas Rast <trast@inf.ethz.ch> 1374485014 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485014 +0200 +data 7 +s/5/A/ +from :2 +M 100644 :3 file + +blob +mark :5 +data 51 +1 +2 +3 +A +A +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 + +commit refs/heads/topic +mark :6 +author Thomas Rast <trast@inf.ethz.ch> 1374485024 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485024 +0200 +data 7 +s/4/A/ +from :4 +M 100644 :5 file + +blob +mark :7 +data 50 +1 +2 +3 +A +A +6 +7 +8 +9 +10 +B +12 +13 +14 +15 +16 +17 +18 +19 +20 + +commit refs/heads/topic +mark :8 +author Thomas Rast <trast@inf.ethz.ch> 1374485036 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485036 +0200 +data 8 +s/11/B/ +from :6 +M 100644 :7 file + +blob +mark :9 +data 49 +1 +2 +3 +A +A +6 +7 +8 +9 +10 +B +B +13 +14 +15 +16 +17 +18 +19 +20 + +commit refs/heads/topic +mark :10 +author Thomas Rast <trast@inf.ethz.ch> 1374485044 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485044 +0200 +data 8 +s/12/B/ +from :8 +M 100644 :9 file + +blob +mark :11 +data 10 +unrelated + +commit refs/heads/master +mark :12 +author Thomas Rast <trast@inf.ethz.ch> 1374485127 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485127 +0200 +data 10 +unrelated +from :2 +M 100644 :11 otherfile + +commit refs/heads/rebased +mark :13 +author Thomas Rast <trast@inf.ethz.ch> 1374485014 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485137 +0200 +data 7 +s/5/A/ +from :12 +M 100644 :3 file + +commit refs/heads/rebased +mark :14 +author Thomas Rast <trast@inf.ethz.ch> 1374485024 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485138 +0200 +data 7 +s/4/A/ +from :13 +M 100644 :5 file + +commit refs/heads/rebased +mark :15 +author Thomas Rast <trast@inf.ethz.ch> 1374485036 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485138 +0200 +data 8 +s/11/B/ +from :14 +M 100644 :7 file + +commit refs/heads/rebased +mark :16 +author Thomas Rast <trast@inf.ethz.ch> 1374485044 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485138 +0200 +data 8 +s/12/B/ +from :15 +M 100644 :9 file + +commit refs/heads/added +mark :17 +author Thomas Rast <trast@inf.ethz.ch> 1374485014 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485341 +0200 +data 7 +s/5/A/ +from :2 +M 100644 :3 file + +commit refs/heads/added +mark :18 +author Thomas Rast <trast@inf.ethz.ch> 1374485024 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485341 +0200 +data 7 +s/4/A/ +from :17 +M 100644 :5 file + +blob +mark :19 +data 51 +1 +2 +3 +A +A +A +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 + +commit refs/heads/added +mark :20 +author Thomas Rast <trast@inf.ethz.ch> 1374485186 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485341 +0200 +data 7 +s/6/A/ +from :18 +M 100644 :19 file + +blob +mark :21 +data 50 +1 +2 +3 +A +A +A +7 +8 +9 +10 +B +12 +13 +14 +15 +16 +17 +18 +19 +20 + +commit refs/heads/added +mark :22 +author Thomas Rast <trast@inf.ethz.ch> 1374485036 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485341 +0200 +data 8 +s/11/B/ +from :20 +M 100644 :21 file + +blob +mark :23 +data 49 +1 +2 +3 +A +A +A +7 +8 +9 +10 +B +B +13 +14 +15 +16 +17 +18 +19 +20 + +commit refs/heads/added +mark :24 +author Thomas Rast <trast@inf.ethz.ch> 1374485044 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485341 +0200 +data 8 +s/12/B/ +from :22 +M 100644 :23 file + +commit refs/heads/reordered +mark :25 +author Thomas Rast <trast@inf.ethz.ch> 1374485014 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485350 +0200 +data 7 +s/5/A/ +from :2 +M 100644 :3 file + +blob +mark :26 +data 50 +1 +2 +3 +4 +A +6 +7 +8 +9 +10 +B +12 +13 +14 +15 +16 +17 +18 +19 +20 + +commit refs/heads/reordered +mark :27 +author Thomas Rast <trast@inf.ethz.ch> 1374485036 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485350 +0200 +data 8 +s/11/B/ +from :25 +M 100644 :26 file + +blob +mark :28 +data 49 +1 +2 +3 +4 +A +6 +7 +8 +9 +10 +B +B +13 +14 +15 +16 +17 +18 +19 +20 + +commit refs/heads/reordered +mark :29 +author Thomas Rast <trast@inf.ethz.ch> 1374485044 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485350 +0200 +data 8 +s/12/B/ +from :27 +M 100644 :28 file + +commit refs/heads/reordered +mark :30 +author Thomas Rast <trast@inf.ethz.ch> 1374485024 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485350 +0200 +data 7 +s/4/A/ +from :29 +M 100644 :9 file + +commit refs/heads/changed +mark :31 +author Thomas Rast <trast@inf.ethz.ch> 1374485014 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485507 +0200 +data 7 +s/5/A/ +from :2 +M 100644 :3 file + +commit refs/heads/changed +mark :32 +author Thomas Rast <trast@inf.ethz.ch> 1374485024 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485507 +0200 +data 7 +s/4/A/ +from :31 +M 100644 :5 file + +blob +mark :33 +data 51 +1 +2 +3 +A +A +6 +7 +8 +9 +10 +BB +12 +13 +14 +15 +16 +17 +18 +19 +20 + +commit refs/heads/changed +mark :34 +author Thomas Rast <trast@inf.ethz.ch> 1374485036 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485507 +0200 +data 8 +s/11/B/ +from :32 +M 100644 :33 file + +blob +mark :35 +data 50 +1 +2 +3 +A +A +6 +7 +8 +9 +10 +BB +B +13 +14 +15 +16 +17 +18 +19 +20 + +commit refs/heads/changed +mark :36 +author Thomas Rast <trast@inf.ethz.ch> 1374485044 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485507 +0200 +data 8 +s/12/B/ +from :34 +M 100644 :35 file + +commit refs/heads/changed-message +mark :37 +author Thomas Rast <trast@inf.ethz.ch> 1374485014 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485530 +0200 +data 7 +s/5/A/ +from :2 +M 100644 :3 file + +commit refs/heads/changed-message +mark :38 +author Thomas Rast <trast@inf.ethz.ch> 1374485024 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485530 +0200 +data 35 +s/4/A/ + +Also a silly comment here! +from :37 +M 100644 :5 file + +commit refs/heads/changed-message +mark :39 +author Thomas Rast <trast@inf.ethz.ch> 1374485036 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485536 +0200 +data 8 +s/11/B/ +from :38 +M 100644 :7 file + +commit refs/heads/changed-message +mark :40 +author Thomas Rast <trast@inf.ethz.ch> 1374485044 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485536 +0200 +data 8 +s/12/B/ +from :39 +M 100644 :9 file + +commit refs/heads/unmodified +mark :41 +author Thomas Rast <trast@inf.ethz.ch> 1374485014 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485631 +0200 +data 7 +s/5/A/ +from :2 +M 100644 :3 file + +commit refs/heads/unmodified +mark :42 +author Thomas Rast <trast@inf.ethz.ch> 1374485024 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485631 +0200 +data 7 +s/4/A/ +from :41 +M 100644 :5 file + +commit refs/heads/unmodified +mark :43 +author Thomas Rast <trast@inf.ethz.ch> 1374485036 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485632 +0200 +data 8 +s/11/B/ +from :42 +M 100644 :7 file + +commit refs/heads/unmodified +mark :44 +author Thomas Rast <trast@inf.ethz.ch> 1374485044 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374485632 +0200 +data 8 +s/12/B/ +from :43 +M 100644 :9 file + +commit refs/heads/removed +mark :45 +author Thomas Rast <trast@inf.ethz.ch> 1374485014 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374486061 +0200 +data 7 +s/5/A/ +from :2 +M 100644 :3 file + +commit refs/heads/removed +mark :46 +author Thomas Rast <trast@inf.ethz.ch> 1374485036 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374486061 +0200 +data 8 +s/11/B/ +from :45 +M 100644 :26 file + +commit refs/heads/removed +mark :47 +author Thomas Rast <trast@inf.ethz.ch> 1374485044 +0200 +committer Thomas Rast <trast@inf.ethz.ch> 1374486061 +0200 +data 8 +s/12/B/ +from :46 +M 100644 :28 file + +reset refs/heads/removed +from :47 + diff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh index 724b4b9bc0..9ea5fa4fd2 100755 --- a/t/t3210-pack-refs.sh +++ b/t/t3210-pack-refs.sh @@ -127,7 +127,7 @@ test_expect_success 'explicit pack-refs with dangling packed reference' ' git reflog expire --expire=all --all && git prune --expire=all && git pack-refs --all 2>result && - test_cmp /dev/null result + test_must_be_empty result ' test_expect_success 'delete ref with dangling packed version' ' @@ -139,7 +139,7 @@ test_expect_success 'delete ref with dangling packed version' ' git reflog expire --expire=all --all && git prune --expire=all && git branch -d lamb 2>result && - test_cmp /dev/null result + test_must_be_empty result ' test_expect_success 'delete ref while another dangling packed ref' ' @@ -150,7 +150,7 @@ test_expect_success 'delete ref while another dangling packed ref' ' git reflog expire --expire=all --all && git prune --expire=all && git branch -d lamb 2>result && - test_cmp /dev/null result + test_must_be_empty result ' test_expect_success 'pack ref directly below refs/' ' @@ -186,7 +186,7 @@ test_expect_success 'notice d/f conflict with existing directory' ' test_expect_success 'existing directory reports concrete ref' ' test_must_fail git branch foo 2>stderr && - grep refs/heads/foo/bar/baz stderr + test_i18ngrep refs/heads/foo/bar/baz stderr ' test_expect_success 'notice d/f conflict with existing ref' ' diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh index ac62dc0e8f..84bbf88cf9 100755 --- a/t/t3301-notes.sh +++ b/t/t3301-notes.sh @@ -481,10 +481,8 @@ test_expect_success 'list specific note with "git notes list <object>"' ' ' test_expect_success 'listing non-existing notes fails' ' - cat >expect <<-EOF && - EOF test_must_fail git notes list HEAD >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'append to existing note with "git notes append"' ' diff --git a/t/t3308-notes-merge.sh b/t/t3308-notes-merge.sh index ab946a5153..d60588ec8f 100755 --- a/t/t3308-notes-merge.sh +++ b/t/t3308-notes-merge.sh @@ -183,7 +183,7 @@ test_expect_success 'merge empty notes ref (z => y)' ' git notes add -m "foo" && git notes remove && git notes >output_notes_z && - test_cmp /dev/null output_notes_z && + test_must_be_empty output_notes_z && # Do the merge (z => y) git config core.notesRef refs/notes/y && git notes merge z && diff --git a/t/t3310-notes-merge-manual-resolve.sh b/t/t3310-notes-merge-manual-resolve.sh index 9c1bf6eb3d..2dea846e25 100755 --- a/t/t3310-notes-merge-manual-resolve.sh +++ b/t/t3310-notes-merge-manual-resolve.sh @@ -337,7 +337,7 @@ EOF git notes merge --commit && # No .git/NOTES_MERGE_* files left test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && - test_cmp /dev/null output && + test_must_be_empty output && # Merge commit has pre-merge y and pre-merge z as parents test "$(git rev-parse refs/notes/m^1)" = "$(cat pre_merge_y)" && test "$(git rev-parse refs/notes/m^2)" = "$(cat pre_merge_z)" && @@ -399,7 +399,7 @@ test_expect_success 'abort notes merge' ' git notes merge --abort && # No .git/NOTES_MERGE_* files left test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && - test_cmp /dev/null output && + test_must_be_empty output && # m has not moved (still == y) test "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_y)" && # Verify that other notes refs has not changed (w, x, y and z) @@ -466,7 +466,7 @@ EOF git notes merge --commit && # No .git/NOTES_MERGE_* files left test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && - test_cmp /dev/null output && + test_must_be_empty output && # Merge commit has pre-merge y and pre-merge z as parents test "$(git rev-parse refs/notes/m^1)" = "$(cat pre_merge_y)" && test "$(git rev-parse refs/notes/m^2)" = "$(cat pre_merge_z)" && @@ -541,9 +541,9 @@ EOF test "$(git rev-parse refs/notes/y)" = "$(git rev-parse NOTES_MERGE_PARTIAL^1)" && test "$(git rev-parse refs/notes/m)" != "$(git rev-parse NOTES_MERGE_PARTIAL^1)" && # Mention refs/notes/m, and its current and expected value in output - grep -q "refs/notes/m" output && - grep -q "$(git rev-parse refs/notes/m)" output && - grep -q "$(git rev-parse NOTES_MERGE_PARTIAL^1)" output && + test_i18ngrep -q "refs/notes/m" output && + test_i18ngrep -q "$(git rev-parse refs/notes/m)" output && + test_i18ngrep -q "$(git rev-parse NOTES_MERGE_PARTIAL^1)" output && # Verify that other notes refs has not changed (w, x, y and z) verify_notes w && verify_notes x && @@ -555,7 +555,7 @@ test_expect_success 'resolve situation by aborting the notes merge' ' git notes merge --abort && # No .git/NOTES_MERGE_* files left test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && - test_cmp /dev/null output && + test_must_be_empty output && # m has not moved (still == w) test "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)" && # Verify that other notes refs has not changed (w, x, y and z) diff --git a/t/t3401-rebase-and-am-rename.sh b/t/t3401-rebase-and-am-rename.sh index 8f832957fc..e0b5111993 100755 --- a/t/t3401-rebase-and-am-rename.sh +++ b/t/t3401-rebase-and-am-rename.sh @@ -5,7 +5,7 @@ test_description='git rebase + directory rename tests' . ./test-lib.sh . "$TEST_DIRECTORY"/lib-rebase.sh -test_expect_success 'setup testcase' ' +test_expect_success 'setup testcase where directory rename should be detected' ' test_create_repo dir-rename && ( cd dir-rename && @@ -102,4 +102,112 @@ test_expect_failure 'am: directory rename detected' ' ) ' +test_expect_success 'setup testcase where directory rename should NOT be detected' ' + test_create_repo no-dir-rename && + ( + cd no-dir-rename && + + mkdir x && + test_seq 1 10 >x/a && + test_seq 11 20 >x/b && + test_seq 21 30 >x/c && + echo original >project_info && + git add x project_info && + git commit -m "Initial" && + + git branch O && + git branch A && + git branch B && + + git checkout A && + echo v2 >project_info && + git add project_info && + git commit -m "Modify project_info" && + + git checkout B && + mkdir y && + git mv x/c y/c && + echo v1 >project_info && + git add project_info && + git commit -m "Rename x/c to y/c, modify project_info" + ) +' + +test_expect_success 'rebase --interactive: NO directory rename' ' + test_when_finished "git -C no-dir-rename rebase --abort" && + ( + cd no-dir-rename && + + git checkout B^0 && + + set_fake_editor && + test_must_fail env FAKE_LINES="1" git rebase --interactive A && + + git ls-files -s >out && + test_line_count = 6 out && + + test_path_is_file x/a && + test_path_is_file x/b && + test_path_is_missing x/c + ) +' + +test_expect_success 'rebase (am): NO directory rename' ' + test_when_finished "git -C no-dir-rename rebase --abort" && + ( + cd no-dir-rename && + + git checkout B^0 && + + set_fake_editor && + test_must_fail git rebase A && + + git ls-files -s >out && + test_line_count = 6 out && + + test_path_is_file x/a && + test_path_is_file x/b && + test_path_is_missing x/c + ) +' + +test_expect_success 'rebase --merge: NO directory rename' ' + test_when_finished "git -C no-dir-rename rebase --abort" && + ( + cd no-dir-rename && + + git checkout B^0 && + + set_fake_editor && + test_must_fail git rebase --merge A && + + git ls-files -s >out && + test_line_count = 6 out && + + test_path_is_file x/a && + test_path_is_file x/b && + test_path_is_missing x/c + ) +' + +test_expect_success 'am: NO directory rename' ' + test_when_finished "git -C no-dir-rename am --abort" && + ( + cd no-dir-rename && + + git checkout A^0 && + + git format-patch -1 B && + + test_must_fail git am --3way 0001*.patch && + + git ls-files -s >out && + test_line_count = 6 out && + + test_path_is_file x/a && + test_path_is_file x/b && + test_path_is_missing x/c + ) +' + test_done diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 640fddc9c3..ff89b6341a 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -569,16 +569,15 @@ test_expect_success '--continue tries to commit, even for "edit"' ' ' test_expect_success 'aborted --continue does not squash commits after "edit"' ' - test_when_finished "git rebase --abort" && old=$(git rev-parse HEAD) && test_tick && set_fake_editor && FAKE_LINES="edit 1" git rebase -i HEAD^ && echo "edited again" > file7 && git add file7 && - echo all the things >>conflict && - test_must_fail git rebase --continue && - test $old = $(git rev-parse HEAD) + test_must_fail env FAKE_COMMIT_MESSAGE=" " git rebase --continue && + test $old = $(git rev-parse HEAD) && + git rebase --abort ' test_expect_success 'auto-amend only edited commits after "edit"' ' @@ -796,16 +795,15 @@ test_expect_success 'always cherry-pick with --no-ff' ' git tag original-no-ff-branch && set_fake_editor && git rebase -i --no-ff A && - touch empty && for p in 0 1 2 do test ! $(git rev-parse HEAD~$p) = $(git rev-parse original-no-ff-branch~$p) && git diff HEAD~$p original-no-ff-branch~$p > out && - test_cmp empty out + test_must_be_empty out done && test $(git rev-parse HEAD~3) = $(git rev-parse original-no-ff-branch~3) && git diff HEAD~3 original-no-ff-branch~3 > out && - test_cmp empty out + test_must_be_empty out ' test_expect_success 'set up commits with funny messages' ' @@ -1247,7 +1245,7 @@ rebase_setup_and_clean () { test_might_fail git branch -D $1 && test_might_fail git rebase --abort " && - git checkout -b $1 master + git checkout -b $1 ${2:-master} } test_expect_success 'drop' ' @@ -1424,4 +1422,24 @@ test_expect_success 'rebase -i --gpg-sign=<key-id> overrides commit.gpgSign' ' test_i18ngrep "$SQ-S\"S I Gner\"$SQ" err ' +test_expect_success 'valid author header after --root swap' ' + rebase_setup_and_clean author-header no-conflict-branch && + set_fake_editor && + git commit --amend --author="Au ${SQ}thor <author@example.com>" --no-edit && + git cat-file commit HEAD | grep ^author >expected && + FAKE_LINES="5 1" git rebase -i --root && + git cat-file commit HEAD^ | grep ^author >actual && + test_cmp expected actual +' + +test_expect_success 'valid author header when author contains single quote' ' + rebase_setup_and_clean author-header no-conflict-branch && + set_fake_editor && + git commit --amend --author="Au ${SQ}thor <author@example.com>" --no-edit && + git cat-file commit HEAD | grep ^author >expected && + FAKE_LINES="2" git rebase -i HEAD~2 && + git cat-file commit HEAD | grep ^author >actual && + test_cmp expected actual +' + test_done diff --git a/t/t3405-rebase-malformed.sh b/t/t3405-rebase-malformed.sh index da94dddc86..860e63e444 100755 --- a/t/t3405-rebase-malformed.sh +++ b/t/t3405-rebase-malformed.sh @@ -83,7 +83,7 @@ test_expect_success 'rebase -m commit with empty message' ' test_expect_success 'rebase -i commit with empty message' ' git checkout diff-in-message && set_fake_editor && - env FAKE_COMMIT_MESSAGE=" " FAKE_LINES="reword 1" \ + test_must_fail env FAKE_COMMIT_MESSAGE=" " FAKE_LINES="reword 1" \ git rebase -i HEAD^ ' diff --git a/t/t3415-rebase-autosquash.sh b/t/t3415-rebase-autosquash.sh index e364c12622..13f5688135 100755 --- a/t/t3415-rebase-autosquash.sh +++ b/t/t3415-rebase-autosquash.sh @@ -330,4 +330,23 @@ test_expect_success 'wrapped original subject' ' test $base = $parent ' +test_expect_success 'abort last squash' ' + test_when_finished "test_might_fail git rebase --abort" && + test_when_finished "git checkout master" && + + git checkout -b some-squashes && + git commit --allow-empty -m first && + git commit --allow-empty --squash HEAD && + git commit --allow-empty -m second && + git commit --allow-empty --squash HEAD && + + test_must_fail git -c core.editor="grep -q ^pick" \ + rebase -ki --autosquash HEAD~4 && + : do not finish the squash, but resolve it manually && + git commit --allow-empty --amend -m edited-first && + git rebase --skip && + git show >actual && + ! grep first actual +' + test_done diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh index 65ed7db159..25099d715c 100755 --- a/t/t3418-rebase-continue.sh +++ b/t/t3418-rebase-continue.sh @@ -160,13 +160,15 @@ test_expect_success '--skip after failed fixup cleans commit message' ' : The first squash was skipped, therefore: && git show HEAD >out && test_i18ngrep "# This is a combination of 2 commits" out && + test_i18ngrep "# This is the commit message #2:" out && (test_set_editor "$PWD/copy-editor.sh" && git rebase --skip) && git show HEAD >out && test_i18ngrep ! "# This is a combination" out && : Final squash failed, but there was still a squash && - test_i18ngrep "# This is a combination of 2 commits" .git/copy.txt + test_i18ngrep "# This is a combination of 2 commits" .git/copy.txt && + test_i18ngrep "# This is the commit message #2:" .git/copy.txt ' test_expect_success 'setup rerere database' ' diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh index e243700660..0c4eefec76 100755 --- a/t/t3420-rebase-autostash.sh +++ b/t/t3420-rebase-autostash.sh @@ -202,7 +202,7 @@ testrebase () { echo dirty >>file3 && test_must_fail git rebase$type related-onto-branch && test_path_is_file $dotest/autostash && - ! grep dirty file3 && + test_path_is_missing file3 && rm -rf $dotest && git reset --hard && git checkout feature-branch @@ -216,7 +216,7 @@ testrebase () { echo dirty >>file3 && test_must_fail git rebase$type related-onto-branch && test_path_is_file $dotest/autostash && - ! grep dirty file3 && + test_path_is_missing file3 && echo "conflicting-plus-goodbye" >file2 && git add file2 && git rebase --continue && @@ -233,7 +233,7 @@ testrebase () { echo dirty >>file3 && test_must_fail git rebase$type related-onto-branch && test_path_is_file $dotest/autostash && - ! grep dirty file3 && + test_path_is_missing file3 && git rebase --skip && test_path_is_missing $dotest/autostash && grep dirty file3 && @@ -248,7 +248,7 @@ testrebase () { echo dirty >>file3 && test_must_fail git rebase$type related-onto-branch && test_path_is_file $dotest/autostash && - ! grep dirty file3 && + test_path_is_missing file3 && git rebase --abort && test_path_is_missing $dotest/autostash && grep dirty file3 && diff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh index 9e62297274..aa7bfc88ec 100755 --- a/t/t3430-rebase-merges.sh +++ b/t/t3430-rebase-merges.sh @@ -13,8 +13,10 @@ Initial setup: -- B -- (first) / \ A - C - D - E - H (master) - \ / - F - G (second) + \ \ / + \ F - G (second) + \ + Conflicting-G ' . ./test-lib.sh . "$TEST_DIRECTORY"/lib-rebase.sh @@ -49,7 +51,9 @@ test_expect_success 'setup' ' git merge --no-commit G && test_tick && git commit -m H && - git tag -m H H + git tag -m H H && + git checkout A && + test_commit conflicting-G G.t ' test_expect_success 'create completely different structure' ' @@ -72,7 +76,7 @@ test_expect_success 'create completely different structure' ' EOF test_config sequence.editor \""$PWD"/replace-editor.sh\" && test_tick && - git rebase -i -r A && + git rebase -i -r A master && test_cmp_graph <<-\EOF * Merge the topic branch '\''onebranch'\'' |\ @@ -125,7 +129,7 @@ test_expect_success '`reset` refuses to overwrite untracked files' ' git rebase --abort ' -test_expect_success 'failed `merge` writes patch (may be rescheduled, too)' ' +test_expect_success 'failed `merge -C` writes patch (may be rescheduled, too)' ' test_when_finished "test_might_fail git rebase --abort" && git checkout -b conflicting-merge A && @@ -141,13 +145,25 @@ test_expect_success 'failed `merge` writes patch (may be rescheduled, too)' ' : fail because of merge conflict && rm G.t .git/rebase-merge/patch && - git reset --hard && - test_commit conflicting-G G.t not-G conflicting-G && + git reset --hard conflicting-G && test_must_fail git rebase --continue && ! grep "^merge -C .* G$" .git/rebase-merge/git-rebase-todo && test_path_is_file .git/rebase-merge/patch ' +SQ="'" +test_expect_success 'failed `merge <branch>` does not crash' ' + test_when_finished "test_might_fail git rebase --abort" && + git checkout conflicting-G && + + echo "merge G" >script-from-scratch && + test_config sequence.editor \""$PWD"/replace-editor.sh\" && + test_tick && + test_must_fail git rebase -ir HEAD && + ! grep "^merge G$" .git/rebase-merge/git-rebase-todo && + grep "^Merge branch ${SQ}G${SQ}$" .git/rebase-merge/message +' + test_expect_success 'with a branch tip that was cherry-picked already' ' git checkout -b already-upstream master && base="$(git rev-parse --verify HEAD)" && @@ -363,4 +379,21 @@ test_expect_success 'octopus merges' ' EOF ' +test_expect_success 'with --autosquash and --exec' ' + git checkout -b with-exec H && + echo Booh >B.t && + test_tick && + git commit --fixup B B.t && + write_script show.sh <<-\EOF && + subject="$(git show -s --format=%s HEAD)" + content="$(git diff HEAD^! | tail -n 1)" + echo "$subject: $content" + EOF + test_tick && + git rebase -ir --autosquash --exec ./show.sh A >actual && + grep "B: +Booh" actual && + grep "E: +Booh" actual && + grep "G: +G" actual +' + test_done diff --git a/t/t3505-cherry-pick-empty.sh b/t/t3505-cherry-pick-empty.sh index fbdc47cfbd..5f911bb529 100755 --- a/t/t3505-cherry-pick-empty.sh +++ b/t/t3505-cherry-pick-empty.sh @@ -11,17 +11,14 @@ test_expect_success setup ' test_tick && git commit -m "first" && - git checkout -b empty-branch && - test_tick && - git commit --allow-empty -m "empty" && - + git checkout -b empty-message-branch && echo third >> file1 && git add file1 && test_tick && git commit --allow-empty-message -m "" && git checkout master && - git checkout -b empty-branch2 && + git checkout -b empty-change-branch && test_tick && git commit --allow-empty -m "empty" @@ -29,7 +26,7 @@ test_expect_success setup ' test_expect_success 'cherry-pick an empty commit' ' git checkout master && - test_expect_code 1 git cherry-pick empty-branch^ + test_expect_code 1 git cherry-pick empty-change-branch ' test_expect_success 'index lockfile was removed' ' @@ -37,8 +34,9 @@ test_expect_success 'index lockfile was removed' ' ' test_expect_success 'cherry-pick a commit with an empty message' ' + test_when_finished "git reset --hard empty-message-branch~1" && git checkout master && - test_expect_code 1 git cherry-pick empty-branch + git cherry-pick empty-message-branch ' test_expect_success 'index lockfile was removed' ' @@ -47,7 +45,7 @@ test_expect_success 'index lockfile was removed' ' test_expect_success 'cherry-pick a commit with an empty message with --allow-empty-message' ' git checkout -f master && - git cherry-pick --allow-empty-message empty-branch + git cherry-pick --allow-empty-message empty-message-branch ' test_expect_success 'cherry pick an empty non-ff commit without --allow-empty' ' @@ -55,12 +53,12 @@ test_expect_success 'cherry pick an empty non-ff commit without --allow-empty' ' echo fourth >>file2 && git add file2 && git commit -m "fourth" && - test_must_fail git cherry-pick empty-branch2 + test_must_fail git cherry-pick empty-change-branch ' test_expect_success 'cherry pick an empty non-ff commit with --allow-empty' ' git checkout master && - git cherry-pick --allow-empty empty-branch2 + git cherry-pick --allow-empty empty-change-branch ' test_expect_success 'cherry pick with --keep-redundant-commits' ' diff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh index 7c5ad08626..0db166152a 100755 --- a/t/t3507-cherry-pick-conflict.sh +++ b/t/t3507-cherry-pick-conflict.sh @@ -392,4 +392,17 @@ test_expect_success 'commit --amend -s places the sign-off at the right place' ' test_cmp expect actual ' +test_expect_success 'cherry-pick preserves sparse-checkout' ' + pristine_detach initial && + test_config core.sparseCheckout true && + test_when_finished " + echo \"/*\" >.git/info/sparse-checkout + git read-tree --reset -u HEAD + rm .git/info/sparse-checkout" && + echo /unrelated >.git/info/sparse-checkout && + git read-tree --reset -u HEAD && + test_must_fail git cherry-pick -Xours picked>actual && + test_i18ngrep ! "Changes not staged for commit:" actual +' + test_done diff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh index 3505b6aa14..c84eeefdc9 100755 --- a/t/t3510-cherry-pick-sequence.sh +++ b/t/t3510-cherry-pick-sequence.sh @@ -103,7 +103,8 @@ test_expect_success '--quit cleans up sequencer state' ' pristine_detach initial && test_expect_code 1 git cherry-pick base..picked && git cherry-pick --quit && - test_path_is_missing .git/sequencer + test_path_is_missing .git/sequencer && + test_path_is_missing .git/CHERRY_PICK_HEAD ' test_expect_success '--quit keeps HEAD and conflicted index intact' ' @@ -132,6 +133,7 @@ test_expect_success '--abort to cancel multiple cherry-pick' ' test_expect_code 1 git cherry-pick base..anotherpick && git cherry-pick --abort && test_path_is_missing .git/sequencer && + test_path_is_missing .git/CHERRY_PICK_HEAD && test_cmp_rev initial HEAD && git update-index --refresh && git diff-index --exit-code HEAD @@ -142,6 +144,7 @@ test_expect_success '--abort to cancel single cherry-pick' ' test_expect_code 1 git cherry-pick picked && git cherry-pick --abort && test_path_is_missing .git/sequencer && + test_path_is_missing .git/CHERRY_PICK_HEAD && test_cmp_rev initial HEAD && git update-index --refresh && git diff-index --exit-code HEAD @@ -162,6 +165,7 @@ test_expect_success 'cherry-pick --abort to cancel multiple revert' ' test_expect_code 1 git revert base..picked && git cherry-pick --abort && test_path_is_missing .git/sequencer && + test_path_is_missing .git/CHERRY_PICK_HEAD && test_cmp_rev anotherpick HEAD && git update-index --refresh && git diff-index --exit-code HEAD @@ -239,6 +243,7 @@ test_expect_success '--abort after last commit in sequence' ' test_expect_code 1 git cherry-pick base..picked && git cherry-pick --abort && test_path_is_missing .git/sequencer && + test_path_is_missing .git/CHERRY_PICK_HEAD && test_cmp_rev initial HEAD && git update-index --refresh && git diff-index --exit-code HEAD diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index b8fbdefcdc..04e5d42bd3 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -14,15 +14,13 @@ test_expect_success \ git add -- foo bar baz 'space embedded' -q && git commit -m 'add normal files'" -if test_have_prereq !MINGW && touch -- 'tab embedded' 'newline -embedded' 2>/dev/null -then - test_set_prereq FUNNYNAMES -else +if test_have_prereq !FUNNYNAMES; then say 'Your filesystem does not allow tabs in filenames.' fi test_expect_success FUNNYNAMES 'add files with funny names' " + touch -- 'tab embedded' 'newline +embedded' && git add -- 'tab embedded' 'newline embedded' && git commit -m 'add files with tabs and newlines' @@ -382,7 +380,7 @@ test_expect_success 'rm does not complain when no .gitmodules file is found' ' git submodule update && git rm .gitmodules && git rm submod >actual 2>actual.err && - ! test -s actual.err && + test_must_be_empty actual.err && ! test -d submod && ! test -f submod/.git && git status -s -uno >actual && @@ -400,7 +398,7 @@ test_expect_success 'rm will error out on a modified .gitmodules file unless sta git diff-files --quiet -- submod && git add .gitmodules && git rm submod >actual 2>actual.err && - ! test -s actual.err && + test_must_be_empty actual.err && ! test -d submod && ! test -f submod/.git && git status -s -uno >actual && @@ -694,7 +692,7 @@ test_expect_success 'checking out a commit after submodule removal needs manual test_cmp expected actual && rm -rf submod && git status -s -uno --ignore-submodules=none >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'rm of d/f when d has become a non-directory' ' diff --git a/t/t3700-add.sh b/t/t3700-add.sh index 618750167a..37729ba258 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -188,9 +188,8 @@ test_expect_success 'git add --refresh with pathspec' ' git add foo bar baz && H=$(git rev-parse :foo) && git rm -f foo && echo "100644 $H 3 foo" | git update-index --index-info && test-tool chmtime -60 bar baz && - >expect && git add --refresh bar >actual && - test_cmp expect actual && + test_must_be_empty actual && git diff-files --name-only >actual && ! grep bar actual&& diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 1f871d3cca..6450bc6698 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -724,7 +724,7 @@ test_expect_success 'store updates stash ref and reflog' ' git add bazzy && STASH_ID=$(git stash create) && git reset --hard && - ! grep quux bazzy && + test_path_is_missing bazzy && git stash store -m quuxery $STASH_ID && test $(git rev-parse stash) = $STASH_ID && git reflog --format=%H stash| grep $STASH_ID && diff --git a/t/t3910-mac-os-precompose.sh b/t/t3910-mac-os-precompose.sh index 26dd5b7f78..54ce19e353 100755 --- a/t/t3910-mac-os-precompose.sh +++ b/t/t3910-mac-os-precompose.sh @@ -187,9 +187,8 @@ test_expect_failure 'handle existing decomposed filenames' ' echo content >"verbatim.$Adiarnfd" && git -c core.precomposeunicode=false add "verbatim.$Adiarnfd" && git commit -m "existing decomposed file" && - >expect && git ls-files --exclude-standard -o "verbatim*" >untracked && - test_cmp expect untracked + test_must_be_empty untracked ' # Test if the global core.precomposeunicode stops autosensing diff --git a/t/t4010-diff-pathspec.sh b/t/t4010-diff-pathspec.sh index b7f25071cf..281f8fad0c 100755 --- a/t/t4010-diff-pathspec.sh +++ b/t/t4010-diff-pathspec.sh @@ -74,8 +74,7 @@ test_expect_success 'diff-tree pathspec' ' tree2=$(git write-tree) && echo "$tree2" && git diff-tree -r --name-only $tree $tree2 -- pa path1/a >current && - >expected && - test_cmp expected current + test_must_be_empty current ' test_expect_success 'diff-tree with wildcard shows dir also matches' ' diff --git a/t/t4011-diff-symlink.sh b/t/t4011-diff-symlink.sh index 108c012a3a..5ae19b987d 100755 --- a/t/t4011-diff-symlink.sh +++ b/t/t4011-diff-symlink.sh @@ -126,7 +126,7 @@ test_expect_success SYMLINKS 'diff symlinks with non-existing targets' ' ln -s take\ over brain && test_must_fail git diff --no-index pinky brain >output 2>output.err && grep narf output && - ! test -s output.err + test_must_be_empty output.err ' test_expect_success SYMLINKS 'setup symlinks with attributes' ' diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index f8d853595b..73f7038253 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -140,7 +140,7 @@ do expect="$TEST_DIRECTORY/t4013/diff.$test" actual="$pfx-diff.$test" - test_expect_success "git $cmd # magic is ${magic:-"(not used)"}" ' + test_expect_success "git $cmd # magic is ${magic:-(not used)}" ' { echo "$ git $cmd" case "$magic" in diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh index e2dc1895ba..a9fb226c5a 100755 --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@ -93,21 +93,20 @@ test_expect_success 'another test, without options' ' git diff >out && test_cmp expect out && - >expect && git diff -w >out && - test_cmp expect out && + test_must_be_empty out && git diff -w -b >out && - test_cmp expect out && + test_must_be_empty out && git diff -w --ignore-space-at-eol >out && - test_cmp expect out && + test_must_be_empty out && git diff -w -b --ignore-space-at-eol >out && - test_cmp expect out && + test_must_be_empty out && git diff -w --ignore-cr-at-eol >out && - test_cmp expect out && + test_must_be_empty out && tr "Q_" "\015 " <<-\EOF >expect && diff --git a/x b/x @@ -182,8 +181,7 @@ test_expect_success 'ignore-blank-lines: only new lines' ' test_seq 5 | sed "/3/i\\ " >x && git diff --ignore-blank-lines >out && - >expect && - test_cmp expect out + test_must_be_empty out ' test_expect_success 'ignore-blank-lines: only new lines with space' ' @@ -192,8 +190,7 @@ test_expect_success 'ignore-blank-lines: only new lines with space' ' test_seq 5 | sed "/3/i\\ " >x && git diff -w --ignore-blank-lines >out && - >expect && - test_cmp expect out + test_must_be_empty out ' test_expect_success 'ignore-blank-lines: after change' ' @@ -779,8 +776,6 @@ test_expect_success 'checkdiff allows new blank lines' ' git diff --check ' -cat <<EOF >expect -EOF test_expect_success 'whitespace-only changes not reported' ' git reset --hard && echo >x "hello world" && @@ -788,7 +783,7 @@ test_expect_success 'whitespace-only changes not reported' ' git commit -m "hello 1" && echo >x "hello world" && git diff -b >actual && - test_cmp expect actual + test_must_be_empty actual ' cat <<EOF >expect diff --git a/t/t4019-diff-wserror.sh b/t/t4019-diff-wserror.sh index a5019759bc..c6135c7548 100755 --- a/t/t4019-diff-wserror.sh +++ b/t/t4019-diff-wserror.sh @@ -260,7 +260,7 @@ test_expect_success 'trailing empty lines (2)' ' echo "F -whitespace" >.gitattributes && git diff --check >output && - ! test -s output + test_must_be_empty output ' diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh index 6304130ad4..9aa8e2b39b 100755 --- a/t/t4027-diff-submodule.sh +++ b/t/t4027-diff-submodule.sh @@ -104,19 +104,19 @@ test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)' expect_from_to >expect.body $subprev $subprev-dirty && test_cmp expect.body actual.body && git diff --ignore-submodules HEAD >actual2 && - ! test -s actual2 && + test_must_be_empty actual2 && git diff --ignore-submodules=untracked HEAD >actual3 && sed -e "1,/^@@/d" actual3 >actual3.body && expect_from_to >expect.body $subprev $subprev-dirty && test_cmp expect.body actual3.body && git diff --ignore-submodules=dirty HEAD >actual4 && - ! test -s actual4 + test_must_be_empty actual4 ' test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match) [.gitmodules]' ' git config diff.ignoreSubmodules dirty && git diff HEAD >actual && - ! test -s actual && + test_must_be_empty actual && git config --add -f .gitmodules submodule.subname.ignore none && git config --add -f .gitmodules submodule.subname.path sub && git diff HEAD >actual && @@ -126,7 +126,7 @@ test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match) git config -f .gitmodules submodule.subname.ignore all && git config -f .gitmodules submodule.subname.path sub && git diff HEAD >actual2 && - ! test -s actual2 && + test_must_be_empty actual2 && git config -f .gitmodules submodule.subname.ignore untracked && git diff HEAD >actual3 && sed -e "1,/^@@/d" actual3 >actual3.body && @@ -134,7 +134,7 @@ test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match) test_cmp expect.body actual3.body && git config -f .gitmodules submodule.subname.ignore dirty && git diff HEAD >actual4 && - ! test -s actual4 && + test_must_be_empty actual4 && git config submodule.subname.ignore none && git config submodule.subname.path sub && git diff HEAD >actual && @@ -172,24 +172,24 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)' expect_from_to >expect.body $subprev $subprev-dirty && test_cmp expect.body actual.body && git diff --ignore-submodules=all HEAD >actual2 && - ! test -s actual2 && + test_must_be_empty actual2 && git diff --ignore-submodules=untracked HEAD >actual3 && - ! test -s actual3 && + test_must_be_empty actual3 && git diff --ignore-submodules=dirty HEAD >actual4 && - ! test -s actual4 + test_must_be_empty actual4 ' test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match) [.gitmodules]' ' git config --add -f .gitmodules submodule.subname.ignore all && git config --add -f .gitmodules submodule.subname.path sub && git diff HEAD >actual2 && - ! test -s actual2 && + test_must_be_empty actual2 && git config -f .gitmodules submodule.subname.ignore untracked && git diff HEAD >actual3 && - ! test -s actual3 && + test_must_be_empty actual3 && git config -f .gitmodules submodule.subname.ignore dirty && git diff HEAD >actual4 && - ! test -s actual4 && + test_must_be_empty actual4 && git config submodule.subname.ignore none && git config submodule.subname.path sub && git diff HEAD >actual && @@ -211,7 +211,7 @@ test_expect_success 'git diff between submodule commits' ' expect_from_to >expect.body $subtip $subprev && test_cmp expect.body actual.body && git diff --ignore-submodules HEAD^..HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'git diff between submodule commits [.gitmodules]' ' @@ -227,7 +227,7 @@ test_expect_success 'git diff between submodule commits [.gitmodules]' ' test_cmp expect.body actual.body && git config -f .gitmodules submodule.subname.ignore all && git diff HEAD^..HEAD >actual && - ! test -s actual && + test_must_be_empty actual && git config submodule.subname.ignore dirty && git config submodule.subname.path sub && git diff HEAD^..HEAD >actual && @@ -239,10 +239,9 @@ test_expect_success 'git diff between submodule commits [.gitmodules]' ' ' test_expect_success 'git diff (empty submodule dir)' ' - : >empty && rm -rf sub/* sub/.git && git diff > actual.empty && - test_cmp empty actual.empty + test_must_be_empty actual.empty ' test_expect_success 'conflicted submodule setup' ' diff --git a/t/t4039-diff-assume-unchanged.sh b/t/t4039-diff-assume-unchanged.sh index 23c0e357a7..53ac44b0f0 100755 --- a/t/t4039-diff-assume-unchanged.sh +++ b/t/t4039-diff-assume-unchanged.sh @@ -34,9 +34,8 @@ test_expect_success POSIXPERM 'find-copies-harder is not confused by mode bits' git add exec && git commit -m exec && git update-index --assume-unchanged exec && - >expect && git diff-files --find-copies-harder -- exec >actual && - test_cmp expect actual + test_must_be_empty actual ' test_done diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh index 4e3499ef84..619bf97098 100755 --- a/t/t4041-diff-submodule-option.sh +++ b/t/t4041-diff-submodule-option.sh @@ -257,9 +257,7 @@ test_expect_success 'typechanged submodule(blob->submodule)' ' commit_file sm1 && test_expect_success 'submodule is up to date' ' git diff-index -p --submodule=log HEAD >actual && - cat >expected <<-EOF && - EOF - test_cmp expected actual + test_must_be_empty actual ' test_expect_success 'submodule contains untracked content' ' @@ -273,17 +271,17 @@ test_expect_success 'submodule contains untracked content' ' test_expect_success 'submodule contains untracked content (untracked ignored)' ' git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'submodule contains untracked content (dirty ignored)' ' git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'submodule contains untracked content (all ignored)' ' git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'submodule contains untracked and modifed content' ' @@ -308,13 +306,13 @@ test_expect_success 'submodule contains untracked and modifed content (untracked test_expect_success 'submodule contains untracked and modifed content (dirty ignored)' ' echo new > sm1/foo6 && git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'submodule contains untracked and modifed content (all ignored)' ' echo new > sm1/foo6 && git diff-index -p --ignore-submodules --submodule=log HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'submodule contains modifed content' ' @@ -368,7 +366,7 @@ test_expect_success 'modified submodule contains untracked content (dirty ignore test_expect_success 'modified submodule contains untracked content (all ignored)' ' git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'modified submodule contains untracked and modifed content' ' @@ -407,7 +405,7 @@ test_expect_success 'modified submodule contains untracked and modifed content ( test_expect_success 'modified submodule contains untracked and modifed content (all ignored)' ' echo modification >> sm1/foo6 && git diff-index -p --ignore-submodules --submodule=log HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'modified submodule contains modifed content' ' diff --git a/t/t4047-diff-dirstat.sh b/t/t4047-diff-dirstat.sh index 447a8ffa3a..7fec2cb9cd 100755 --- a/t/t4047-diff-dirstat.sh +++ b/t/t4047-diff-dirstat.sh @@ -940,7 +940,7 @@ test_expect_success 'diff.dirstat=0,lines' ' test_expect_success '--dirstat=future_param,lines,0 should fail loudly' ' test_must_fail git diff --dirstat=future_param,lines,0 HEAD^..HEAD >actual_diff_dirstat 2>actual_error && test_debug "cat actual_error" && - test_cmp /dev/null actual_diff_dirstat && + test_must_be_empty actual_diff_dirstat && test_i18ngrep -q "future_param" actual_error && test_i18ngrep -q "\--dirstat" actual_error ' @@ -948,7 +948,7 @@ test_expect_success '--dirstat=future_param,lines,0 should fail loudly' ' test_expect_success '--dirstat=dummy1,cumulative,2dummy should report both unrecognized parameters' ' test_must_fail git diff --dirstat=dummy1,cumulative,2dummy HEAD^..HEAD >actual_diff_dirstat 2>actual_error && test_debug "cat actual_error" && - test_cmp /dev/null actual_diff_dirstat && + test_must_be_empty actual_diff_dirstat && test_i18ngrep -q "dummy1" actual_error && test_i18ngrep -q "2dummy" actual_error && test_i18ngrep -q "\--dirstat" actual_error diff --git a/t/t4051-diff-function-context.sh b/t/t4051-diff-function-context.sh index 2d76a971c4..4838a1df8b 100755 --- a/t/t4051-diff-function-context.sh +++ b/t/t4051-diff-function-context.sh @@ -174,7 +174,7 @@ test_expect_success ' context does not include other functions' ' ' test_expect_success ' context does not include preceding empty lines' ' - test "$(first_context_line <long_common_tail.diff.diff)" != " " + test "$(first_context_line <long_common_tail.diff)" != " " ' check_diff changed_hello_appended 'changed function plus appended function' diff --git a/t/t4060-diff-submodule-option-diff-format.sh b/t/t4060-diff-submodule-option-diff-format.sh index 0eba4620f0..9dcb69df5c 100755 --- a/t/t4060-diff-submodule-option-diff-format.sh +++ b/t/t4060-diff-submodule-option-diff-format.sh @@ -392,9 +392,7 @@ test_expect_success 'typechanged submodule(blob->submodule)' ' commit_file sm1 && test_expect_success 'submodule is up to date' ' git diff-index -p --submodule=diff HEAD >actual && - cat >expected <<-EOF && - EOF - test_cmp expected actual + test_must_be_empty actual ' test_expect_success 'submodule contains untracked content' ' @@ -408,17 +406,17 @@ test_expect_success 'submodule contains untracked content' ' test_expect_success 'submodule contains untracked content (untracked ignored)' ' git diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'submodule contains untracked content (dirty ignored)' ' git diff-index -p --ignore-submodules=dirty --submodule=diff HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'submodule contains untracked content (all ignored)' ' git diff-index -p --ignore-submodules=all --submodule=diff HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'submodule contains untracked and modified content' ' @@ -458,13 +456,13 @@ test_expect_success 'submodule contains untracked and modified content (untracke test_expect_success 'submodule contains untracked and modified content (dirty ignored)' ' echo new > sm1/foo6 && git diff-index -p --ignore-submodules=dirty --submodule=diff HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'submodule contains untracked and modified content (all ignored)' ' echo new > sm1/foo6 && git diff-index -p --ignore-submodules --submodule=diff HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'submodule contains modified content' ' @@ -549,7 +547,7 @@ test_expect_success 'modified submodule contains untracked content (dirty ignore test_expect_success 'modified submodule contains untracked content (all ignored)' ' git diff-index -p --ignore-submodules=all --submodule=diff HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'modified submodule contains untracked and modified content' ' @@ -609,7 +607,7 @@ test_expect_success 'modified submodule contains untracked and modified content test_expect_success 'modified submodule contains untracked and modified content (all ignored)' ' echo modification >> sm1/foo6 && git diff-index -p --ignore-submodules --submodule=diff HEAD >actual && - ! test -s actual + test_must_be_empty actual ' # NOT OK diff --git a/t/t4116-apply-reverse.sh b/t/t4116-apply-reverse.sh index ce8567f496..b99e65c086 100755 --- a/t/t4116-apply-reverse.sh +++ b/t/t4116-apply-reverse.sh @@ -42,7 +42,7 @@ test_expect_success 'apply in reverse' ' git reset --hard second && git apply --reverse --binary --index patch && git diff >diff && - test_cmp /dev/null diff + test_must_be_empty diff ' diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh index 4fc27c51f7..7e32237a2a 100755 --- a/t/t4124-apply-ws-rule.sh +++ b/t/t4124-apply-ws-rule.sh @@ -100,7 +100,7 @@ test_expect_success 'whitespace=warn, default rule' ' test_expect_success 'whitespace=error-all, default rule' ' test_must_fail apply_patch --whitespace=error-all && - ! test -s target + test_must_be_empty target ' diff --git a/t/t4132-apply-removal.sh b/t/t4132-apply-removal.sh index a2bc1cd37d..fec1d6fa51 100755 --- a/t/t4132-apply-removal.sh +++ b/t/t4132-apply-removal.sh @@ -49,8 +49,7 @@ test_expect_success setup ' sed -e "s/TS0/$timeGMT/" -e "s/TS1/$epocGMT/" <d >removeGMT.patch && sed -e "s/TS0/$timeWest/" -e "s/TS1/$epocWest2/" <d >removeWest2.patch && - echo something >something && - >empty + echo something >something ' for patch in *.patch @@ -81,7 +80,7 @@ do git add file && git apply --index $patch && test -f file && - test_cmp empty file + test_must_be_empty file ;; remove*) # must remove the file diff --git a/t/t4135-apply-weird-filenames.sh b/t/t4135-apply-weird-filenames.sh index c7c688fcc4..6bc3fb97a7 100755 --- a/t/t4135-apply-weird-filenames.sh +++ b/t/t4135-apply-weird-filenames.sh @@ -15,15 +15,7 @@ test_expect_success 'setup' ' git checkout -f preimage^0 && git read-tree -u --reset HEAD && git update-index --refresh - } && - - test_when_finished "rm -f \"tab embedded.txt\"" && - test_when_finished "rm -f '\''\"quoteembedded\".txt'\''" && - if test_have_prereq !MINGW && - touch -- "tab embedded.txt" '\''"quoteembedded".txt'\'' - then - test_set_prereq FUNNYNAMES - fi + } ' try_filename() { diff --git a/t/t4150-am.sh b/t/t4150-am.sh index 1ebc587f8f..55b577d919 100755 --- a/t/t4150-am.sh +++ b/t/t4150-am.sh @@ -69,13 +69,15 @@ test_expect_success 'setup: messages' ' EOF - cat >scissors-msg <<-\EOF && - Test git-am with scissors line + cat >msg-without-scissors-line <<-\EOF && + Test that git-am --scissors cuts at the scissors line This line should be included in the commit message. EOF - cat - scissors-msg >no-scissors-msg <<-\EOF && + printf "Subject: " >subject-prefix && + + cat - subject-prefix msg-without-scissors-line >msg-with-scissors-line <<-\EOF && This line should not be included in the commit message with --scissors enabled. - - >8 - - remove everything above this line - - >8 - - @@ -148,18 +150,17 @@ test_expect_success setup ' } >patch1-hg.eml && - echo scissors-file >scissors-file && - git add scissors-file && - git commit -F scissors-msg && - git tag scissors && - git format-patch --stdout scissors^ >scissors-patch.eml && + echo file >file && + git add file && + git commit -F msg-without-scissors-line && + git tag expected-for-scissors && git reset --hard HEAD^ && - echo no-scissors-file >no-scissors-file && - git add no-scissors-file && - git commit -F no-scissors-msg && - git tag no-scissors && - git format-patch --stdout no-scissors^ >no-scissors-patch.eml && + echo file >file && + git add file && + git commit -F msg-with-scissors-line && + git tag expected-for-no-scissors && + git format-patch --stdout expected-for-no-scissors^ >patch-with-scissors-line.eml && git reset --hard HEAD^ && sed -n -e "3,\$p" msg >file && @@ -416,10 +417,10 @@ test_expect_success 'am --scissors cuts the message at the scissors line' ' rm -fr .git/rebase-apply && git reset --hard && git checkout second && - git am --scissors scissors-patch.eml && + git am --scissors patch-with-scissors-line.eml && test_path_is_missing .git/rebase-apply && - git diff --exit-code scissors && - test_cmp_rev scissors HEAD + git diff --exit-code expected-for-scissors && + test_cmp_rev expected-for-scissors HEAD ' test_expect_success 'am --no-scissors overrides mailinfo.scissors' ' @@ -427,10 +428,10 @@ test_expect_success 'am --no-scissors overrides mailinfo.scissors' ' git reset --hard && git checkout second && test_config mailinfo.scissors true && - git am --no-scissors no-scissors-patch.eml && + git am --no-scissors patch-with-scissors-line.eml && test_path_is_missing .git/rebase-apply && - git diff --exit-code no-scissors && - test_cmp_rev no-scissors HEAD + git diff --exit-code expected-for-no-scissors && + test_cmp_rev expected-for-no-scissors HEAD ' test_expect_success 'setup: new author and committer' ' @@ -651,7 +652,7 @@ test_expect_success 'am -3 -q is quiet' ' git checkout -f lorem2 && git reset base3way --hard && git am -3 -q lorem-move.patch >output.out 2>&1 && - ! test -s output.out + test_must_be_empty output.out ' test_expect_success 'am pauses on conflict' ' @@ -874,7 +875,7 @@ test_expect_success 'am -q is quiet' ' git checkout first && test_tick && git am -q <patch1 >output.out 2>&1 && - ! test -s output.out + test_must_be_empty output.out ' test_expect_success 'am empty-file does not infloop' ' diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh index 8417e5a4b1..313222d0d6 100755 --- a/t/t4200-rerere.sh +++ b/t/t4200-rerere.sh @@ -267,8 +267,7 @@ rerere_gc_custom_expiry_test () { git -c "gc.rerereresolved=$right_now" \ -c "gc.rerereunresolved=$right_now" rerere gc && find .git/rr-cache -type f | sort >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ' } @@ -536,9 +535,8 @@ test_expect_success 'multiple identical conflicts' ' # We resolved file1 and file2 git rerere && - >expect && git rerere remaining >actual && - test_cmp expect actual && + test_must_be_empty actual && # We must have recorded both of them count_pre_post 2 2 && @@ -548,9 +546,8 @@ test_expect_success 'multiple identical conflicts' ' test_must_fail git merge six.1 && git rerere && - >expect && git rerere remaining >actual && - test_cmp expect actual && + test_must_be_empty actual && concat_insert short 6.1 6.2 >file1.expect && concat_insert long 6.1 6.2 >file2.expect && @@ -580,4 +577,33 @@ test_expect_success 'multiple identical conflicts' ' count_pre_post 0 0 ' +test_expect_success 'setup simple stage 1 handling' ' + test_create_repo stage_1_handling && + ( + cd stage_1_handling && + + test_seq 1 10 >original && + git add original && + git commit -m original && + + git checkout -b A master && + git mv original A && + git commit -m "rename to A" && + + git checkout -b B master && + git mv original B && + git commit -m "rename to B" + ) +' + +test_expect_success 'test simple stage 1 handling' ' + ( + cd stage_1_handling && + + git config rerere.enabled true && + git checkout A^0 && + test_must_fail git merge B^0 + ) +' + test_done diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh index 58c2773676..d3a7ce6bbb 100755 --- a/t/t4201-shortlog.sh +++ b/t/t4201-shortlog.sh @@ -192,7 +192,7 @@ test_expect_success 'shortlog with revision pseudo options' ' test_expect_success 'shortlog with --output=<file>' ' git shortlog --output=shortlog -1 master >output && - test ! -s output && + test_must_be_empty output && test_line_count = 3 shortlog ' diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 25b1f8cc73..153a506151 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -340,10 +340,9 @@ test_expect_success PCRE 'log -F -E --perl-regexp --grep=<pcre> uses PCRE' ' ' test_expect_success 'log with grep.patternType configuration' ' - >expect && git -c grep.patterntype=fixed \ log -1 --pretty=tformat:%s --grep=s.c.nd >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'log with grep.patternType configuration and command line' ' @@ -1556,12 +1555,28 @@ test_expect_success GPG 'setup signed branch' ' git commit -S -m signed_commit ' +test_expect_success GPGSM 'setup signed branch x509' ' + test_when_finished "git reset --hard && git checkout master" && + git checkout -b signed-x509 master && + echo foo >foo && + git add foo && + test_config gpg.format x509 && + test_config user.signingkey $GIT_COMMITTER_EMAIL && + git commit -S -m signed_commit +' + test_expect_success GPG 'log --graph --show-signature' ' git log --graph --show-signature -n1 signed >actual && grep "^| gpg: Signature made" actual && grep "^| gpg: Good signature" actual ' +test_expect_success GPGSM 'log --graph --show-signature x509' ' + git log --graph --show-signature -n1 signed-x509 >actual && + grep "^| gpgsm: Signature made" actual && + grep "^| gpgsm: Good signature" actual +' + test_expect_success GPG 'log --graph --show-signature for merged tag' ' test_when_finished "git reset --hard && git checkout master" && git checkout -b plain master && @@ -1581,6 +1596,27 @@ test_expect_success GPG 'log --graph --show-signature for merged tag' ' grep "^| | gpg: Good signature" actual ' +test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' ' + test_when_finished "git reset --hard && git checkout master" && + test_config gpg.format x509 && + test_config user.signingkey $GIT_COMMITTER_EMAIL && + git checkout -b plain-x509 master && + echo aaa >bar && + git add bar && + git commit -m bar_commit && + git checkout -b tagged-x509 master && + echo bbb >baz && + git add baz && + git commit -m baz_commit && + git tag -s -m signed_tag_msg signed_tag_x509 && + git checkout plain-x509 && + git merge --no-ff -m msg signed_tag_x509 && + git log --graph --show-signature -n1 plain-x509 >actual && + grep "^|\\\ merged tag" actual && + grep "^| | gpgsm: Signature made" actual && + grep "^| | gpgsm: Good signature" actual +' + test_expect_success GPG '--no-show-signature overrides --show-signature' ' git log -1 --show-signature --no-show-signature signed >actual && ! grep "^gpg:" actual @@ -1625,9 +1661,8 @@ test_expect_success 'log diagnoses bogus HEAD' ' ' test_expect_success 'log does not default to HEAD when rev input is given' ' - >expect && git log --branches=does-not-exist >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'set up --source tests' ' diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh index 0dd8b65d7c..43b1522ea2 100755 --- a/t/t4203-mailmap.sh +++ b/t/t4203-mailmap.sh @@ -461,11 +461,9 @@ test_expect_success 'Grep author with log.mailmap' ' test_cmp expect actual ' ->expect - test_expect_success 'Only grep replaced author with --use-mailmap' ' git log --use-mailmap --author "<cto@coompany.xx>" >actual && - test_cmp expect actual + test_must_be_empty actual ' # git blame diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index 2052cadb11..978a8a66ff 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -598,4 +598,27 @@ test_expect_success ':only and :unfold work together' ' test_cmp expect actual ' +test_expect_success 'trailer parsing not fooled by --- line' ' + git commit --allow-empty -F - <<-\EOF && + this is the subject + + This is the body. The message has a "---" line which would confuse a + message+patch parser. But here we know we have only a commit message, + so we get it right. + + trailer: wrong + --- + This is more body. + + trailer: right + EOF + + { + echo "trailer: right" && + echo + } >expect && + git log --no-walk --format="%(trailers)" >actual && + test_cmp expect actual +' + test_done diff --git a/t/t4210-log-i18n.sh b/t/t4210-log-i18n.sh index e585fe6129..7c519436ef 100755 --- a/t/t4210-log-i18n.sh +++ b/t/t4210-log-i18n.sh @@ -44,15 +44,13 @@ test_expect_success !MINGW 'log --grep searches in log output encoding (latin1)' ' test_expect_success !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 + test_must_be_empty actual ' test_expect_success 'log --grep does not find non-reencoded values (latin1)' ' - >expect && git log --encoding=ISO-8859-1 --format=%s --grep=$utf8_e >actual && - test_cmp expect actual + test_must_be_empty actual ' test_done diff --git a/t/t4211-line-log.sh b/t/t4211-line-log.sh index 436b13ad21..ef1322148e 100755 --- a/t/t4211-line-log.sh +++ b/t/t4211-line-log.sh @@ -101,7 +101,7 @@ test_expect_success '-L with --first-parent and a merge' ' test_expect_success '-L with --output' ' git checkout parallel-change && git log --output=log -L :main:b.c >output && - test ! -s output && + test_must_be_empty output && test_line_count = 70 log ' diff --git a/t/t4212-log-corrupt.sh b/t/t4212-log-corrupt.sh index 22aa8b7c0e..03b952c90d 100755 --- a/t/t4212-log-corrupt.sh +++ b/t/t4212-log-corrupt.sh @@ -26,22 +26,20 @@ test_expect_success 'git log with broken author email' ' echo echo " foo" } >expect.out && - : >expect.err && git log broken_email >actual.out 2>actual.err && test_cmp expect.out actual.out && - test_cmp expect.err actual.err + test_must_be_empty actual.err ' test_expect_success 'git log --format with broken author email' ' echo "A U Thor+author@example.com+Thu Apr 7 15:13:13 2005 -0700" >expect.out && - : >expect.err && git log --format="%an+%ae+%ad" broken_email >actual.out 2>actual.err && test_cmp expect.out actual.out && - test_cmp expect.err actual.err + test_must_be_empty actual.err ' munge_author_date () { diff --git a/t/t4300-merge-tree.sh b/t/t4300-merge-tree.sh index 9015e47654..d87cc7d9ef 100755 --- a/t/t4300-merge-tree.sh +++ b/t/t4300-merge-tree.sh @@ -25,25 +25,19 @@ EXPECTED ' test_expect_success 'file add !A, B' ' - cat >expected <<\EXPECTED && -EXPECTED - git reset --hard initial && test_commit "add-not-a-b" "ONE" "AAA" && git merge-tree initial add-not-a-b initial >actual && - test_cmp expected actual + test_must_be_empty actual ' test_expect_success 'file add A, B (same)' ' - cat >expected <<\EXPECTED && -EXPECTED - git reset --hard initial && test_commit "add-a-b-same-A" "ONE" "AAA" && git reset --hard initial && test_commit "add-a-b-same-B" "ONE" "AAA" && git merge-tree initial add-a-b-same-A add-a-b-same-B >actual && - test_cmp expected actual + test_must_be_empty actual ' test_expect_success 'file add A, B (different)' ' @@ -68,13 +62,10 @@ EXPECTED ' test_expect_success 'file change A, !B' ' - cat >expected <<\EXPECTED && -EXPECTED - git reset --hard initial && test_commit "change-a-not-b" "initial-file" "BBB" && git merge-tree initial change-a-not-b initial >actual && - test_cmp expected actual + test_must_be_empty actual ' test_expect_success 'file change !A, B' ' @@ -94,15 +85,12 @@ EXPECTED ' test_expect_success 'file change A, B (same)' ' - cat >expected <<\EXPECTED && -EXPECTED - git reset --hard initial && test_commit "change-a-b-same-A" "initial-file" "AAA" && git reset --hard initial && test_commit "change-a-b-same-B" "initial-file" "AAA" && git merge-tree initial change-a-b-same-A change-a-b-same-B >actual && - test_cmp expected actual + test_must_be_empty actual ' test_expect_success 'file change A, B (different)' ' @@ -175,16 +163,13 @@ AAA" && ' test_expect_success 'file remove A, !B' ' - cat >expected <<\EXPECTED && -EXPECTED - git reset --hard initial && test_commit "rm-a-not-b-base" "ONE" "AAA" && git rm ONE && git commit -m "rm-a-not-b" && git tag "rm-a-not-b" && git merge-tree rm-a-not-b-base rm-a-not-b rm-a-not-b-base >actual && - test_cmp expected actual + test_must_be_empty actual ' test_expect_success 'file remove !A, B' ' @@ -206,16 +191,13 @@ EXPECTED ' test_expect_success 'file remove A, B (same)' ' - cat >expected <<\EXPECTED && -EXPECTED - git reset --hard initial && test_commit "rm-a-b-base" "ONE" "AAA" && git rm ONE && git commit -m "rm-a-b" && git tag "rm-a-b" && git merge-tree rm-a-b-base rm-a-b rm-a-b >actual && - test_cmp expected actual + test_must_be_empty actual ' test_expect_success 'file change A, remove B' ' @@ -260,13 +242,11 @@ EXPECTED ' test_expect_success 'tree add A, B (same)' ' - cat >expect <<-\EOF && - EOF git reset --hard initial && mkdir sub && test_commit "add sub/file" "sub/file" "file" add-tree-A && git merge-tree initial add-tree-A add-tree-A >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'tree add A, B (different)' ' diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh index f20f03c103..270da21ac3 100755 --- a/t/t5304-prune.sh +++ b/t/t5304-prune.sh @@ -112,8 +112,7 @@ test_expect_success 'prune: do not prune detached HEAD with no reflog' ' # (should be removed and disabled by previous test) test_path_is_missing .git/logs && git prune -n >prune_actual && - : >prune_expected && - test_cmp prune_actual prune_expected + test_must_be_empty prune_actual ' diff --git a/t/t5310-pack-bitmaps.sh b/t/t5310-pack-bitmaps.sh index 2d22a17c4a..7bff7923f2 100755 --- a/t/t5310-pack-bitmaps.sh +++ b/t/t5310-pack-bitmaps.sh @@ -9,7 +9,8 @@ objpath () { # show objects present in pack ($1 should be associated *.idx) list_packed_objects () { - git show-index <"$1" | cut -d' ' -f2 + git show-index <"$1" >object-list && + cut -d' ' -f2 object-list } # has_any pattern-file content-file @@ -204,8 +205,8 @@ test_expect_success 'pack-objects to file can use bitmap' ' # verify equivalent packs are generated with/without using bitmap index packasha1=$(git pack-objects --no-use-bitmap-index --all packa </dev/null) && packbsha1=$(git pack-objects --use-bitmap-index --all packb </dev/null) && - list_packed_objects <packa-$packasha1.idx >packa.objects && - list_packed_objects <packb-$packbsha1.idx >packb.objects && + list_packed_objects packa-$packasha1.idx >packa.objects && + list_packed_objects packb-$packbsha1.idx >packb.objects && test_cmp packa.objects packb.objects ' @@ -309,9 +310,8 @@ test_expect_success 'pack reuse respects --honor-pack-keep' ' done && reusable_pack --honor-pack-keep >empty.pack && git index-pack empty.pack && - >expect && git show-index <empty.idx >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'pack reuse respects --local' ' @@ -319,17 +319,15 @@ test_expect_success 'pack reuse respects --local' ' test_when_finished "mv alt.git/objects/pack/* .git/objects/pack/" && reusable_pack --local >empty.pack && git index-pack empty.pack && - >expect && git show-index <empty.idx >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'pack reuse respects --incremental' ' reusable_pack --incremental >empty.pack && git index-pack empty.pack && - >expect && git show-index <empty.idx >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'truncated bitmap fails gracefully' ' @@ -337,7 +335,7 @@ test_expect_success 'truncated bitmap fails gracefully' ' git rev-list --use-bitmap-index --count --all >expect && bitmap=$(ls .git/objects/pack/*.bitmap) && test_when_finished "rm -f $bitmap" && - head -c 512 <$bitmap >$bitmap.tmp && + test_copy_bytes 512 <$bitmap >$bitmap.tmp && mv -f $bitmap.tmp $bitmap && git rev-list --use-bitmap-index --count --all >actual 2>stderr && test_cmp expect actual && diff --git a/t/t5313-pack-bounds-checks.sh b/t/t5313-pack-bounds-checks.sh index 4fe4ad9d61..f1708d415e 100755 --- a/t/t5313-pack-bounds-checks.sh +++ b/t/t5313-pack-bounds-checks.sh @@ -90,9 +90,8 @@ test_expect_success 'matched bogus object count' ' # Unlike above, we should notice early that the .idx is totally # bogus, and not even enumerate its contents. - >expect && git cat-file --batch-all-objects --batch-check >actual && - test_cmp expect actual && + test_must_be_empty actual && # But as before, we can do the same object-access checks. test_must_fail git cat-file blob $object && diff --git a/t/t5314-pack-cycle-detection.sh b/t/t5314-pack-cycle-detection.sh index f31995d3d2..e525466de0 100755 --- a/t/t5314-pack-cycle-detection.sh +++ b/t/t5314-pack-cycle-detection.sh @@ -98,9 +98,8 @@ test_expect_success 'repack' ' # We first want to check that we do not have any internal errors, # and also that we do not hit the last-ditch cycle-breaking code # in write_object(), which will issue a warning to stderr. - >expect && git repack -ad 2>stderr && - test_cmp expect stderr && + test_must_be_empty stderr && # And then double-check that the resulting pack is usable (i.e., # we did not fail to notice any cycles). We know we are accessing diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh index 6aee861f78..2799969f3e 100755 --- a/t/t5318-commit-graph.sh +++ b/t/t5318-commit-graph.sh @@ -134,7 +134,7 @@ test_expect_success 'Add one more commit' ' git branch commits/8 && ls $objdir/pack | grep idx >existing-idx && git repack && - ls $objdir/pack| grep idx | grep -v --file=existing-idx >new-idx + ls $objdir/pack| grep idx | grep -v -f existing-idx >new-idx ' # Current graph structure: @@ -254,9 +254,9 @@ test_expect_success 'check that gc computes commit-graph' ' git config gc.writeCommitGraph true && git gc && cp $objdir/info/commit-graph commit-graph-after-gc && - ! test_cmp commit-graph-before-gc commit-graph-after-gc && + ! test_cmp_bin commit-graph-before-gc commit-graph-after-gc && git commit-graph write --reachable && - test_cmp commit-graph-after-gc $objdir/info/commit-graph + test_cmp_bin commit-graph-after-gc $objdir/info/commit-graph ' test_expect_success 'replace-objects invalidates commit-graph' ' @@ -504,25 +504,27 @@ test_expect_success 'setup non-the_repository tests' ' test_expect_success 'parse_commit_in_graph works for non-the_repository' ' test-tool repository parse_commit_in_graph \ repo/.git repo "$(git -C repo rev-parse two)" >actual && - echo $(git -C repo log --pretty="%ct" -1) \ - $(git -C repo rev-parse one) >expect && + { + git -C repo log --pretty=format:"%ct " -1 && + git -C repo rev-parse one + } >expect && test_cmp expect actual && test-tool repository parse_commit_in_graph \ repo/.git repo "$(git -C repo rev-parse one)" >actual && - echo $(git -C repo log --pretty="%ct" -1 one) >expect && + git -C repo log --pretty="%ct" -1 one >expect && test_cmp expect actual ' test_expect_success 'get_commit_tree_in_graph works for non-the_repository' ' test-tool repository get_commit_tree_in_graph \ repo/.git repo "$(git -C repo rev-parse two)" >actual && - echo $(git -C repo rev-parse two^{tree}) >expect && + git -C repo rev-parse two^{tree} >expect && test_cmp expect actual && test-tool repository get_commit_tree_in_graph \ repo/.git repo "$(git -C repo rev-parse one)" >actual && - echo $(git -C repo rev-parse one^{tree}) >expect && + git -C repo rev-parse one^{tree} >expect && test_cmp expect actual ' diff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh index b5f886a0e2..956d69f5b1 100755 --- a/t/t5401-update-hooks.sh +++ b/t/t5401-update-hooks.sh @@ -104,17 +104,17 @@ test_expect_success 'post-update hook arguments' ' ' test_expect_success 'all hook stdin is /dev/null' ' - ! test -s victim.git/update.stdin && - ! test -s victim.git/post-update.stdin + test_must_be_empty victim.git/update.stdin && + test_must_be_empty victim.git/post-update.stdin ' test_expect_success 'all *-receive hook args are empty' ' - ! test -s victim.git/pre-receive.args && - ! test -s victim.git/post-receive.args + test_must_be_empty victim.git/pre-receive.args && + test_must_be_empty victim.git/post-receive.args ' test_expect_success 'send-pack produced no output' ' - ! test -s send.out + test_must_be_empty send.out ' cat <<EOF >expect diff --git a/t/t5409-colorize-remote-messages.sh b/t/t5409-colorize-remote-messages.sh new file mode 100755 index 0000000000..f81b6813c0 --- /dev/null +++ b/t/t5409-colorize-remote-messages.sh @@ -0,0 +1,101 @@ +#!/bin/sh + +test_description='remote messages are colorized on the client' + +. ./test-lib.sh + +test_expect_success 'setup' ' + mkdir .git/hooks && + write_script .git/hooks/update <<-\EOF && + echo error: error + echo ERROR: also highlighted + echo hint: hint + echo hinting: not highlighted + echo success: success + echo warning: warning + echo prefixerror: error + echo " " "error: leading space" + echo " " + echo Err + exit 0 + EOF + echo 1 >file && + git add file && + git commit -m 1 && + git clone . child && + ( + cd child && + test_commit message2 file content2 + ) +' + +test_expect_success 'keywords' ' + git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/keywords 2>output && + test_decode_color <output >decoded && + grep "<BOLD;RED>error<RESET>: error" decoded && + grep "<YELLOW>hint<RESET>:" decoded && + grep "<BOLD;GREEN>success<RESET>:" decoded && + grep "<BOLD;YELLOW>warning<RESET>:" decoded +' + +test_expect_success 'whole words at line start' ' + git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/whole-words 2>output && + test_decode_color <output >decoded && + grep "<YELLOW>hint<RESET>:" decoded && + grep "hinting: not highlighted" decoded && + grep "prefixerror: error" decoded +' + +test_expect_success 'short line' ' + git -C child -c color.remote=always push -f origin HEAD:short-line 2>output && + test_decode_color <output >decoded && + grep "remote: Err" decoded +' + +test_expect_success 'case-insensitive' ' + git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/case-insensitive 2>output && + cat output && + test_decode_color <output >decoded && + grep "<BOLD;RED>error<RESET>: error" decoded && + grep "<BOLD;RED>ERROR<RESET>: also highlighted" decoded +' + +test_expect_success 'leading space' ' + git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/leading-space 2>output && cat output && + test_decode_color <output >decoded && + grep " <BOLD;RED>error<RESET>: leading space" decoded +' + +test_expect_success 'spaces only' ' + git -C child -c color.remote=always push -f origin HEAD:only-space 2>output && + test_decode_color <output >decoded && + grep "remote: " decoded +' + +test_expect_success 'no coloring for redirected output' ' + git --git-dir child/.git push -f origin HEAD:refs/heads/redirected-output 2>output && + test_decode_color <output >decoded && + grep "error: error" decoded +' + +test_expect_success 'push with customized color' ' + git --git-dir child/.git -c color.remote=always -c color.remote.error=blue push -f origin HEAD:refs/heads/customized-color 2>output && + test_decode_color <output >decoded && + grep "<BLUE>error<RESET>:" decoded && + grep "<BOLD;GREEN>success<RESET>:" decoded +' + + +test_expect_success 'error in customized color' ' + git --git-dir child/.git -c color.remote=always -c color.remote.error=i-am-not-a-color push -f origin HEAD:refs/heads/error-customized-color 2>output && + test_decode_color <output >decoded && + grep "<BOLD;GREEN>success<RESET>:" decoded +' + +test_expect_success 'fallback to color.ui' ' + git --git-dir child/.git -c color.ui=always push -f origin HEAD:refs/heads/fallback-color-ui 2>output && + test_decode_color <output >decoded && + grep "<BOLD;RED>error<RESET>: error" decoded +' + +test_done diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index fa03f56a20..1b5a4a6d38 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -161,7 +161,7 @@ test_expect_success 'clone shallow object count' ' test_expect_success 'clone shallow object count (part 2)' ' sed -e "/^in-pack:/d" -e "/^packs:/d" -e "/^size-pack:/d" \ -e "/: 0$/d" count.shallow > count_output && - ! test -s count_output + test_must_be_empty count_output ' test_expect_success 'fsck in shallow repo' ' @@ -403,7 +403,7 @@ test_expect_success 'fetch creating new shallow root' ' git fetch --depth=1 --progress 2>actual && # This should fetch only the empty commit, no tree or # blob objects - grep "remote: Total 1" actual + test_i18ngrep "remote: Total 1" actual ) ' diff --git a/t/t5504-fetch-receive-strict.sh b/t/t5504-fetch-receive-strict.sh index 49d3621a92..62f3569891 100755 --- a/t/t5504-fetch-receive-strict.sh +++ b/t/t5504-fetch-receive-strict.sh @@ -3,13 +3,16 @@ test_description='fetch/receive strict mode' . ./test-lib.sh -test_expect_success setup ' +test_expect_success 'setup and inject "corrupt or missing" object' ' echo hello >greetings && git add greetings && git commit -m greetings && S=$(git rev-parse :greetings | sed -e "s|^..|&/|") && X=$(echo bye | git hash-object -w --stdin | sed -e "s|^..|&/|") && + echo $S >S && + echo $X >X && + cp .git/objects/$S .git/objects/$S.back && mv -f .git/objects/$X .git/objects/$S && test_must_fail git fsck @@ -115,6 +118,13 @@ test_expect_success 'push with transfer.fsckobjects' ' test_cmp exp act ' +test_expect_success 'repair the "corrupt or missing" object' ' + mv -f .git/objects/$(cat S) .git/objects/$(cat X) && + mv .git/objects/$(cat S).back .git/objects/$(cat S) && + rm -rf .git/objects/$(cat X) && + git fsck +' + cat >bogus-commit <<EOF tree $EMPTY_TREE author Bugs Bunny 1234567890 +0000 @@ -123,6 +133,14 @@ committer Bugs Bunny <bugs@bun.ni> 1234567890 +0000 This commit object intentionally broken EOF +test_expect_success 'fsck with invalid or bogus skipList input' ' + git -c fsck.skipList=/dev/null -c fsck.missingEmail=ignore fsck && + test_must_fail git -c fsck.skipList=does-not-exist -c fsck.missingEmail=ignore fsck 2>err && + test_i18ngrep "Could not open skip list: does-not-exist" err && + test_must_fail git -c fsck.skipList=.git/config -c fsck.missingEmail=ignore fsck 2>err && + test_i18ngrep "Invalid SHA-1: \[core\]" err +' + test_expect_success 'push with receive.fsck.skipList' ' commit="$(git hash-object -t commit -w --stdin <bogus-commit)" && git push . $commit:refs/heads/bogus && @@ -130,11 +148,61 @@ test_expect_success 'push with receive.fsck.skipList' ' git init dst && git --git-dir=dst/.git config receive.fsckObjects true && test_must_fail git push --porcelain dst bogus && - git --git-dir=dst/.git config receive.fsck.skipList SKIP && echo $commit >dst/.git/SKIP && + + # receive.fsck.* does not fall back on fsck.* + git --git-dir=dst/.git config fsck.skipList SKIP && + test_must_fail git push --porcelain dst bogus && + + # Invalid and/or bogus skipList input + git --git-dir=dst/.git config receive.fsck.skipList /dev/null && + test_must_fail git push --porcelain dst bogus && + git --git-dir=dst/.git config receive.fsck.skipList does-not-exist && + test_must_fail git push --porcelain dst bogus 2>err && + test_i18ngrep "Could not open skip list: does-not-exist" err && + git --git-dir=dst/.git config receive.fsck.skipList config && + test_must_fail git push --porcelain dst bogus 2>err && + test_i18ngrep "Invalid SHA-1: \[core\]" err && + + git --git-dir=dst/.git config receive.fsck.skipList SKIP && git push --porcelain dst bogus ' +test_expect_success 'fetch with fetch.fsck.skipList' ' + commit="$(git hash-object -t commit -w --stdin <bogus-commit)" && + refspec=refs/heads/bogus:refs/heads/bogus && + git push . $commit:refs/heads/bogus && + rm -rf dst && + git init dst && + git --git-dir=dst/.git config fetch.fsckObjects true && + test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec && + git --git-dir=dst/.git config fetch.fsck.skipList /dev/null && + test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec && + echo $commit >dst/.git/SKIP && + + # fetch.fsck.* does not fall back on fsck.* + git --git-dir=dst/.git config fsck.skipList dst/.git/SKIP && + test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec && + + # Invalid and/or bogus skipList input + git --git-dir=dst/.git config fetch.fsck.skipList /dev/null && + test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec && + git --git-dir=dst/.git config fetch.fsck.skipList does-not-exist && + test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec 2>err && + test_i18ngrep "Could not open skip list: does-not-exist" err && + git --git-dir=dst/.git config fetch.fsck.skipList dst/.git/config && + test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec 2>err && + test_i18ngrep "Invalid SHA-1: \[core\]" err && + + git --git-dir=dst/.git config fetch.fsck.skipList dst/.git/SKIP && + git --git-dir=dst/.git fetch "file://$(pwd)" $refspec +' + +test_expect_success 'fsck.<unknownmsg-id> dies' ' + test_must_fail git -c fsck.whatEver=ignore fsck 2>err && + test_i18ngrep "Unhandled message id: whatever" err +' + test_expect_success 'push with receive.fsck.missingEmail=warn' ' commit="$(git hash-object -t commit -w --stdin <bogus-commit)" && git push . $commit:refs/heads/bogus && @@ -142,19 +210,58 @@ test_expect_success 'push with receive.fsck.missingEmail=warn' ' git init dst && git --git-dir=dst/.git config receive.fsckobjects true && test_must_fail git push --porcelain dst bogus && + + # receive.fsck.<msg-id> does not fall back on fsck.<msg-id> + git --git-dir=dst/.git config fsck.missingEmail warn && + test_must_fail git push --porcelain dst bogus && + + # receive.fsck.<unknownmsg-id> warns + git --git-dir=dst/.git config \ + receive.fsck.whatEver error && + git --git-dir=dst/.git config \ receive.fsck.missingEmail warn && git push --porcelain dst bogus >act 2>&1 && grep "missingEmail" act && + test_i18ngrep "Skipping unknown msg id.*whatever" act && git --git-dir=dst/.git branch -D bogus && git --git-dir=dst/.git config --add \ receive.fsck.missingEmail ignore && - git --git-dir=dst/.git config --add \ - receive.fsck.badDate warn && git push --porcelain dst bogus >act 2>&1 && ! grep "missingEmail" act ' +test_expect_success 'fetch with fetch.fsck.missingEmail=warn' ' + commit="$(git hash-object -t commit -w --stdin <bogus-commit)" && + refspec=refs/heads/bogus:refs/heads/bogus && + git push . $commit:refs/heads/bogus && + rm -rf dst && + git init dst && + git --git-dir=dst/.git config fetch.fsckobjects true && + test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec && + + # fetch.fsck.<msg-id> does not fall back on fsck.<msg-id> + git --git-dir=dst/.git config fsck.missingEmail warn && + test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec && + + # receive.fsck.<unknownmsg-id> warns + git --git-dir=dst/.git config \ + fetch.fsck.whatEver error && + + git --git-dir=dst/.git config \ + fetch.fsck.missingEmail warn && + git --git-dir=dst/.git fetch "file://$(pwd)" $refspec >act 2>&1 && + grep "missingEmail" act && + test_i18ngrep "Skipping unknown msg id.*whatever" act && + rm -rf dst && + git init dst && + git --git-dir=dst/.git config fetch.fsckobjects true && + git --git-dir=dst/.git config \ + fetch.fsck.missingEmail ignore && + git --git-dir=dst/.git fetch "file://$(pwd)" $refspec >act 2>&1 && + ! grep "missingEmail" act +' + test_expect_success \ 'receive.fsck.unterminatedHeader=warn triggers error' ' rm -rf dst && @@ -166,4 +273,15 @@ test_expect_success \ grep "Cannot demote unterminatedheader" act ' +test_expect_success \ + 'fetch.fsck.unterminatedHeader=warn triggers error' ' + rm -rf dst && + git init dst && + git --git-dir=dst/.git config fetch.fsckobjects true && + git --git-dir=dst/.git config \ + fetch.fsck.unterminatedheader warn && + test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" HEAD && + grep "Cannot demote unterminatedheader" act +' + test_done diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index 11e14a1e0f..d2a2cdd453 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -74,8 +74,7 @@ test_expect_success 'add another remote' ' git for-each-ref "--format=%(refname)" refs/remotes | sed -e "/^refs\/remotes\/origin\//d" \ -e "/^refs\/remotes\/second\//d" >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ) ' @@ -112,8 +111,7 @@ test_expect_success C_LOCALE_OUTPUT 'remove remote' ' check_remote_track origin master side && git for-each-ref "--format=%(refname)" refs/remotes | sed -e "/^refs\/remotes\/origin\//d" >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ) ' @@ -147,7 +145,7 @@ test_expect_success 'remove remote protects local branches' ' test_expect_success 'remove errors out early when deleting non-existent branch' ' ( cd test && - echo "fatal: No such remote: foo" >expect && + echo "fatal: No such remote: '\''foo'\''" >expect && test_must_fail git remote rm foo 2>actual && test_i18ncmp expect actual ) @@ -175,7 +173,7 @@ test_expect_success 'remove remote with a branch without configured merge' ' test_expect_success 'rename errors out early when deleting non-existent branch' ' ( cd test && - echo "fatal: No such remote: foo" >expect && + echo "fatal: No such remote: '\''foo'\''" >expect && test_must_fail git remote rename foo bar 2>actual && test_i18ncmp expect actual ) @@ -872,7 +870,7 @@ test_expect_success 'remote prune to cause a dangling symref' ' cd eight && test_must_fail git branch nomore origin ) 2>err && - grep "dangling symref" err + test_i18ngrep "dangling symref" err ' test_expect_success 'show empty remote' ' diff --git a/t/t5509-fetch-push-namespaces.sh b/t/t5509-fetch-push-namespaces.sh index 75c570adca..c88df78c0b 100755 --- a/t/t5509-fetch-push-namespaces.sh +++ b/t/t5509-fetch-push-namespaces.sh @@ -44,7 +44,7 @@ test_expect_success 'pushing into a repository using a ref namespace' ' test_cmp expected actual && # Try a namespace with no content git ls-remote "ext::git --namespace=garbage %s ../pushee" >actual && - test_cmp /dev/null actual && + test_must_be_empty actual && git ls-remote pushee-unnamespaced >actual && sed -e "s|refs/|refs/namespaces/namespace/refs/|" expected >expected.unnamespaced && test_cmp expected.unnamespaced actual diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index 62308be499..3b7b30568c 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -535,6 +535,41 @@ test_expect_success "should be able to fetch with duplicate refspecs" ' ) ' +test_expect_success 'LHS of refspec follows ref disambiguation rules' ' + mkdir lhs-ambiguous && + ( + cd lhs-ambiguous && + git init server && + test_commit -C server unwanted && + test_commit -C server wanted && + + git init client && + + # Check a name coming after "refs" alphabetically ... + git -C server update-ref refs/heads/s wanted && + git -C server update-ref refs/heads/refs/heads/s unwanted && + git -C client fetch ../server +refs/heads/s:refs/heads/checkthis && + git -C server rev-parse wanted >expect && + git -C client rev-parse checkthis >actual && + test_cmp expect actual && + + # ... and one before. + git -C server update-ref refs/heads/q wanted && + git -C server update-ref refs/heads/refs/heads/q unwanted && + git -C client fetch ../server +refs/heads/q:refs/heads/checkthis && + git -C server rev-parse wanted >expect && + git -C client rev-parse checkthis >actual && + test_cmp expect actual && + + # Tags are preferred over branches like refs/{heads,tags}/* + git -C server update-ref refs/tags/t wanted && + git -C server update-ref refs/heads/t unwanted && + git -C client fetch ../server +t:refs/heads/checkthis && + git -C server rev-parse wanted >expect && + git -C client rev-parse checkthis >actual + ) +' + # configured prune tests set_config_tristate () { @@ -613,7 +648,7 @@ test_configured_prune_type () { git rev-parse --verify refs/tags/newtag ) && - # now remove it + # now remove them git branch -d newbranch && git tag -d newtag && diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh index ea020040e8..bc5703ff9b 100755 --- a/t/t5512-ls-remote.sh +++ b/t/t5512-ls-remote.sh @@ -155,14 +155,12 @@ test_expect_success 'die with non-2 for wrong repository even with --exit-code' test_expect_success 'Report success even when nothing matches' ' git ls-remote other.git "refs/nsn/*" >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'Report no-match with --exit-code' ' test_expect_code 2 git ls-remote --exit-code other.git "refs/nsn/*" >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'Report match with --exit-code' ' diff --git a/t/t5514-fetch-multiple.sh b/t/t5514-fetch-multiple.sh index 4b4b6673b8..0030c92e1a 100755 --- a/t/t5514-fetch-multiple.sh +++ b/t/t5514-fetch-multiple.sh @@ -152,7 +152,6 @@ test_expect_success 'git fetch --multiple (ignoring skipFetchAll)' ' ' test_expect_success 'git fetch --all --no-tags' ' - >expect && git clone one test5 && git clone test5 test6 && (cd test5 && git tag test-tag) && @@ -161,7 +160,7 @@ test_expect_success 'git fetch --all --no-tags' ' git fetch --all --no-tags && git tag >output ) && - test_cmp expect test6/output + test_must_be_empty test6/output ' test_expect_success 'git fetch --all --tags' ' diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index bd8f23e430..539c25aada 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -965,26 +965,51 @@ test_expect_success 'push into aliased refs (inconsistent)' ' ) ' -test_expect_success 'push requires --force to update lightweight tag' ' - mk_test testrepo heads/master && - mk_child testrepo child1 && - mk_child testrepo child2 && - ( - cd child1 && - git tag Tag && - git push ../child2 Tag && - git push ../child2 Tag && - >file1 && - git add file1 && - git commit -m "file1" && - git tag -f Tag && - test_must_fail git push ../child2 Tag && - git push --force ../child2 Tag && - git tag -f Tag && - test_must_fail git push ../child2 Tag HEAD~ && - git push --force ../child2 Tag - ) -' +test_force_push_tag () { + tag_type_description=$1 + tag_args=$2 + + test_expect_success 'force pushing required to update lightweight tag' " + mk_test testrepo heads/master && + mk_child testrepo child1 && + mk_child testrepo child2 && + ( + cd child1 && + git tag testTag && + git push ../child2 testTag && + >file1 && + git add file1 && + git commit -m 'file1' && + git tag $tag_args testTag && + test_must_fail git push ../child2 testTag && + git push --force ../child2 testTag && + git tag $tag_args testTag HEAD~ && + test_must_fail git push ../child2 testTag && + git push --force ../child2 testTag && + + # Clobbering without + in refspec needs --force + git tag -f testTag && + test_must_fail git push ../child2 'refs/tags/*:refs/tags/*' && + git push --force ../child2 'refs/tags/*:refs/tags/*' && + + # Clobbering with + in refspec does not need --force + git tag -f testTag HEAD~ && + git push ../child2 '+refs/tags/*:refs/tags/*' && + + # Clobbering with --no-force still obeys + in refspec + git tag -f testTag && + git push --no-force ../child2 '+refs/tags/*:refs/tags/*' && + + # Clobbering with/without --force and 'tag <name>' format + git tag -f testTag HEAD~ && + test_must_fail git push ../child2 tag testTag && + git push --force ../child2 tag testTag + ) + " +} + +test_force_push_tag "lightweight tag" "-f" +test_force_push_tag "annotated tag" "-f -a -m'msg'" test_expect_success 'push --porcelain' ' mk_empty testrepo && diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index 68aa5f0340..5e501c8b08 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -475,10 +475,22 @@ test_expect_success 'pull.rebase=interactive' ' false EOF test_set_editor "$TRASH_DIRECTORY/fake-editor" && + test_when_finished "test_might_fail git rebase --abort" && test_must_fail git pull --rebase=interactive . copy && test "I was here" = "$(cat fake.out)" ' +test_expect_success 'pull --rebase=i' ' + write_script "$TRASH_DIRECTORY/fake-editor" <<-\EOF && + echo I was here, too >fake.out && + false + EOF + test_set_editor "$TRASH_DIRECTORY/fake-editor" && + test_when_finished "test_might_fail git rebase --abort" && + test_must_fail git pull --rebase=i . copy && + test "I was here, too" = "$(cat fake.out)" +' + test_expect_success 'pull.rebase=invalid fails' ' git reset --hard before-preserve-rebase && test_config pull.rebase invalid && diff --git a/t/t5523-push-upstream.sh b/t/t5523-push-upstream.sh index d6981ba304..c0df81a014 100755 --- a/t/t5523-push-upstream.sh +++ b/t/t5523-push-upstream.sh @@ -113,7 +113,7 @@ test_expect_success TTY 'quiet push' ' ensure_fresh_upstream && test_terminal git push --quiet --no-progress upstream master 2>&1 | tee output && - test_cmp /dev/null output + test_must_be_empty output ' test_done diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh index 0f730d7781..6c2f9b2ba2 100755 --- a/t/t5526-fetch-submodules.sh +++ b/t/t5526-fetch-submodules.sh @@ -98,8 +98,8 @@ test_expect_success "fetch alone only fetches superproject" ' cd downstream && git fetch >../actual.out 2>../actual.err ) && - ! test -s actual.out && - ! test -s actual.err + test_must_be_empty actual.out && + test_must_be_empty actual.err ' test_expect_success "fetch --no-recurse-submodules only fetches superproject" ' @@ -107,8 +107,8 @@ test_expect_success "fetch --no-recurse-submodules only fetches superproject" ' cd downstream && git fetch --no-recurse-submodules >../actual.out 2>../actual.err ) && - ! test -s actual.out && - ! test -s actual.err + test_must_be_empty actual.out && + test_must_be_empty actual.err ' test_expect_success "using fetchRecurseSubmodules=true in .gitmodules recurses into submodules" ' @@ -127,8 +127,8 @@ test_expect_success "--no-recurse-submodules overrides .gitmodules config" ' cd downstream && git fetch --no-recurse-submodules >../actual.out 2>../actual.err ) && - ! test -s actual.out && - ! test -s actual.err + test_must_be_empty actual.out && + test_must_be_empty actual.err ' test_expect_success "using fetchRecurseSubmodules=false in .git/config overrides setting in .gitmodules" ' @@ -137,8 +137,8 @@ test_expect_success "using fetchRecurseSubmodules=false in .git/config overrides git config submodule.submodule.fetchRecurseSubmodules false && git fetch >../actual.out 2>../actual.err ) && - ! test -s actual.out && - ! test -s actual.err + test_must_be_empty actual.out && + test_must_be_empty actual.err ' test_expect_success "--recurse-submodules overrides fetchRecurseSubmodules setting from .git/config" ' @@ -157,8 +157,8 @@ test_expect_success "--quiet propagates to submodules" ' cd downstream && git fetch --recurse-submodules --quiet >../actual.out 2>../actual.err ) && - ! test -s actual.out && - ! test -s actual.err + test_must_be_empty actual.out && + test_must_be_empty actual.err ' test_expect_success "--quiet propagates to parallel submodules" ' @@ -166,8 +166,8 @@ test_expect_success "--quiet propagates to parallel submodules" ' cd downstream && git fetch --recurse-submodules -j 2 --quiet >../actual.out 2>../actual.err ) && - ! test -s actual.out && - ! test -s actual.err + test_must_be_empty actual.out && + test_must_be_empty actual.err ' test_expect_success "--dry-run propagates to submodules" ' @@ -221,8 +221,8 @@ test_expect_success "--no-recurse-submodules overrides config setting" ' git config fetch.recurseSubmodules true && git fetch --no-recurse-submodules >../actual.out 2>../actual.err ) && - ! test -s actual.out && - ! test -s actual.err + test_must_be_empty actual.out && + test_must_be_empty actual.err ' test_expect_success "Recursion doesn't happen when no new commits are fetched in the superproject" ' @@ -235,8 +235,8 @@ test_expect_success "Recursion doesn't happen when no new commits are fetched in git config --unset fetch.recurseSubmodules && git fetch >../actual.out 2>../actual.err ) && - ! test -s actual.out && - ! test -s actual.err + test_must_be_empty actual.out && + test_must_be_empty actual.err ' test_expect_success "Recursion stops when no new submodule commits are fetched" ' @@ -268,7 +268,7 @@ test_expect_success "Recursion doesn't happen when new superproject commits don' cd downstream && git fetch >../actual.out 2>../actual.err ) && - ! test -s actual.out && + test_must_be_empty actual.out && test_i18ncmp expect.err.file actual.err ' @@ -357,8 +357,8 @@ test_expect_success "'--recurse-submodules=on-demand' doesn't recurse when no ne git fetch --recurse-submodules=on-demand >../actual.out 2>../actual.err && git config --unset fetch.recurseSubmodules ) && - ! test -s actual.out && - ! test -s actual.err + test_must_be_empty actual.out && + test_must_be_empty actual.err ' test_expect_success "'--recurse-submodules=on-demand' recurses as deep as necessary (and ignores config)" ' @@ -402,7 +402,7 @@ test_expect_success "'--recurse-submodules=on-demand' stops when no new submodul cd downstream && git fetch --recurse-submodules=on-demand >../actual.out 2>../actual.err ) && - ! test -s actual.out && + test_must_be_empty actual.out && test_i18ncmp expect.err.file actual.err ' @@ -477,7 +477,7 @@ test_expect_success "don't fetch submodule when newly recorded commits are alrea cd downstream && git fetch >../actual.out 2>../actual.err ) && - ! test -s actual.out && + test_must_be_empty actual.out && test_i18ncmp expect.err actual.err && ( cd submodule && @@ -495,7 +495,6 @@ test_expect_success "'fetch.recurseSubmodules=on-demand' works also without .git git add submodule && git rm .gitmodules && git commit -m "new submodule without .gitmodules" && - printf "" >expect.out && head2=$(git rev-parse --short HEAD) && echo "From $pwd/." >expect.err.2 && echo " $head1..$head2 master -> origin/master" >>expect.err.2 && @@ -514,7 +513,7 @@ test_expect_success "'fetch.recurseSubmodules=on-demand' works also without .git git config --unset fetch.recurseSubmodules && git reset --hard ) && - test_i18ncmp expect.out actual.out && + test_must_be_empty actual.out && test_i18ncmp expect.err.2 actual.err && git checkout HEAD^ -- .gitmodules && git add .gitmodules && diff --git a/t/t5533-push-cas.sh b/t/t5533-push-cas.sh index d38ecee217..0b0eb1d025 100755 --- a/t/t5533-push-cas.sh +++ b/t/t5533-push-cas.sh @@ -142,9 +142,8 @@ test_expect_success 'push to delete (protected, forced)' ' cd dst && git push --force --force-with-lease=master:master^ origin :master ) && - >expect && git ls-remote src refs/heads/master >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'push to delete (allowed)' ' @@ -154,9 +153,8 @@ test_expect_success 'push to delete (allowed)' ' git push --force-with-lease=master origin :master 2>err && grep deleted err ) && - >expect && git ls-remote src refs/heads/master >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'cover everything with default force-with-lease (protected)' ' diff --git a/t/t5534-push-signed.sh b/t/t5534-push-signed.sh index 1cea758f78..030331f1c5 100755 --- a/t/t5534-push-signed.sh +++ b/t/t5534-push-signed.sh @@ -194,10 +194,12 @@ test_expect_success GPG 'fail without key and heed user.signingkey' ' EOF - unset GIT_COMMITTER_EMAIL && - git config user.email hasnokey@nowhere.com && - test_must_fail git push --signed dst noop ff +noff && - git config user.signingkey committer@example.com && + test_config user.email hasnokey@nowhere.com && + ( + sane_unset GIT_COMMITTER_EMAIL && + test_must_fail git push --signed dst noop ff +noff + ) && + test_config user.signingkey $GIT_COMMITTER_EMAIL && git push --signed dst noop ff +noff && ( @@ -218,4 +220,57 @@ test_expect_success GPG 'fail without key and heed user.signingkey' ' test_cmp expect dst/push-cert-status ' +test_expect_success GPGSM 'fail without key and heed user.signingkey x509' ' + test_config gpg.format x509 && + prepare_dst && + mkdir -p dst/.git/hooks && + git -C dst config receive.certnonceseed sekrit && + write_script dst/.git/hooks/post-receive <<-\EOF && + # discard the update list + cat >/dev/null + # record the push certificate + if test -n "${GIT_PUSH_CERT-}" + then + git cat-file blob $GIT_PUSH_CERT >../push-cert + fi && + + cat >../push-cert-status <<E_O_F + SIGNER=${GIT_PUSH_CERT_SIGNER-nobody} + KEY=${GIT_PUSH_CERT_KEY-nokey} + STATUS=${GIT_PUSH_CERT_STATUS-nostatus} + NONCE_STATUS=${GIT_PUSH_CERT_NONCE_STATUS-nononcestatus} + NONCE=${GIT_PUSH_CERT_NONCE-nononce} + E_O_F + + EOF + + test_config user.email hasnokey@nowhere.com && + test_config user.signingkey "" && + ( + sane_unset GIT_COMMITTER_EMAIL && + test_must_fail git push --signed dst noop ff +noff + ) && + test_config user.signingkey $GIT_COMMITTER_EMAIL && + git push --signed dst noop ff +noff && + + ( + cat <<-\EOF && + SIGNER=/CN=C O Mitter/O=Example/SN=C O/GN=Mitter + KEY= + STATUS=G + NONCE_STATUS=OK + EOF + sed -n -e "s/^nonce /NONCE=/p" -e "/^$/q" dst/push-cert + ) >expect.in && + key=$(cat "${GNUPGHOME}/trustlist.txt" | cut -d" " -f1 | tr -d ":") && + sed -e "s/^KEY=/KEY=${key}/" expect.in >expect && + + noop=$(git rev-parse noop) && + ff=$(git rev-parse ff) && + noff=$(git rev-parse noff) && + grep "$noop $ff refs/heads/ff" dst/push-cert && + grep "$noop $noff refs/heads/noff" dst/push-cert && + test_cmp expect dst/push-cert-status +' + test_done diff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh index a0fc4005e0..5475afc052 100755 --- a/t/t5541-http-push-smart.sh +++ b/t/t5541-http-push-smart.sh @@ -210,7 +210,7 @@ test_expect_success TTY 'push --quiet silences status and progress' ' cd "$ROOT_PATH"/test_repo_clone && test_commit quiet && test_terminal git push --quiet >output 2>&1 && - test_cmp /dev/null output + test_must_be_empty output ' test_expect_success TTY 'push --no-progress silences progress but not status' ' diff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh index 3aab44bdcb..771f36f9ff 100755 --- a/t/t5551-http-fetch-smart.sh +++ b/t/t5551-http-fetch-smart.sh @@ -363,6 +363,24 @@ test_expect_success 'custom http headers' ' submodule update sub ' +test_expect_success 'using fetch command in remote-curl updates refs' ' + SERVER="$HTTPD_DOCUMENT_ROOT_PATH/twobranch" && + rm -rf "$SERVER" client && + + git init "$SERVER" && + test_commit -C "$SERVER" foo && + git -C "$SERVER" update-ref refs/heads/anotherbranch foo && + + git clone $HTTPD_URL/smart/twobranch client && + + test_commit -C "$SERVER" bar && + git -C client -c protocol.version=0 fetch && + + git -C "$SERVER" rev-parse master >expect && + git -C client rev-parse origin/master >actual && + test_cmp expect actual +' + test_expect_success 'GIT_REDACT_COOKIES redacts cookies' ' rm -rf clone && echo "Set-Cookie: Foo=1" >cookies && diff --git a/t/t5552-skipping-fetch-negotiator.sh b/t/t5552-skipping-fetch-negotiator.sh index 0a8e0e42ed..30857b84a8 100755 --- a/t/t5552-skipping-fetch-negotiator.sh +++ b/t/t5552-skipping-fetch-negotiator.sh @@ -28,12 +28,25 @@ have_not_sent () { done } +# trace_fetch <client_dir> <server_dir> [args] +# +# Trace the packet output of fetch, but make sure we disable the variable +# in the child upload-pack, so we don't combine the results in the same file. +trace_fetch () { + client=$1; shift + server=$1; shift + GIT_TRACE_PACKET="$(pwd)/trace" \ + git -C "$client" fetch \ + --upload-pack 'unset GIT_TRACE_PACKET; git-upload-pack' \ + "$server" "$@" +} + test_expect_success 'commits with no parents are sent regardless of skip distance' ' git init server && test_commit -C server to_fetch && git init client && - for i in $(seq 7) + for i in $(test_seq 7) do test_commit -C client c$i done && @@ -42,18 +55,41 @@ test_expect_success 'commits with no parents are sent regardless of skip distanc # "c1" has no parent, it is still sent as "have" even though it would # normally be skipped. test_config -C client fetch.negotiationalgorithm skipping && - GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch "$(pwd)/server" && + trace_fetch client "$(pwd)/server" && have_sent c7 c5 c2 c1 && have_not_sent c6 c4 c3 ' +test_expect_success 'unknown fetch.negotiationAlgorithm values error out' ' + rm -rf server client trace && + git init server && + test_commit -C server to_fetch && + + git init client && + test_commit -C client on_client && + git -C client checkout on_client && + + test_config -C client fetch.negotiationAlgorithm invalid && + test_must_fail git -C client fetch "$(pwd)/server" 2>err && + test_i18ngrep "unknown fetch negotiation algorithm" err && + + # Explicit "default" value + test_config -C client fetch.negotiationAlgorithm default && + git -C client -c fetch.negotiationAlgorithm=default fetch "$(pwd)/server" && + + # Implementation detail: If there is nothing to fetch, we will not error out + test_config -C client fetch.negotiationAlgorithm invalid && + git -C client fetch "$(pwd)/server" 2>err && + test_i18ngrep ! "unknown fetch negotiation algorithm" err +' + test_expect_success 'when two skips collide, favor the larger one' ' rm -rf server client trace && git init server && test_commit -C server to_fetch && git init client && - for i in $(seq 11) + for i in $(test_seq 11) do test_commit -C client c$i done && @@ -65,7 +101,7 @@ test_expect_success 'when two skips collide, favor the larger one' ' # the next "have" sent will be "c1" (from "c6" skip 4) and not "c4" # (from "c5side" skip 1). test_config -C client fetch.negotiationalgorithm skipping && - GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch "$(pwd)/server" && + trace_fetch client "$(pwd)/server" && have_sent c5side c11 c9 c6 c1 && have_not_sent c10 c8 c7 c5 c4 c3 c2 ' @@ -91,7 +127,7 @@ test_expect_success 'use ref advertisement to filter out commits' ' # not need to send any ancestors of "c3", but we still need to send "c3" # itself. test_config -C client fetch.negotiationalgorithm skipping && - GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch origin to_fetch && + trace_fetch client origin to_fetch && have_sent c5 c4^ c2side && have_not_sent c4 c4^^ c4^^^ ' @@ -121,7 +157,7 @@ test_expect_success 'handle clock skew' ' # and sent, because (due to clock skew) its only parent has already been # popped off the priority queue. test_config -C client fetch.negotiationalgorithm skipping && - GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch "$(pwd)/server" && + trace_fetch client "$(pwd)/server" && have_sent c2 c1 old4 old2 old1 && have_not_sent old3 ' @@ -132,14 +168,14 @@ test_expect_success 'do not send "have" with ancestors of commits that server AC test_commit -C server to_fetch && git init client && - for i in $(seq 8) + for i in $(test_seq 8) do git -C client checkout --orphan b$i && test_commit -C client b$i.c0 done && - for j in $(seq 19) + for j in $(test_seq 19) do - for i in $(seq 8) + for i in $(test_seq 8) do git -C client checkout b$i && test_commit -C client b$i.c$j @@ -153,7 +189,7 @@ test_expect_success 'do not send "have" with ancestors of commits that server AC test_commit -C server commit-on-b1 && test_config -C client fetch.negotiationalgorithm skipping && - GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch "$(pwd)/server" to_fetch && + trace_fetch client "$(pwd)/server" to_fetch && grep " fetch" trace && # fetch-pack sends 2 requests each containing 16 "have" lines before @@ -169,7 +205,7 @@ test_expect_success 'do not send "have" with ancestors of commits that server AC # fetch-pack should thus not send any more commits in the b1 branch, but # should still send the others (in this test, just check b2). - for i in $(seq 0 8) + for i in $(test_seq 0 8) do have_not_sent b1.c$i done && diff --git a/t/t5562-http-backend-content-length.sh b/t/t5562-http-backend-content-length.sh new file mode 100755 index 0000000000..f94d01f69e --- /dev/null +++ b/t/t5562-http-backend-content-length.sh @@ -0,0 +1,167 @@ +#!/bin/sh + +test_description='test git-http-backend respects CONTENT_LENGTH' +. ./test-lib.sh + +test_lazy_prereq GZIP 'gzip --version' + +verify_http_result() { + # some fatal errors still produce status 200 + # so check if there is the error message + if grep 'fatal:' act.err + then + return 1 + fi + + if ! grep "Status" act.out >act + then + printf "Status: 200 OK\r\n" >act + fi + printf "Status: $1\r\n" >exp && + test_cmp exp act +} + +test_http_env() { + handler_type="$1" + request_body="$2" + shift + env \ + CONTENT_TYPE="application/x-git-$handler_type-pack-request" \ + QUERY_STRING="/repo.git/git-$handler_type-pack" \ + PATH_TRANSLATED="$PWD/.git/git-$handler_type-pack" \ + GIT_HTTP_EXPORT_ALL=TRUE \ + REQUEST_METHOD=POST \ + "$TEST_DIRECTORY"/t5562/invoke-with-content-length.pl \ + "$request_body" git http-backend >act.out 2>act.err +} + +ssize_b100dots() { + # hardcoded ((size_t) SSIZE_MAX) + 1 + case "$(build_option sizeof-size_t)" in + 8) echo 9223372036854775808;; + 4) echo 2147483648;; + *) die "Unexpected ssize_t size: $(build_option sizeof-size_t)";; + esac +} + +test_expect_success 'setup' ' + HTTP_CONTENT_ENCODING="identity" && + export HTTP_CONTENT_ENCODING && + git config http.receivepack true && + test_commit c0 && + test_commit c1 && + hash_head=$(git rev-parse HEAD) && + hash_prev=$(git rev-parse HEAD~1) && + printf "want %s" "$hash_head" | packetize >fetch_body && + printf 0000 >>fetch_body && + printf "have %s" "$hash_prev" | packetize >>fetch_body && + printf done | packetize >>fetch_body && + test_copy_bytes 10 <fetch_body >fetch_body.trunc && + hash_next=$(git commit-tree -p HEAD -m next HEAD^{tree}) && + printf "%s %s refs/heads/newbranch\\0report-status\\n" "$_z40" "$hash_next" | packetize >push_body && + printf 0000 >>push_body && + echo "$hash_next" | git pack-objects --stdout >>push_body && + test_copy_bytes 10 <push_body >push_body.trunc && + : >empty_body +' + +test_expect_success GZIP 'setup, compression related' ' + gzip -c fetch_body >fetch_body.gz && + test_copy_bytes 10 <fetch_body.gz >fetch_body.gz.trunc && + gzip -c push_body >push_body.gz && + test_copy_bytes 10 <push_body.gz >push_body.gz.trunc +' + +test_expect_success 'fetch plain' ' + test_http_env upload fetch_body && + verify_http_result "200 OK" +' + +test_expect_success 'fetch plain truncated' ' + test_http_env upload fetch_body.trunc && + ! verify_http_result "200 OK" +' + +test_expect_success 'fetch plain empty' ' + test_http_env upload empty_body && + ! verify_http_result "200 OK" +' + +test_expect_success GZIP 'fetch gzipped' ' + test_env HTTP_CONTENT_ENCODING="gzip" test_http_env upload fetch_body.gz && + verify_http_result "200 OK" +' + +test_expect_success GZIP 'fetch gzipped truncated' ' + test_env HTTP_CONTENT_ENCODING="gzip" test_http_env upload fetch_body.gz.trunc && + ! verify_http_result "200 OK" +' + +test_expect_success GZIP 'fetch gzipped empty' ' + test_env HTTP_CONTENT_ENCODING="gzip" test_http_env upload empty_body && + ! verify_http_result "200 OK" +' + +test_expect_success GZIP 'push plain' ' + test_when_finished "git branch -D newbranch" && + test_http_env receive push_body && + verify_http_result "200 OK" && + git rev-parse newbranch >act.head && + echo "$hash_next" >exp.head && + test_cmp act.head exp.head +' + +test_expect_success 'push plain truncated' ' + test_http_env receive push_body.trunc && + ! verify_http_result "200 OK" +' + +test_expect_success 'push plain empty' ' + test_http_env receive empty_body && + ! verify_http_result "200 OK" +' + +test_expect_success GZIP 'push gzipped' ' + test_when_finished "git branch -D newbranch" && + test_env HTTP_CONTENT_ENCODING="gzip" test_http_env receive push_body.gz && + verify_http_result "200 OK" && + git rev-parse newbranch >act.head && + echo "$hash_next" >exp.head && + test_cmp act.head exp.head +' + +test_expect_success GZIP 'push gzipped truncated' ' + test_env HTTP_CONTENT_ENCODING="gzip" test_http_env receive push_body.gz.trunc && + ! verify_http_result "200 OK" +' + +test_expect_success GZIP 'push gzipped empty' ' + test_env HTTP_CONTENT_ENCODING="gzip" test_http_env receive empty_body && + ! verify_http_result "200 OK" +' + +test_expect_success 'CONTENT_LENGTH overflow ssite_t' ' + NOT_FIT_IN_SSIZE=$(ssize_b100dots) && + env \ + CONTENT_TYPE=application/x-git-upload-pack-request \ + QUERY_STRING=/repo.git/git-upload-pack \ + PATH_TRANSLATED="$PWD"/.git/git-upload-pack \ + GIT_HTTP_EXPORT_ALL=TRUE \ + REQUEST_METHOD=POST \ + CONTENT_LENGTH="$NOT_FIT_IN_SSIZE" \ + git http-backend </dev/zero >/dev/null 2>err && + grep "fatal:.*CONTENT_LENGTH" err +' + +test_expect_success 'empty CONTENT_LENGTH' ' + env \ + QUERY_STRING=/repo.git/HEAD \ + PATH_TRANSLATED="$PWD"/.git/HEAD \ + GIT_HTTP_EXPORT_ALL=TRUE \ + REQUEST_METHOD=GET \ + CONTENT_LENGTH="" \ + git http-backend <empty_body >act.out 2>act.err && + verify_http_result "200 OK" +' + +test_done diff --git a/t/t5562/invoke-with-content-length.pl b/t/t5562/invoke-with-content-length.pl new file mode 100755 index 0000000000..6c2aae7692 --- /dev/null +++ b/t/t5562/invoke-with-content-length.pl @@ -0,0 +1,37 @@ +#!/usr/bin/perl +use 5.008; +use strict; +use warnings; + +my $body_filename = $ARGV[0]; +my @command = @ARGV[1 .. $#ARGV]; + +# read data +my $body_size = -s $body_filename; +$ENV{"CONTENT_LENGTH"} = $body_size; +open(my $body_fh, "<", $body_filename) or die "Cannot open $body_filename: $!"; +my $body_data; +defined read($body_fh, $body_data, $body_size) or die "Cannot read $body_filename: $!"; +close($body_fh); + +my $exited = 0; +$SIG{"CHLD"} = sub { + $exited = 1; +}; + +# write data +my $pid = open(my $out, "|-", @command); +{ + # disable buffering at $out + my $old_selected = select; + select $out; + $| = 1; + select $old_selected; +} +print $out $body_data or die "Cannot write data: $!"; + +sleep 60; # is interrupted by SIGCHLD +if (!$exited) { + close($out); + die "Command did not exit after reading whole body"; +} diff --git a/t/t5570-git-daemon.sh b/t/t5570-git-daemon.sh index 0d4c52016b..7466aad111 100755 --- a/t/t5570-git-daemon.sh +++ b/t/t5570-git-daemon.sh @@ -7,9 +7,9 @@ test_description='test fetching over git protocol' start_git_daemon check_verbose_connect () { - grep -F "Looking up 127.0.0.1 ..." stderr && - grep -F "Connecting to 127.0.0.1 (port " stderr && - grep -F "done." stderr + test_i18ngrep -F "Looking up 127.0.0.1 ..." stderr && + test_i18ngrep -F "Connecting to 127.0.0.1 (port " stderr && + test_i18ngrep -F "done." stderr } test_expect_success 'setup repository' ' @@ -51,7 +51,7 @@ test_expect_success 'no-op fetch -v stderr is as expected' ' test_expect_success 'no-op fetch without "-v" is quiet' ' (cd clone && git fetch 2>../stderr) && - ! test -s stderr + test_must_be_empty stderr ' test_expect_success 'remote detects correct HEAD' ' diff --git a/t/t5612-clone-refspec.sh b/t/t5612-clone-refspec.sh index fac5a73851..5582b3d5fd 100755 --- a/t/t5612-clone-refspec.sh +++ b/t/t5612-clone-refspec.sh @@ -97,8 +97,7 @@ test_expect_success 'clone with --no-tags' ' git fetch && git for-each-ref refs/tags >../actual ) && - >expect && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success '--single-branch while HEAD pointing at master' ' @@ -140,8 +139,7 @@ test_expect_success '--single-branch while HEAD pointing at master and --no-tags git fetch && git for-each-ref refs/tags >../actual ) && - >expect && - test_cmp expect actual && + test_must_be_empty actual && test_line_count = 0 actual && # get tags with --tags overrides tagOpt ( @@ -230,8 +228,7 @@ test_expect_success '--single-branch with detached' ' -e "s|/remotes/origin/|/heads/|" >../actual ) && # nothing - >expect && - test_cmp expect actual + test_must_be_empty actual ' test_done diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh index a4fe6508bd..3beeed4546 100755 --- a/t/t5702-protocol-v2.sh +++ b/t/t5702-protocol-v2.sh @@ -181,7 +181,12 @@ test_expect_success 'clone with file:// using protocol v2' ' test_cmp expect actual && # Server responded using protocol v2 - grep "clone< version 2" log + grep "clone< version 2" log && + + # Client sent ref-prefixes to filter the ref-advertisement + grep "ref-prefix HEAD" log && + grep "ref-prefix refs/heads/" log && + grep "ref-prefix refs/tags/" log ' test_expect_success 'fetch with file:// using protocol v2' ' @@ -204,6 +209,7 @@ test_expect_success 'ref advertisment is filtered during fetch using protocol v2 test_when_finished "rm -f log" && test_commit -C file_parent three && + git -C file_parent branch unwanted-branch three && GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \ fetch origin master && @@ -212,9 +218,8 @@ test_expect_success 'ref advertisment is filtered during fetch using protocol v2 git -C file_parent log -1 --format=%s >expect && test_cmp expect actual && - ! grep "refs/tags/one" log && - ! grep "refs/tags/two" log && - ! grep "refs/tags/three" log + grep "refs/heads/master" log && + ! grep "refs/heads/unwanted-branch" log ' test_expect_success 'server-options are sent when fetching' ' @@ -359,6 +364,71 @@ test_expect_success 'default refspec is used to filter ref when fetchcing' ' grep "ref-prefix refs/tags/" log ' +test_expect_success 'fetch supports various ways of have lines' ' + rm -rf server client trace && + git init server && + test_commit -C server dwim && + TREE=$(git -C server rev-parse HEAD^{tree}) && + git -C server tag exact \ + $(git -C server commit-tree -m a "$TREE") && + git -C server tag dwim-unwanted \ + $(git -C server commit-tree -m b "$TREE") && + git -C server tag exact-unwanted \ + $(git -C server commit-tree -m c "$TREE") && + git -C server tag prefix1 \ + $(git -C server commit-tree -m d "$TREE") && + git -C server tag prefix2 \ + $(git -C server commit-tree -m e "$TREE") && + git -C server tag fetch-by-sha1 \ + $(git -C server commit-tree -m f "$TREE") && + git -C server tag completely-unrelated \ + $(git -C server commit-tree -m g "$TREE") && + + git init client && + GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \ + fetch "file://$(pwd)/server" \ + dwim \ + refs/tags/exact \ + refs/tags/prefix*:refs/tags/prefix* \ + "$(git -C server rev-parse fetch-by-sha1)" && + + # Ensure that the appropriate prefixes are sent (using a sample) + grep "fetch> ref-prefix dwim" trace && + grep "fetch> ref-prefix refs/heads/dwim" trace && + grep "fetch> ref-prefix refs/tags/prefix" trace && + + # Ensure that the correct objects are returned + git -C client cat-file -e $(git -C server rev-parse dwim) && + git -C client cat-file -e $(git -C server rev-parse exact) && + git -C client cat-file -e $(git -C server rev-parse prefix1) && + git -C client cat-file -e $(git -C server rev-parse prefix2) && + git -C client cat-file -e $(git -C server rev-parse fetch-by-sha1) && + test_must_fail git -C client cat-file -e \ + $(git -C server rev-parse dwim-unwanted) && + test_must_fail git -C client cat-file -e \ + $(git -C server rev-parse exact-unwanted) && + test_must_fail git -C client cat-file -e \ + $(git -C server rev-parse completely-unrelated) +' + +test_expect_success 'fetch supports include-tag and tag following' ' + rm -rf server client trace && + git init server && + + test_commit -C server to_fetch && + git -C server tag -a annotated_tag -m message && + + git init client && + GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \ + fetch "$(pwd)/server" to_fetch:to_fetch && + + grep "fetch> ref-prefix to_fetch" trace && + grep "fetch> ref-prefix refs/tags/" trace && + grep "fetch> include-tag" trace && + + git -C client cat-file -e $(git -C client rev-parse annotated_tag) +' + # Test protocol v2 with 'http://' transport # . "$TEST_DIRECTORY"/lib-httpd.sh diff --git a/t/t5703-upload-pack-ref-in-want.sh b/t/t5703-upload-pack-ref-in-want.sh index a73c55a47e..d1ccc22331 100755 --- a/t/t5703-upload-pack-ref-in-want.sh +++ b/t/t5703-upload-pack-ref-in-want.sh @@ -176,7 +176,7 @@ test_expect_success 'setup repos for change-while-negotiating test' ' git clone "http://127.0.0.1:$LIB_HTTPD_PORT/smart/repo" "$LOCAL_PRISTINE" && cd "$LOCAL_PRISTINE" && git checkout -b side && - for i in $(seq 1 33); do test_commit s$i; done && + for i in $(test_seq 1 33); do test_commit s$i; done && # Add novel commits to upstream git checkout master && @@ -289,7 +289,7 @@ test_expect_success 'setup repos for fetching with ref-in-want tests' ' git clone "file://$REPO" "$LOCAL_PRISTINE" && cd "$LOCAL_PRISTINE" && git checkout -b side && - for i in $(seq 1 33); do test_commit s$i; done && + for i in $(test_seq 1 33); do test_commit s$i; done && # Add novel commits to upstream git checkout master && diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh index ee5757966f..aaaa722cca 100755 --- a/t/t5801-remote-helpers.sh +++ b/t/t5801-remote-helpers.sh @@ -126,7 +126,7 @@ test_expect_success 'forced push' ' test_expect_success 'cloning without refspec' ' GIT_REMOTE_TESTGIT_REFSPEC="" \ git clone "testgit::${PWD}/server" local2 2>error && - grep "This remote helper should implement refspec capability" error && + test_i18ngrep "this remote helper should implement refspec capability" error && compare_refs local2 HEAD server HEAD ' @@ -134,7 +134,7 @@ test_expect_success 'pulling without refspecs' ' (cd local2 && git reset --hard && GIT_REMOTE_TESTGIT_REFSPEC="" git pull 2>../error) && - grep "This remote helper should implement refspec capability" error && + test_i18ngrep "this remote helper should implement refspec capability" error && compare_refs local2 HEAD server HEAD ' @@ -146,7 +146,7 @@ test_expect_success 'pushing without refspecs' ' GIT_REMOTE_TESTGIT_REFSPEC="" && export GIT_REMOTE_TESTGIT_REFSPEC && test_must_fail git push 2>../error) && - grep "remote-helper doesn.t support push; refspec needed" error + test_i18ngrep "remote-helper doesn.t support push; refspec needed" error ' test_expect_success 'pulling without marks' ' @@ -246,7 +246,7 @@ test_expect_success 'proper failure checks for fetching' ' (cd local && test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 git fetch 2>error && cat error && - grep -q "Error while running fast-import" error + test_i18ngrep -q "error while running fast-import" error ) ' diff --git a/t/t6000-rev-list-misc.sh b/t/t6000-rev-list-misc.sh index 969e4e9e52..fb4d295aa0 100755 --- a/t/t6000-rev-list-misc.sh +++ b/t/t6000-rev-list-misc.sh @@ -58,8 +58,7 @@ test_expect_success 'rev-list A..B and rev-list ^A B are the same' ' test_expect_success 'propagate uninteresting flag down correctly' ' git rev-list --objects ^HEAD^{tree} HEAD^{tree} >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'symleft flag bit is propagated down from tag' ' diff --git a/t/t6009-rev-list-parent.sh b/t/t6009-rev-list-parent.sh index 20e3e2554a..916d9692bc 100755 --- a/t/t6009-rev-list-parent.sh +++ b/t/t6009-rev-list-parent.sh @@ -31,8 +31,7 @@ test_expect_success setup ' test_expect_success 'one is ancestor of others and should not be shown' ' git rev-list one --not four >result && - >expect && - test_cmp expect result + test_must_be_empty result ' @@ -144,8 +143,7 @@ test_expect_success 'ancestors with the same commit time' ' test_commit t$i done && git rev-list t1^! --not t$i >result && - >expect && - test_cmp expect result + test_must_be_empty result ' test_done diff --git a/t/t6018-rev-list-glob.sh b/t/t6018-rev-list-glob.sh index d3453c583c..0bf10d0686 100755 --- a/t/t6018-rev-list-glob.sh +++ b/t/t6018-rev-list-glob.sh @@ -256,31 +256,27 @@ test_expect_success 'rev-list accumulates multiple --exclude' ' ' test_expect_failure 'rev-list should succeed with empty output on empty stdin' ' - >expect && - git rev-list --stdin <expect >actual && - test_cmp expect actual + git rev-list --stdin </dev/null >actual && + test_must_be_empty actual ' test_expect_success 'rev-list should succeed with empty output with all refs excluded' ' - >expect && git rev-list --exclude=* --all >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'rev-list should succeed with empty output with empty --all' ' ( test_create_repo empty && cd empty && - >expect && git rev-list --all >actual && - test_cmp expect actual + test_must_be_empty actual ) ' test_expect_success 'rev-list should succeed with empty output with empty glob' ' - >expect && git rev-list --glob=does-not-match-anything >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'shortlog accepts --glob/--tags/--remotes' ' diff --git a/t/t6019-rev-list-ancestry-path.sh b/t/t6019-rev-list-ancestry-path.sh index dabebaee0b..beadaf6cca 100755 --- a/t/t6019-rev-list-ancestry-path.sh +++ b/t/t6019-rev-list-ancestry-path.sh @@ -95,10 +95,9 @@ test_expect_success 'rev-list --ancestry-path F...I' ' # G.t is dropped in an "-s ours" merge test_expect_success 'rev-list G..M -- G.t' ' - >expect && git rev-list --format=%s G..M -- G.t | sed -e "/^commit /d" >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'rev-list --ancestry-path G..M -- G.t' ' diff --git a/t/t6020-merge-df.sh b/t/t6020-merge-df.sh index 2af1beec5f..46b506b3b7 100755 --- a/t/t6020-merge-df.sh +++ b/t/t6020-merge-df.sh @@ -89,9 +89,6 @@ test_expect_success 'modify/delete + directory/file conflict' ' ' test_expect_success 'modify/delete + directory/file conflict; other way' ' - # Yes, we really need the double reset since "letters" appears as - # both a file and a directory. - git reset --hard && git reset --hard && git clean -f && git checkout modify^0 && diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh index b760c223c6..53cc9b2ffb 100755 --- a/t/t6022-merge-rename.sh +++ b/t/t6022-merge-rename.sh @@ -893,8 +893,7 @@ test_expect_success 'do not follow renames for empty files' ' git mv empty1 empty2 && git commit -m rename && test_must_fail git merge empty-base && - >expect && - test_cmp expect empty2 + test_must_be_empty empty2 ' test_done diff --git a/t/t6029-merge-subtree.sh b/t/t6029-merge-subtree.sh index 7d5bc78472..793f0c8bf3 100755 --- a/t/t6029-merge-subtree.sh +++ b/t/t6029-merge-subtree.sh @@ -29,6 +29,34 @@ test_expect_success 'subtree available and works like recursive' ' ' +test_expect_success 'setup branch sub' ' + git checkout --orphan sub && + git rm -rf . && + test_commit foo +' + +test_expect_success 'setup branch main' ' + git checkout -b main master && + git merge -s ours --no-commit --allow-unrelated-histories sub && + git read-tree --prefix=dir/ -u sub && + git commit -m "initial merge of sub into main" && + test_path_is_file dir/foo.t && + test_path_is_file hello +' + +test_expect_success 'update branch sub' ' + git checkout sub && + test_commit bar +' + +test_expect_success 'update branch main' ' + git checkout main && + git merge -s subtree sub -m "second merge of sub into main" && + test_path_is_file dir/bar.t && + test_path_is_file dir/foo.t && + test_path_is_file hello +' + test_expect_success 'setup' ' mkdir git-gui && cd git-gui && diff --git a/t/t6042-merge-rename-corner-cases.sh b/t/t6042-merge-rename-corner-cases.sh index 07dd09d985..b97aca7fa2 100755 --- a/t/t6042-merge-rename-corner-cases.sh +++ b/t/t6042-merge-rename-corner-cases.sh @@ -324,7 +324,6 @@ test_expect_success 'rename/directory conflict + content merge conflict' ' cd rename-directory-1 && git reset --hard && - git reset --hard && git clean -fdqx && git checkout left-conflict^0 && diff --git a/t/t6060-merge-index.sh b/t/t6060-merge-index.sh index debadbd299..ddf34f0115 100755 --- a/t/t6060-merge-index.sh +++ b/t/t6060-merge-index.sh @@ -44,8 +44,7 @@ test_expect_success 'read-tree does not resolve content merge' ' test_expect_success 'git merge-index git-merge-one-file resolves' ' git merge-index git-merge-one-file -a && git diff-files --name-only --diff-filter=U >unmerged && - >expect && - test_cmp expect unmerged && + test_must_be_empty unmerged && test_cmp expect-merged file && git cat-file blob :file >file-index && test_cmp expect-merged file-index diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh index 0a37dd5f97..d4ff0b3bef 100755 --- a/t/t6112-rev-list-filters-objects.sh +++ b/t/t6112-rev-list-filters-objects.sh @@ -113,12 +113,11 @@ test_expect_success 'verify blob:limit=1k' ' ' test_expect_success 'verify blob:limit=1m' ' - cat </dev/null >expected && git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1m \ | awk -f print_1.awk \ | sed "s/~//" \ | sort >observed && - test_cmp observed expected + test_must_be_empty observed ' # Test sparse:path=<path> filter. diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh index 84dd1cb690..d639d94696 100755 --- a/t/t6120-describe.sh +++ b/t/t6120-describe.sh @@ -121,10 +121,9 @@ test_expect_success 'describe --contains defaults to HEAD without commit-ish' ' test_cmp expect actual ' -: >err.expect check_describe tags/A --all A^0 test_expect_success 'no warning was displayed for A' ' - test_cmp err.expect err.actual + test_must_be_empty err.actual ' test_expect_success 'rename tag A to Q locally' ' diff --git a/t/t6130-pathspec-noglob.sh b/t/t6130-pathspec-noglob.sh index 658353277e..37760233a5 100755 --- a/t/t6130-pathspec-noglob.sh +++ b/t/t6130-pathspec-noglob.sh @@ -97,9 +97,8 @@ test_expect_success 'no-glob option matches literally (bracket)' ' ' test_expect_success 'no-glob option disables :(literal)' ' - : >expect && git --literal-pathspecs log --format=%s -- ":(literal)foo" >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'no-glob environment variable works' ' @@ -130,9 +129,8 @@ test_expect_success '**/ works with :(glob)' ' ' test_expect_success '**/ does not work with --noglob-pathspecs' ' - : >expect && git --noglob-pathspecs log --format=%s -- "**/bar" >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success '**/ works with :(glob) and --noglob-pathspecs' ' @@ -154,9 +152,8 @@ test_expect_success '**/ works with --glob-pathspecs' ' ' test_expect_success '**/ does not work with :(literal) and --glob-pathspecs' ' - : >expect && git --glob-pathspecs log --format=%s -- ":(literal)**/bar" >actual && - test_cmp expect actual + test_must_be_empty actual ' test_done diff --git a/t/t6135-pathspec-with-attrs.sh b/t/t6135-pathspec-with-attrs.sh index 77b8cef661..e436a73962 100755 --- a/t/t6135-pathspec-with-attrs.sh +++ b/t/t6135-pathspec-with-attrs.sh @@ -166,7 +166,7 @@ test_expect_success 'fail if attr magic is used places not implemented' ' # though, but git-add is convenient as it has its own internal pathspec # parsing. test_must_fail git add ":(attr:labelB)" 2>actual && - test_i18ngrep "unsupported magic" actual + test_i18ngrep "magic not supported" actual ' test_expect_success 'abort on giving invalid label on the command line' ' diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh index a54a52aaa4..93f23cfa82 100755 --- a/t/t6200-fmt-merge-msg.sh +++ b/t/t6200-fmt-merge-msg.sh @@ -366,8 +366,6 @@ test_expect_success 'merge-msg with nothing to merge' ' test_unconfig merge.log && test_config merge.summary yes && - >empty && - ( cd remote && git checkout -b unrelated && @@ -376,7 +374,7 @@ test_expect_success 'merge-msg with nothing to merge' ' git fmt-merge-msg <.git/FETCH_HEAD >../actual ) && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'merge-msg tag' ' diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh index e0496da812..97bfbee6e8 100755 --- a/t/t6300-for-each-ref.sh +++ b/t/t6300-for-each-ref.sh @@ -715,6 +715,29 @@ test_expect_success 'basic atom: head contents:trailers' ' test_cmp expect actual.clean ' +test_expect_success 'trailer parsing not fooled by --- line' ' + git commit --allow-empty -F - <<-\EOF && + this is the subject + + This is the body. The message has a "---" line which would confuse a + message+patch parser. But here we know we have only a commit message, + so we get it right. + + trailer: wrong + --- + This is more body. + + trailer: right + EOF + + { + echo "trailer: right" && + echo + } >expect && + git for-each-ref --format="%(trailers)" refs/heads/master >actual && + test_cmp expect actual +' + test_expect_success 'Add symbolic ref for the following tests' ' git symbolic-ref refs/heads/sym refs/heads/master ' @@ -796,9 +819,8 @@ test_expect_success ':remotename and :remoteref' ' ' test_expect_success 'for-each-ref --ignore-case ignores case' ' - >expect && git for-each-ref --format="%(refname)" refs/heads/MASTER >actual && - test_cmp expect actual && + test_must_be_empty actual && echo refs/heads/master >expect && git for-each-ref --format="%(refname)" --ignore-case \ diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh index 9e59e5a5dd..36b50d0b4c 100755 --- a/t/t7001-mv.sh +++ b/t/t7001-mv.sh @@ -384,7 +384,7 @@ test_expect_success 'mv does not complain when no .gitmodules file is found' ' entry="$(git ls-files --stage sub | cut -f 1)" && mkdir mod && git mv sub mod/sub 2>actual.err && - ! test -s actual.err && + test_must_be_empty actual.err && ! test -e sub && [ "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" ] && ( @@ -408,7 +408,7 @@ test_expect_success 'mv will error out on a modified .gitmodules file unless sta git diff-files --quiet -- sub && git add .gitmodules && git mv sub mod/sub 2>actual.err && - ! test -s actual.err && + test_must_be_empty actual.err && ! test -e sub && [ "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" ] && ( @@ -469,7 +469,7 @@ test_expect_success 'checking out a commit before submodule moved needs manual u git update-index --refresh && git diff-files --quiet -- sub .gitmodules && git status -s sub2 >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'mv -k does not accidentally destroy submodules' ' diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh index d7b319e919..0b01862c23 100755 --- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh @@ -325,11 +325,10 @@ test_expect_success \ test_cmp expect actual ' ->expect test_expect_success \ 'listing tags using v.* should print nothing because none have v.' ' git tag -l "v.*" > actual && - test_cmp expect actual + test_must_be_empty actual ' cat >expect <<EOF @@ -693,9 +692,8 @@ test_expect_success \ ' test_expect_success 'The -n 100 invocation means -n --list 100, not -n100' ' - >expect && git tag -n 100 >actual && - test_cmp expect actual && + test_must_be_empty actual && git tag -m "A msg" 100 && echo "100 A msg" >expect && @@ -974,9 +972,8 @@ test_expect_success GPG 'verifying a proper tag with --format pass and format ac ' test_expect_success GPG 'verifying a forged tag with --format should fail silently' ' - >expect && test_must_fail git tag -v --format="tagname : %(tag)" "forged-tag" >actual && - test_cmp expect actual + test_must_be_empty actual ' # blank and empty messages for signed tags: @@ -1354,6 +1351,19 @@ test_expect_success GPG \ 'test_config gpg.program echo && test_must_fail git tag -s -m tail tag-gpg-failure' +# try to sign with bad user.signingkey +test_expect_success GPGSM \ + 'git tag -s fails if gpgsm is misconfigured (bad key)' \ + 'test_config user.signingkey BobTheMouse && + test_config gpg.format x509 && + test_must_fail git tag -s -m tail tag-gpg-failure' + +# try to produce invalid signature +test_expect_success GPGSM \ + 'git tag -s fails if gpgsm is misconfigured (bad signature format)' \ + 'test_config gpg.x509.program echo && + test_config gpg.format x509 && + test_must_fail git tag -s -m tail tag-gpg-failure' # try to verify without gpg: @@ -1382,9 +1392,8 @@ test_expect_success 'message in editor has initial comment: first line' ' test_expect_success \ 'message in editor has initial comment: remainder' ' # remove commented lines from the remainder -- should be empty - >rest.expect && sed -e 1d -e "/^#/d" <actual >rest.actual && - test_cmp rest.expect rest.actual + test_must_be_empty rest.actual ' get_tag_header reuse $commit commit $time >expect @@ -1466,19 +1475,18 @@ test_expect_success 'checking that first commit is in all tags (relative)' " # All the --contains tests above, but with --no-contains test_expect_success 'checking that first commit is not listed in any tag with --no-contains (hash)' " - >expected && git tag -l --no-contains $hash1 v* >actual && - test_cmp expected actual + test_must_be_empty actual " test_expect_success 'checking that first commit is in all tags (tag)' " git tag -l --no-contains v1.0 v* >actual && - test_cmp expected actual + test_must_be_empty actual " test_expect_success 'checking that first commit is in all tags (relative)' " git tag -l --no-contains HEAD~2 v* >actual && - test_cmp expected actual + test_must_be_empty actual " cat > expected <<EOF @@ -1502,12 +1510,9 @@ test_expect_success 'inverse of the last test, with --no-contains' " test_cmp expected actual " -cat > expected <<EOF -EOF - test_expect_success 'checking that third commit has no tags' " git tag -l --contains $hash3 v* >actual && - test_cmp expected actual + test_must_be_empty actual " cat > expected <<EOF @@ -1606,9 +1611,8 @@ test_expect_success 'checking that --contains can be used in non-list mode' ' ' test_expect_success 'checking that initial commit is in all tags with --no-contains' " - >expected && git tag -l --no-contains $hash1 v* >actual && - test_cmp expected actual + test_must_be_empty actual " # mixing modes and options: @@ -1905,7 +1909,6 @@ test_expect_success 'version sort with very long prerelease suffix' ' ' test_expect_success ULIMIT_STACK_SIZE '--contains and --no-contains work in a deep repo' ' - >expect && i=1 && while test $i -lt 8000 do @@ -1920,7 +1923,7 @@ EOF" git checkout master && git tag far-far-away HEAD^ && run_with_limited_stack git tag --contains HEAD >actual && - test_cmp expect actual && + test_must_be_empty actual && run_with_limited_stack git tag --no-contains HEAD >actual && test_line_count "-gt" 10 actual ' diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh index 7541ba5edb..00e09a375c 100755 --- a/t/t7006-pager.sh +++ b/t/t7006-pager.sh @@ -626,12 +626,11 @@ test_expect_success TTY 'sub-commands of externals use their own pager' ' test_expect_success TTY 'external command pagers override sub-commands' ' sane_unset PAGER GIT_PAGER && - >expect && >actual && test_config pager.external false && test_config pager.log "sed s/^/log:/ >actual" && test_terminal git --exec-path=. external log --format=%s -1 && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'command with underscores does not complain' ' diff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh index 615e7e0162..2d87c49b75 100755 --- a/t/t7008-grep-binary.sh +++ b/t/t7008-grep-binary.sh @@ -57,9 +57,8 @@ test_expect_success 'git grep -ah ina a' ' ' test_expect_success 'git grep -I ina a' ' - : >expect && test_must_fail git grep -I ina a >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'git grep -c ina a' ' @@ -81,9 +80,8 @@ test_expect_success 'git grep -L bar a' ' ' test_expect_success 'git grep -q ina a' ' - : >expect && git grep -q ina a >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'git grep -F ile a' ' diff --git a/t/t7030-verify-tag.sh b/t/t7030-verify-tag.sh index 291a1e2b07..041e319e79 100755 --- a/t/t7030-verify-tag.sh +++ b/t/t7030-verify-tag.sh @@ -41,6 +41,13 @@ test_expect_success GPG 'create signed tags' ' git tag -uB7227189 -m eighth eighth-signed-alt ' +test_expect_success GPGSM 'create signed tags x509 ' ' + test_config gpg.format x509 && + test_config user.signingkey $GIT_COMMITTER_EMAIL && + echo 9 >file && test_tick && git commit -a -m "nineth gpgsm-signed" && + git tag -s -m nineth nineth-signed-x509 +' + test_expect_success GPG 'verify and show signatures' ' ( for tag in initial second merge fourth-signed sixth-signed seventh-signed @@ -72,6 +79,13 @@ test_expect_success GPG 'verify and show signatures' ' ) ' +test_expect_success GPGSM 'verify and show signatures x509' ' + git verify-tag nineth-signed-x509 2>actual && + grep "Good signature from" actual && + ! grep "BAD signature from" actual && + echo nineth-signed-x509 OK +' + test_expect_success GPG 'detect fudged signature' ' git cat-file tag seventh-signed >raw && sed -e "/^tag / s/seventh/7th forged/" raw >forged1 && @@ -112,6 +126,13 @@ test_expect_success GPG 'verify signatures with --raw' ' ) ' +test_expect_success GPGSM 'verify signatures with --raw x509' ' + git verify-tag --raw nineth-signed-x509 2>actual && + grep "GOODSIG" actual && + ! grep "BADSIG" actual && + echo nineth-signed-x509 OK +' + test_expect_success GPG 'verify multiple tags' ' tags="fourth-signed sixth-signed seventh-signed" && for i in $tags @@ -125,6 +146,19 @@ test_expect_success GPG 'verify multiple tags' ' test_cmp expect.stderr actual.stderr ' +test_expect_success GPGSM 'verify multiple tags x509' ' + tags="seventh-signed nineth-signed-x509" && + for i in $tags + do + git verify-tag -v --raw $i || return 1 + done >expect.stdout 2>expect.stderr.1 && + grep "^.GNUPG:." <expect.stderr.1 >expect.stderr && + git verify-tag -v --raw $tags >actual.stdout 2>actual.stderr.1 && + grep "^.GNUPG:." <actual.stderr.1 >actual.stderr && + test_cmp expect.stdout actual.stdout && + test_cmp expect.stderr actual.stderr +' + test_expect_success GPG 'verifying tag with --format' ' cat >expect <<-\EOF && tagname : fourth-signed @@ -134,9 +168,8 @@ test_expect_success GPG 'verifying tag with --format' ' ' test_expect_success GPG 'verifying a forged tag with --format should fail silently' ' - >expect && test_must_fail git verify-tag --format="tagname : %(tag)" $(cat forged1.tag) >actual-forged && - test_cmp expect actual-forged + test_must_be_empty actual-forged ' test_done diff --git a/t/t7063-status-untracked-cache.sh b/t/t7063-status-untracked-cache.sh index c61e304e97..2da57fce7b 100755 --- a/t/t7063-status-untracked-cache.sh +++ b/t/t7063-status-untracked-cache.sh @@ -26,9 +26,8 @@ avoid_racy() { } status_is_clean() { - >../status.expect && git status --porcelain >../status.actual && - test_cmp ../status.expect ../status.actual + test_must_be_empty ../status.actual } test_lazy_prereq UNTRACKED_CACHE ' @@ -666,7 +665,7 @@ test_expect_success 'test ident field is working' ' mkdir ../other_worktree && cp -R done dthree dtwo four three ../other_worktree && GIT_WORK_TREE=../other_worktree git status 2>../err && - echo "warning: Untracked cache is disabled on this system or location." >../expect && + echo "warning: untracked cache is disabled on this system or location" >../expect && test_i18ncmp ../expect ../err ' diff --git a/t/t7064-wtstatus-pv2.sh b/t/t7064-wtstatus-pv2.sh index b9a86d3347..11eccc231a 100755 --- a/t/t7064-wtstatus-pv2.sh +++ b/t/t7064-wtstatus-pv2.sh @@ -364,11 +364,8 @@ test_expect_success 'verify upstream fields in branch header' ' test_cmp expect actual && ## Repeat the above but without --branch. - cat >expect <<-EOF && - EOF - git status --porcelain=v2 --untracked-files=all >actual && - test_cmp expect actual && + test_must_be_empty actual && ## Test upstream-gone case. Fake this by pointing origin/master at ## a non-existing commit. diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh index 95653a08ca..97be0d968d 100755 --- a/t/t7102-reset.sh +++ b/t/t7102-reset.sh @@ -549,8 +549,7 @@ test_expect_success 'reset -N keeps removed files as intent-to-add' ' tree=$(git write-tree) && git ls-tree $tree new-file >actual && - >expect && - test_cmp expect actual && + test_must_be_empty actual && git diff --name-only >actual && echo new-file >expect && @@ -563,9 +562,8 @@ test_expect_success 'reset --mixed sets up work tree' ' cd mixed_worktree && test_commit dummy ) && - : >expect && git --git-dir=mixed_worktree/.git --work-tree=mixed_worktree reset >actual && - test_cmp expect actual + test_must_be_empty actual ' test_done diff --git a/t/t7106-reset-unborn-branch.sh b/t/t7106-reset-unborn-branch.sh index 0f95f00477..ecb85c3b82 100755 --- a/t/t7106-reset-unborn-branch.sh +++ b/t/t7106-reset-unborn-branch.sh @@ -12,9 +12,8 @@ test_expect_success 'reset' ' git add a b && git reset && - >expect && git ls-files >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'reset HEAD' ' @@ -39,9 +38,8 @@ test_expect_success PERL 'reset -p' ' echo y >yes && git reset -p <yes >output && - >expect && git ls-files >actual && - test_cmp expect actual && + test_must_be_empty actual && test_i18ngrep "Unstage" output ' @@ -61,9 +59,8 @@ test_expect_success 'reset --hard' ' test_when_finished "echo a >a" && git reset --hard && - >expect && git ls-files >actual && - test_cmp expect actual && + test_must_be_empty actual && test_path_is_missing a ' diff --git a/t/t7201-co.sh b/t/t7201-co.sh index 94cb039a03..324933acfe 100755 --- a/t/t7201-co.sh +++ b/t/t7201-co.sh @@ -116,9 +116,8 @@ test_expect_success "checkout -m with dirty tree" ' git diff --name-status side >current.side && test_cmp expect.side current.side && - : >expect.index && git diff --cached >current.index && - test_cmp expect.index current.index + test_must_be_empty current.index ' test_expect_success "checkout -m with dirty tree, renamed" ' @@ -139,7 +138,7 @@ test_expect_success "checkout -m with dirty tree, renamed" ' test_cmp expect uno && ! test -f one && git diff --cached >current && - ! test -s current + test_must_be_empty current ' @@ -163,7 +162,7 @@ test_expect_success 'checkout -m with merge conflict' ' fill d2 aT d7 aS >expect && test_cmp current expect && git diff --cached two >current && - ! test -s current + test_must_be_empty current ' test_expect_success 'format of merge conflict from checkout -m' ' diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index 2c2c97e144..c0ffc1022a 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -101,7 +101,6 @@ inspect() { test_expect_success 'submodule add' ' echo "refs/heads/master" >expect && - >empty && ( cd addtest && @@ -123,7 +122,7 @@ test_expect_success 'submodule add' ' inspect addtest/submod ../.. && test_cmp expect heads && test_cmp expect head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success 'setup parent and one repository' ' @@ -189,7 +188,6 @@ test_expect_success 'submodule add --branch' ' refs/heads/initial refs/heads/master EOF - >empty && ( cd addtest && @@ -202,12 +200,11 @@ test_expect_success 'submodule add --branch' ' inspect addtest/submod-branch ../.. && test_cmp expect-heads heads && test_cmp expect-head head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success 'submodule add with ./ in path' ' echo "refs/heads/master" >expect && - >empty && ( cd addtest && @@ -219,12 +216,11 @@ test_expect_success 'submodule add with ./ in path' ' inspect addtest/dotsubmod/frotz ../../.. && test_cmp expect heads && test_cmp expect head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success 'submodule add with /././ in path' ' echo "refs/heads/master" >expect && - >empty && ( cd addtest && @@ -236,12 +232,11 @@ test_expect_success 'submodule add with /././ in path' ' inspect addtest/dotslashdotsubmod/frotz ../../.. && test_cmp expect heads && test_cmp expect head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success 'submodule add with // in path' ' echo "refs/heads/master" >expect && - >empty && ( cd addtest && @@ -253,12 +248,11 @@ test_expect_success 'submodule add with // in path' ' inspect addtest/slashslashsubmod/frotz ../../.. && test_cmp expect heads && test_cmp expect head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success 'submodule add with /.. in path' ' echo "refs/heads/master" >expect && - >empty && ( cd addtest && @@ -270,12 +264,11 @@ test_expect_success 'submodule add with /.. in path' ' inspect addtest/realsubmod ../.. && test_cmp expect heads && test_cmp expect head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success 'submodule add with ./, /.. and // in path' ' echo "refs/heads/master" >expect && - >empty && ( cd addtest && @@ -287,7 +280,7 @@ test_expect_success 'submodule add with ./, /.. and // in path' ' inspect addtest/realsubmod2 ../.. && test_cmp expect heads && test_cmp expect head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success !CYGWIN 'submodule add with \\ in path' ' @@ -306,7 +299,6 @@ test_expect_success !CYGWIN 'submodule add with \\ in path' ' test_expect_success 'submodule add in subdirectory' ' echo "refs/heads/master" >expect && - >empty && mkdir addtest/sub && ( @@ -319,7 +311,7 @@ test_expect_success 'submodule add in subdirectory' ' inspect addtest/realsubmod3 ../.. && test_cmp expect heads && test_cmp expect head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success 'submodule add in subdirectory with relative path should fail' ' @@ -378,7 +370,7 @@ test_expect_success 'init should register submodule url in .git/config' ' test_failure_with_unknown_submodule () { test_must_fail git submodule $1 no-such-submodule 2>output.err && - grep "^error: .*no-such-submodule" output.err + test_i18ngrep "^error: .*no-such-submodule" output.err } test_expect_success 'init should fail with unknown submodule' ' @@ -502,8 +494,6 @@ test_expect_success 'checkout superproject with subproject already present' ' ' test_expect_success 'apply submodule diff' ' - >empty && - git branch second && ( cd init && @@ -518,7 +508,7 @@ test_expect_success 'apply submodule diff' ' git apply --index P.diff && git diff --cached master >staged && - test_cmp empty staged + test_must_be_empty staged ' test_expect_success 'update --init' ' @@ -994,11 +984,6 @@ test_expect_success 'submodule deinit should remove the whole submodule section rmdir init ' -test_expect_success 'submodule deinit should unset core.worktree' ' - test_path_is_file .git/modules/example/config && - test_must_fail git config -f .git/modules/example/config core.worktree -' - test_expect_success 'submodule deinit from subdirectory' ' git submodule update --init && git config submodule.example.foo bar && diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh index 4e4c455502..9bc841d085 100755 --- a/t/t7401-submodule-summary.sh +++ b/t/t7401-submodule-summary.sh @@ -64,8 +64,7 @@ test_expect_success 'added submodule (subdirectory only)' " cd sub && git submodule summary . >../actual ) && - >expected && - test_cmp expected actual + test_must_be_empty actual " test_expect_success 'added submodule (subdirectory with explicit path)' " @@ -301,7 +300,7 @@ test_expect_success 'should not fail in an empty repo' " git init xyzzy && cd xyzzy && git submodule summary >output 2>&1 && - test_cmp output /dev/null + test_must_be_empty output " test_done diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh index 686e6a439e..10dc91620a 100755 --- a/t/t7406-submodule-update.sh +++ b/t/t7406-submodule-update.sh @@ -175,7 +175,7 @@ test_expect_success 'submodule update does not fetch already present commits' ' git submodule update > ../actual 2> ../actual.err ) && test_i18ncmp expected actual && - ! test -s actual.err + test_must_be_empty actual.err ' test_expect_success 'submodule update should fail due to local changes' ' @@ -482,7 +482,8 @@ test_expect_success 'recursive submodule update - command in .git/config catches test_expect_success 'submodule init does not copy command into .git/config' ' (cd super && - H=$(git ls-files -s submodule | cut -d" " -f2) && + git ls-files -s submodule >out && + H=$(cut -d" " -f2 out) && mkdir submodule1 && git update-index --add --cacheinfo 160000 $H submodule1 && git config -f .gitmodules submodule.submodule1.path submodule1 && @@ -580,9 +581,11 @@ test_expect_success 'submodule update - update=none in .git/config' ' git checkout master && compare_head ) && - git diff --raw | grep " submodule" && + git diff --name-only >out && + grep ^submodule$ out && git submodule update && - git diff --raw | grep " submodule" && + git diff --name-only >out && + grep ^submodule$ out && (cd submodule && compare_head ) && @@ -598,11 +601,13 @@ test_expect_success 'submodule update - update=none in .git/config but --checkou git checkout master && compare_head ) && - git diff --raw | grep " submodule" && + git diff --name-only >out && + grep ^submodule$ out && git submodule update --checkout && - test_must_fail git diff --raw \| grep " submodule" && + git diff --name-only >out && + ! grep ^submodule$ out && (cd submodule && - test_must_fail compare_head + ! compare_head ) && git config --unset submodule.submodule.update ) @@ -616,8 +621,8 @@ test_expect_success 'submodule update --init skips submodule with update=none' ' git clone super cloned && (cd cloned && git submodule update --init && - test -e submodule/.git && - test_must_fail test -e none/.git + test_path_exists submodule/.git && + test_path_is_missing none/.git ) ' @@ -886,7 +891,8 @@ test_expect_success 'submodule update properly revives a moved submodule' ' H=$(git rev-parse --short HEAD) && git commit -am "pre move" && H2=$(git rev-parse --short HEAD) && - git status | sed "s/$H/XXX/" >expect && + git status >out && + sed "s/$H/XXX/" out >expect && H=$(cd submodule2 && git rev-parse HEAD) && git rm --cached submodule2 && rm -rf submodule2 && @@ -895,7 +901,8 @@ test_expect_success 'submodule update properly revives a moved submodule' ' git config -f .gitmodules submodule.submodule2.path "moved/sub module" && git commit -am "post move" && git submodule update && - git status | sed "s/$H2/XXX/" >actual && + git status > out && + sed "s/$H2/XXX/" out >actual && test_cmp expect actual ) ' @@ -913,7 +920,7 @@ test_expect_success SYMLINKS 'submodule update can handle symbolic links in pwd' test_expect_success 'submodule update clone shallow submodule' ' test_when_finished "rm -rf super3" && - first=$(git -C cloned submodule status submodule |cut -c2-41) && + first=$(git -C cloned rev-parse HEAD:submodule) && second=$(git -C submodule rev-parse HEAD) && commit_count=$(git -C submodule rev-list --count $first^..$second) && git clone cloned super3 && @@ -923,7 +930,8 @@ test_expect_success 'submodule update clone shallow submodule' ' sed -e "s#url = ../#url = file://$pwd/#" <.gitmodules >.gitmodules.tmp && mv -f .gitmodules.tmp .gitmodules && git submodule update --init --depth=$commit_count && - test 1 = $(git -C submodule log --oneline | wc -l) + git -C submodule log --oneline >out && + test_line_count = 1 out ) ' @@ -939,7 +947,8 @@ test_expect_success 'submodule update clone shallow submodule outside of depth' test_i18ngrep "Direct fetching of that commit failed." actual && git -C ../submodule config uploadpack.allowReachableSHA1InWant true && git submodule update --init --depth=1 >actual && - test 1 = $(git -C submodule log --oneline | wc -l) + git -C submodule log --oneline >out && + test_line_count = 1 out ) ' diff --git a/t/t7410-submodule-checkout-to.sh b/t/t7410-submodule-checkout-to.sh index 1acef32647..f1b492ebc4 100755 --- a/t/t7410-submodule-checkout-to.sh +++ b/t/t7410-submodule-checkout-to.sh @@ -6,55 +6,72 @@ test_description='Combination of submodules and multiple workdirs' base_path=$(pwd -P) -test_expect_success 'setup: make origin' \ - 'mkdir -p origin/sub && ( cd origin/sub && git init && - echo file1 >file1 && - git add file1 && - git commit -m file1 ) && - mkdir -p origin/main && ( cd origin/main && git init && - git submodule add ../sub && - git commit -m "add sub" ) && - ( cd origin/sub && - echo file1updated >file1 && - git add file1 && - git commit -m "file1 updated" ) && - ( cd origin/main/sub && git pull ) && - ( cd origin/main && - git add sub && - git commit -m "sub updated" )' - -test_expect_success 'setup: clone' \ - 'mkdir clone && ( cd clone && - git clone --recursive "$base_path/origin/main")' +test_expect_success 'setup: make origin' ' + mkdir -p origin/sub && + ( + cd origin/sub && git init && + echo file1 >file1 && + git add file1 && + git commit -m file1 + ) && + mkdir -p origin/main && + ( + cd origin/main && git init && + git submodule add ../sub && + git commit -m "add sub" + ) && + ( + cd origin/sub && + echo file1updated >file1 && + git add file1 && + git commit -m "file1 updated" + ) && + git -C origin/main/sub pull && + ( + cd origin/main && + git add sub && + git commit -m "sub updated" + ) +' + +test_expect_success 'setup: clone' ' + mkdir clone && + git -C clone clone --recursive "$base_path/origin/main" +' rev1_hash_main=$(git --git-dir=origin/main/.git show --pretty=format:%h -q "HEAD~1") rev1_hash_sub=$(git --git-dir=origin/sub/.git show --pretty=format:%h -q "HEAD~1") -test_expect_success 'checkout main' \ - 'mkdir default_checkout && - (cd clone/main && - git worktree add "$base_path/default_checkout/main" "$rev1_hash_main")' +test_expect_success 'checkout main' ' + mkdir default_checkout && + git -C clone/main worktree add "$base_path/default_checkout/main" "$rev1_hash_main" +' -test_expect_failure 'can see submodule diffs just after checkout' \ - '(cd default_checkout/main && git diff --submodule master"^!" | grep "file1 updated")' +test_expect_failure 'can see submodule diffs just after checkout' ' + git -C default_checkout/main diff --submodule master"^!" >out && + grep "file1 updated" out +' -test_expect_success 'checkout main and initialize independed clones' \ - 'mkdir fully_cloned_submodule && - (cd clone/main && - git worktree add "$base_path/fully_cloned_submodule/main" "$rev1_hash_main") && - (cd fully_cloned_submodule/main && git submodule update)' +test_expect_success 'checkout main and initialize independent clones' ' + mkdir fully_cloned_submodule && + git -C clone/main worktree add "$base_path/fully_cloned_submodule/main" "$rev1_hash_main" && + git -C fully_cloned_submodule/main submodule update +' -test_expect_success 'can see submodule diffs after independed cloning' \ - '(cd fully_cloned_submodule/main && git diff --submodule master"^!" | grep "file1 updated")' +test_expect_success 'can see submodule diffs after independent cloning' ' + git -C fully_cloned_submodule/main diff --submodule master"^!" >out && + grep "file1 updated" out +' -test_expect_success 'checkout sub manually' \ - 'mkdir linked_submodule && - (cd clone/main && - git worktree add "$base_path/linked_submodule/main" "$rev1_hash_main") && - (cd clone/main/sub && - git worktree add "$base_path/linked_submodule/main/sub" "$rev1_hash_sub")' +test_expect_success 'checkout sub manually' ' + mkdir linked_submodule && + git -C clone/main worktree add "$base_path/linked_submodule/main" "$rev1_hash_main" && + git -C clone/main/sub worktree add "$base_path/linked_submodule/main/sub" "$rev1_hash_sub" +' -test_expect_success 'can see submodule diffs after manual checkout of linked submodule' \ - '(cd linked_submodule/main && git diff --submodule master"^!" | grep "file1 updated")' +test_expect_success 'can see submodule diffs after manual checkout of linked submodule' ' + git -C linked_submodule/main diff --submodule master"^!" >out && + grep "file1 updated" out +' test_done diff --git a/t/t7416-submodule-dash-url.sh b/t/t7416-submodule-dash-url.sh new file mode 100755 index 0000000000..1cd2c1c1ea --- /dev/null +++ b/t/t7416-submodule-dash-url.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +test_description='check handling of .gitmodule url with dash' +. ./test-lib.sh + +test_expect_success 'create submodule with protected dash in url' ' + git init upstream && + git -C upstream commit --allow-empty -m base && + mv upstream ./-upstream && + git submodule add ./-upstream sub && + git add sub .gitmodules && + git commit -m submodule +' + +test_expect_success 'clone can recurse submodule' ' + test_when_finished "rm -rf dst" && + git clone --recurse-submodules . dst && + echo base >expect && + git -C dst/sub log -1 --format=%s >actual && + test_cmp expect actual +' + +test_expect_success 'fsck accepts protected dash' ' + test_when_finished "rm -rf dst" && + git init --bare dst && + git -C dst config transfer.fsckObjects true && + git push dst HEAD +' + +test_expect_success 'remove ./ protection from .gitmodules url' ' + perl -i -pe "s{\./}{}" .gitmodules && + git commit -am "drop protection" +' + +test_expect_success 'clone rejects unprotected dash' ' + test_when_finished "rm -rf dst" && + test_must_fail git clone --recurse-submodules . dst 2>err && + test_i18ngrep ignoring err +' + +test_expect_success 'fsck rejects unprotected dash' ' + test_when_finished "rm -rf dst" && + git init --bare dst && + git -C dst config transfer.fsckObjects true && + test_must_fail git push dst HEAD 2>err && + grep gitmodulesUrl err +' + +test_done diff --git a/t/t7417-submodule-path-url.sh b/t/t7417-submodule-path-url.sh new file mode 100755 index 0000000000..756af8c4d6 --- /dev/null +++ b/t/t7417-submodule-path-url.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +test_description='check handling of .gitmodule path with dash' +. ./test-lib.sh + +test_expect_success 'create submodule with dash in path' ' + git init upstream && + git -C upstream commit --allow-empty -m base && + git submodule add ./upstream sub && + git mv sub ./-sub && + git commit -m submodule +' + +test_expect_success 'clone rejects unprotected dash' ' + test_when_finished "rm -rf dst" && + git clone --recurse-submodules . dst 2>err && + test_i18ngrep ignoring err +' + +test_expect_success 'fsck rejects unprotected dash' ' + test_when_finished "rm -rf dst" && + git init --bare dst && + git -C dst config transfer.fsckObjects true && + test_must_fail git push dst HEAD 2>err && + grep gitmodulesPath err +' + +test_done diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh index 51646d8019..1a6773ee68 100755 --- a/t/t7501-commit.sh +++ b/t/t7501-commit.sh @@ -517,6 +517,22 @@ Myfooter: x" && test_cmp expected actual ' +test_expect_success 'signoff not confused by ---' ' + cat >expected <<-EOF && + subject + + body + --- + these dashes confuse the parser! + + Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> + EOF + # should be a noop, since we already signed + git commit --allow-empty --signoff -F expected && + git log -1 --pretty=format:%B >actual && + test_cmp expected actual +' + test_expect_success 'multiple -m' ' >negative && @@ -582,13 +598,11 @@ test_expect_success 'same tree (merge and amend merge)' ' git merge -s ours side -m "empty ok" && git diff HEAD^ HEAD >actual && - : >expected && - test_cmp expected actual && + test_must_be_empty actual && git commit --amend -m "empty really ok" && git diff HEAD^ HEAD >actual && - : >expected && - test_cmp expected actual + test_must_be_empty actual ' @@ -677,7 +691,7 @@ test_expect_success '--dry-run with conflicts fixed from a merge' ' git checkout -b branch-2 HEAD^1 && echo "commit-2-state" >test-file && git commit -m "commit 2" -i test-file && - ! $(git merge --no-commit commit-1) && + test_must_fail git merge --no-commit commit-1 && echo "commit-2-state" >test-file && git add test-file && git commit --dry-run && diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh index d33a3cb331..ca4a740da0 100755 --- a/t/t7502-commit.sh +++ b/t/t7502-commit.sh @@ -393,7 +393,6 @@ EOF test_expect_success !AUTOIDENT 'do not fire editor when committer is bogus' ' >.git/result && - >expect && echo >>negative && ( @@ -403,7 +402,7 @@ test_expect_success !AUTOIDENT 'do not fire editor when committer is bogus' ' export GIT_EDITOR && test_must_fail git commit -e -m sample -a ) && - test_cmp expect .git/result + test_must_be_empty .git/result ' test_expect_success 'do not fire editor if -m <msg> was given' ' diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh index 6e2015ed9a..4e37ff8f16 100755 --- a/t/t7510-signed-commit.sh +++ b/t/t7510-signed-commit.sh @@ -227,4 +227,11 @@ test_expect_success GPG 'log.showsignature behaves like --show-signature' ' grep "gpg: Good signature" actual ' +test_expect_success GPG 'check config gpg.format values' ' + test_config gpg.format openpgp && + git commit -S --amend -m "success" && + test_config gpg.format OpEnPgP && + test_must_fail git commit -S --amend -m "fail" +' + test_done diff --git a/t/t7513-interpret-trailers.sh b/t/t7513-interpret-trailers.sh index 164719d1c9..c441861331 100755 --- a/t/t7513-interpret-trailers.sh +++ b/t/t7513-interpret-trailers.sh @@ -1417,4 +1417,46 @@ test_expect_success 'unfold' ' test_cmp expected actual ' +test_expect_success 'handling of --- lines in input' ' + echo "real-trailer: just right" >expected && + + git interpret-trailers --parse >actual <<-\EOF && + subject + + body + + not-a-trailer: too soon + ------ this is just a line in the commit message with a bunch of + ------ dashes; it does not have any syntactic meaning. + + real-trailer: just right + --- + below the dashed line may be a patch, etc. + + not-a-trailer: too late + EOF + + test_cmp expected actual +' + +test_expect_success 'suppress --- handling' ' + echo "real-trailer: just right" >expected && + + git interpret-trailers --parse --no-divider >actual <<-\EOF && + subject + + This commit message has a "---" in it, but because we tell + interpret-trailers not to respect that, it has no effect. + + not-a-trailer: too soon + --- + + This is still the commit message body. + + real-trailer: just right + EOF + + test_cmp expected actual +' + test_done diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh index 6736d8d131..106148254d 100755 --- a/t/t7600-merge.sh +++ b/t/t7600-merge.sh @@ -38,7 +38,6 @@ printf '%s\n' '1 X' 2 3 4 5 6 7 8 9 >result.1 printf '%s\n' '1 X' 2 3 4 '5 X' 6 7 8 9 >result.1-5 printf '%s\n' '1 X' 2 3 4 '5 X' 6 7 8 '9 X' >result.1-5-9 printf '%s\n' 1 2 3 4 5 6 7 8 '9 Z' >result.9z ->empty create_merge_msgs () { echo "Merge tag 'c2'" >msg.1-5 && @@ -58,8 +57,6 @@ create_merge_msgs () { echo && git log --no-merges ^HEAD c2 c3 } >squash.1-5-9 && - : >msg.nologff && - : >msg.nolognoff && { echo "* tag 'c3':" && echo " commit 3" @@ -519,7 +516,7 @@ test_expect_success 'tolerate unknown values for merge.ff' ' test_tick && git merge c1 2>message && verify_head "$c1" && - test_cmp empty message + test_must_be_empty message ' test_expect_success 'combining --squash and --no-ff is refused' ' @@ -551,13 +548,13 @@ test_expect_success 'merge log message' ' git reset --hard c0 && git merge --no-log c2 && git show -s --pretty=format:%b HEAD >msg.act && - test_cmp msg.nologff msg.act && + test_must_be_empty msg.act && git reset --hard c0 && test_config branch.master.mergeoptions "--no-ff" && git merge --no-log c2 && git show -s --pretty=format:%b HEAD >msg.act && - test_cmp msg.nolognoff msg.act && + test_must_be_empty msg.act && git merge --log c3 && git show -s --pretty=format:%b HEAD >msg.act && diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh index 047156e9d5..a9fb971615 100755 --- a/t/t7610-mergetool.sh +++ b/t/t7610-mergetool.sh @@ -328,9 +328,8 @@ test_expect_success 'mergetool produces no errors when keepBackup is used' ' git checkout -b test$test_count move-to-c && test_config mergetool.keepBackup true && test_must_fail git merge move-to-b && - : >expect && echo d | git mergetool a/a/file.txt 2>actual && - test_cmp expect actual && + test_must_be_empty actual && ! test -d a ' @@ -620,8 +619,7 @@ test_expect_success 'file with no base' ' git checkout -b test$test_count branch1 && test_must_fail git merge master && git mergetool --no-prompt --tool mybase -- both && - >expected && - test_cmp expected both + test_must_be_empty both ' test_expect_success 'custom commands override built-ins' ' diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index dcaab1557b..be5c1bd553 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -217,9 +217,8 @@ do ' test_expect_success "grep -w $L (w)" ' - : >expected && test_must_fail git grep -n -w -e "^w" $H >actual && - test_cmp expected actual + test_must_be_empty actual ' test_expect_success "grep -w $L (x)" ' @@ -239,26 +238,24 @@ do ' test_expect_success "grep -w $L (y-2)" ' - : >expected && if git grep -n -w -e "^y y" $H >actual then echo should not have matched cat actual false else - test_cmp expected actual + test_must_be_empty actual fi ' test_expect_success "grep -w $L (z)" ' - : >expected && if git grep -n -w -e "^z" $H >actual then echo should not have matched cat actual false else - test_cmp expected actual + test_must_be_empty actual fi ' @@ -498,7 +495,7 @@ test_expect_success 'grep -L -C' ' test_expect_success 'grep --files-without-match --quiet' ' git grep --files-without-match --quiet nonexistent_string >actual && - test_cmp /dev/null actual + test_must_be_empty actual ' cat >expected <<EOF @@ -619,11 +616,10 @@ z:zzz EOF test_expect_success 'grep -q, silently report matches' ' - >empty && git grep -q mmap >actual && - test_cmp empty actual && + test_must_be_empty actual && test_must_fail git grep -q qfwfq >actual && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'grep -C1 hunk mark between files' ' @@ -691,8 +687,7 @@ test_expect_success 'log grep (5)' ' test_expect_success 'log grep (6)' ' git log --author=-0700 --pretty=tformat:%s >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'log grep (7)' ' @@ -717,8 +712,7 @@ test_expect_success 'log grep (9)' ' test_expect_success 'log grep (9)' ' git log -g --grep-reflog="commit: third" --author="non-existent" --pretty=tformat:%s >actual && - : >expect && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'log --grep-reflog can only be used under -g' ' @@ -808,15 +802,13 @@ test_expect_success 'log --all-match --grep --grep --author takes intersection' ' test_expect_success 'log --author does not search in timestamp' ' - : >expect && git log --author="$GIT_AUTHOR_DATE" >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'log --committer does not search in timestamp' ' - : >expect && git log --committer="$GIT_COMMITTER_DATE" >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'grep with CE_VALID file' ' @@ -957,7 +949,7 @@ test_expect_success 'grep from a subdirectory to search wider area (2)' ' ( cd s && test_expect_code 1 git grep xxyyzz .. >out && - ! test -s out + test_must_be_empty out ) ' @@ -1066,13 +1058,12 @@ test_expect_success 'inside git repository but with --no-index' ' echo ".gitignore:.*o*" && cat is/expect.unignored } >is/expect.full && - : >is/expect.empty && echo file2:world >is/expect.sub && ( cd is/git && git init && test_must_fail git grep o >../actual.full && - test_cmp ../expect.empty ../actual.full && + test_must_be_empty ../actual.full && git grep --untracked o >../actual.unignored && test_cmp ../expect.unignored ../actual.unignored && @@ -1085,7 +1076,7 @@ test_expect_success 'inside git repository but with --no-index' ' cd sub && test_must_fail git grep o >../../actual.sub && - test_cmp ../../expect.empty ../../actual.sub && + test_must_be_empty ../../actual.sub && git grep --no-index o >../../actual.sub && test_cmp ../../expect.sub ../../actual.sub && @@ -1251,10 +1242,9 @@ test_expect_success !PCRE 'grep -P pattern errors without PCRE' ' ' test_expect_success 'grep pattern with grep.extendedRegexp=true' ' - >empty && test_must_fail git -c grep.extendedregexp=true \ grep "\p{Ps}.*?\p{Pe}" hello.c >actual && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success PCRE 'grep -P pattern with grep.extendedRegexp=true' ' diff --git a/t/t7811-grep-open.sh b/t/t7811-grep-open.sh index e1951a5cbb..d1ebfd88c7 100755 --- a/t/t7811-grep-open.sh +++ b/t/t7811-grep-open.sh @@ -51,14 +51,13 @@ test_expect_success SIMPLEPAGER 'git grep -O' ' grep.h EOF echo grep.h >expect.notless && - >empty && PATH=.:$PATH git grep -O GREP_PATTERN >out && { test_cmp expect.less pager-args || test_cmp expect.notless pager-args } && - test_cmp empty out + test_must_be_empty out ' test_expect_success 'git grep -O --cached' ' @@ -72,7 +71,6 @@ test_expect_success 'git grep -O --no-index' ' grep.h untracked EOF - >empty && ( GIT_PAGER='\''printf "%s\n" >pager-args'\'' && @@ -80,7 +78,7 @@ test_expect_success 'git grep -O --no-index' ' git grep --no-index -O GREP_PATTERN >out ) && test_cmp expect pager-args && - test_cmp empty out + test_must_be_empty out ' test_expect_success 'setup: fake "less"' ' @@ -96,15 +94,14 @@ test_expect_success 'git grep -O jumps to line in less' ' +/*GREP_PATTERN grep.h EOF - >empty && GIT_PAGER=./less git grep -O GREP_PATTERN >out && test_cmp expect actual && - test_cmp empty out && + test_must_be_empty out && git grep -O./less GREP_PATTERN >out2 && test_cmp expect actual && - test_cmp empty out2 + test_must_be_empty out2 ' test_expect_success 'modified file' ' @@ -122,7 +119,7 @@ test_expect_success 'modified file' ' test_when_finished "git checkout HEAD unrelated" && GIT_PAGER=./less git grep -F -O "enum grep_pat_token" >out && test_cmp expect actual && - test_cmp empty out + test_must_be_empty out ' test_expect_success 'copes with color settings' ' @@ -138,7 +135,6 @@ test_expect_success 'copes with color settings' ' test_expect_success 'run from subdir' ' rm -f actual && echo grep.c >expect && - >empty && ( cd subdir && @@ -156,8 +152,8 @@ test_expect_success 'run from subdir' ' ;; esac && test_cmp expect args && - test_cmp empty out && - test_cmp empty out2 + test_must_be_empty out && + test_must_be_empty out2 ' test_done diff --git a/t/t8010-cat-file-filters.sh b/t/t8010-cat-file-filters.sh index 0f86c19174..31de4b64dc 100755 --- a/t/t8010-cat-file-filters.sh +++ b/t/t8010-cat-file-filters.sh @@ -47,7 +47,7 @@ test_expect_success 'cat-file --textconv --path=<path> works' ' test_expect_success '--path=<path> complains without --textconv/--filters' ' sha1=$(git rev-parse -q --verify HEAD:world.txt) && test_must_fail git cat-file --path=hello.txt blob $sha1 >actual 2>err && - test ! -s actual && + test_must_be_empty actual && grep "path.*needs.*filters" err ' diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index b8e919e25d..1ef1a19003 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -253,10 +253,9 @@ test_suppress_self () { mv msgtxt1 msgtxt1-$3 && sed -e '/^$/q' msgtxt1-$3 >"msghdr1-$3" && - >"expected-no-cc-$3" && (grep '^Cc:' msghdr1-$3 >"actual-no-cc-$3"; - test_cmp expected-no-cc-$3 actual-no-cc-$3) + test_must_be_empty actual-no-cc-$3) } test_suppress_self_unquoted () { diff --git a/t/t9011-svn-da.sh b/t/t9011-svn-da.sh index b38d16f9db..ab1ef28fd9 100755 --- a/t/t9011-svn-da.sh +++ b/t/t9011-svn-da.sh @@ -18,7 +18,7 @@ test_expect_success 'reject empty delta' ' test_expect_success 'delta can empty file' ' printf "SVNQ" | q_to_nul >clear.delta && test-svn-fe -d preimage clear.delta 4 >actual && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'reject svndiff2' ' @@ -29,7 +29,7 @@ test_expect_success 'reject svndiff2' ' test_expect_success 'one-window empty delta' ' printf "SVNQ%s" "QQQQQ" | q_to_nul >clear.onewindow && test-svn-fe -d preimage clear.onewindow 9 >actual && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'reject incomplete window header' ' @@ -50,7 +50,7 @@ test_expect_success 'two-window empty delta' ' printf "SVNQ%s%s" "QQQQQ" "QQQQQ" | q_to_nul >clear.twowindow && test-svn-fe -d preimage clear.twowindow 14 >actual && test_must_fail test-svn-fe -d preimage clear.twowindow 13 && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'noisy zeroes' ' @@ -60,7 +60,7 @@ test_expect_success 'noisy zeroes' ' q_to_nul >clear.noisy && len=$(wc -c <clear.noisy) && test-svn-fe -d preimage clear.noisy $len && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'reject variable-length int in magic' ' @@ -83,7 +83,7 @@ test_expect_success 'reject truncated integer' ' test_expect_success 'nonempty (but unused) preimage view' ' printf "SVNQ%b" "Q\003QQQ" | q_to_nul >clear.readpreimage && test-svn-fe -d preimage clear.readpreimage 9 >actual && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'preimage view: right endpoint cannot backtrack' ' @@ -99,7 +99,7 @@ test_expect_success 'preimage view: left endpoint can advance' ' q_to_nul >clear.shrinkbacktrack && test-svn-fe -d preimage clear.preshrink 14 >actual && test_must_fail test-svn-fe -d preimage clear.shrinkbacktrack 14 && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'preimage view: offsets compared by value' ' @@ -109,7 +109,7 @@ test_expect_success 'preimage view: offsets compared by value' ' q_to_nul >clear.noisyadvance && test_must_fail test-svn-fe -d preimage clear.noisybacktrack 15 && test-svn-fe -d preimage clear.noisyadvance 15 && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'preimage view: reject truncated preimage' ' diff --git a/t/t9131-git-svn-empty-symlink.sh b/t/t9131-git-svn-empty-symlink.sh index f762038f0e..3bf4255aa3 100755 --- a/t/t9131-git-svn-empty-symlink.sh +++ b/t/t9131-git-svn-empty-symlink.sh @@ -85,7 +85,7 @@ EOF test_expect_success 'clone using git svn' 'git svn clone -r1 "$svnrepo" x' test_expect_success 'enable broken symlink workaround' \ '(cd x && git config svn.brokenSymlinkWorkaround true)' -test_expect_success '"bar" is an empty file' 'test -f x/bar && ! test -s x/bar' +test_expect_success '"bar" is an empty file' 'test_must_be_empty x/bar' test_expect_success 'get "bar" => symlink fix from svn' \ '(cd x && git svn rebase)' test_expect_success SYMLINKS '"bar" becomes a symlink' 'test -h x/bar' @@ -94,14 +94,14 @@ test_expect_success SYMLINKS '"bar" becomes a symlink' 'test -h x/bar' test_expect_success 'clone using git svn' 'git svn clone -r1 "$svnrepo" y' test_expect_success 'disable broken symlink workaround' \ '(cd y && git config svn.brokenSymlinkWorkaround false)' -test_expect_success '"bar" is an empty file' 'test -f y/bar && ! test -s y/bar' +test_expect_success '"bar" is an empty file' 'test_must_be_empty y/bar' test_expect_success 'get "bar" => symlink fix from svn' \ '(cd y && git svn rebase)' test_expect_success '"bar" does not become a symlink' '! test -L y/bar' # svn.brokenSymlinkWorkaround is unset test_expect_success 'clone using git svn' 'git svn clone -r1 "$svnrepo" z' -test_expect_success '"bar" is an empty file' 'test -f z/bar && ! test -s z/bar' +test_expect_success '"bar" is an empty file' 'test_must_be_empty z/bar' test_expect_success 'get "bar" => symlink fix from svn' \ '(cd z && git svn rebase)' test_expect_success '"bar" does not become a symlink' '! test -L z/bar' diff --git a/t/t9135-git-svn-moved-branch-empty-file.sh b/t/t9135-git-svn-moved-branch-empty-file.sh index 93db45db7d..2f80b216fe 100755 --- a/t/t9135-git-svn-moved-branch-empty-file.sh +++ b/t/t9135-git-svn-moved-branch-empty-file.sh @@ -13,8 +13,7 @@ test_expect_success 'test that b1 exists and is empty' ' ( cd x && git reset --hard origin/branch-c && - test -f b1 && - ! test -s b1 + test_must_be_empty b1 ) ' diff --git a/t/t9200-git-cvsexportcommit.sh b/t/t9200-git-cvsexportcommit.sh index cd61288aa1..c5946cb0b8 100755 --- a/t/t9200-git-cvsexportcommit.sh +++ b/t/t9200-git-cvsexportcommit.sh @@ -43,11 +43,11 @@ check_entries () { sed -ne '/^\//p' "$1/CVS/Entries" | sort | cut -d/ -f2,3,5 >actual if test -z "$2" then - >expected + test_must_be_empty actual else printf '%s\n' "$2" | tr '|' '\012' >expected + test_cmp expected actual fi - test_cmp expected actual } test_expect_success \ diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index fac33e524c..40fe7e4976 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -2191,12 +2191,11 @@ test_expect_success 'R: --import-marks-if-exists' ' test_expect_success 'R: feature import-marks-if-exists' ' rm -f io.marks && - >expect && git fast-import --export-marks=io.marks <<-\EOF && feature import-marks-if-exists=not_io.marks EOF - test_cmp expect io.marks && + test_must_be_empty io.marks && blob=$(echo hi | git hash-object --stdin) && @@ -2227,13 +2226,11 @@ test_expect_success 'R: feature import-marks-if-exists' ' EOF test_cmp expect io.marks && - >expect && - git fast-import --import-marks-if-exists=not_io.marks \ --export-marks=io.marks <<-\EOF && feature import-marks-if-exists=io.marks EOF - test_cmp expect io.marks + test_must_be_empty io.marks ' test_expect_success 'R: import to output marks works without any content' ' diff --git a/t/t9800-git-p4-basic.sh b/t/t9800-git-p4-basic.sh index 4849edc4ef..729cd25770 100755 --- a/t/t9800-git-p4-basic.sh +++ b/t/t9800-git-p4-basic.sh @@ -261,6 +261,35 @@ test_expect_success 'unresolvable host in P4PORT should display error' ' ) ' +# Test following scenarios: +# - Without ".git/hooks/p4-pre-submit" , submit should continue +# - With the hook returning 0, submit should continue +# - With the hook returning 1, submit should abort +test_expect_success 'run hook p4-pre-submit before submit' ' + test_when_finished cleanup_git && + git p4 clone --dest="$git" //depot && + ( + cd "$git" && + echo "hello world" >hello.txt && + git add hello.txt && + git commit -m "add hello.txt" && + git config git-p4.skipSubmitEdit true && + git p4 submit --dry-run >out && + grep "Would apply" out && + mkdir -p .git/hooks && + write_script .git/hooks/p4-pre-submit <<-\EOF && + exit 0 + EOF + git p4 submit --dry-run >out && + grep "Would apply" out && + write_script .git/hooks/p4-pre-submit <<-\EOF && + exit 1 + EOF + test_must_fail git p4 submit --dry-run >errs 2>&1 && + ! grep "Would apply" errs + ) +' + test_expect_success 'submit from detached head' ' test_when_finished cleanup_git && git p4 clone --dest="$git" //depot && diff --git a/t/t9802-git-p4-filetype.sh b/t/t9802-git-p4-filetype.sh index 1fc9b33aeb..9978352d78 100755 --- a/t/t9802-git-p4-filetype.sh +++ b/t/t9802-git-p4-filetype.sh @@ -310,7 +310,7 @@ test_expect_success SYMLINKS 'empty symlink target' ' # p4 to sync here will make it generate errors. cd "$cli" && p4 print -q //depot/empty-symlink#2 >out && - test ! -s out + test_must_be_empty out ) && test_when_finished cleanup_git && diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 5ff43b9cbb..175f83d704 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -1278,7 +1278,7 @@ test_expect_success 'setup for path completion tests' ' touch BS\\dir/DQ\"file \ '$'separators\034in\035dir/sep\036in\037file'' then - test_set_prereq FUNNYNAMES + test_set_prereq FUNNIERNAMES else rm -rf BS\\dir '$'separators\034in\035dir'' fi @@ -1320,7 +1320,7 @@ test_expect_success '__git_complete_index_file - UTF-8 in ls-files output' ' test_path_completion árvíztűrő/С "árvíztűrő/Сайн яваарай" ' -test_expect_success FUNNYNAMES \ +test_expect_success FUNNIERNAMES \ '__git_complete_index_file - C-style escapes in ls-files output' ' test_path_completion BS \ BS\\dir && @@ -1332,7 +1332,7 @@ test_expect_success FUNNYNAMES \ BS\\dir/DQ\"file ' -test_expect_success FUNNYNAMES \ +test_expect_success FUNNIERNAMES \ '__git_complete_index_file - \nnn-escaped characters in ls-files output' ' test_path_completion sep '$'separators\034in\035dir'' && test_path_completion '$'separators\034i'' \ diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh index 04440685a6..81a5179e28 100755 --- a/t/t9903-bash-prompt.sh +++ b/t/t9903-bash-prompt.sh @@ -63,18 +63,15 @@ test_expect_success 'prompt - unborn branch' ' test_cmp expected "$actual" ' -repo_with_newline='repo -with -newline' - -if test_have_prereq !MINGW && mkdir "$repo_with_newline" 2>/dev/null -then - test_set_prereq FUNNYNAMES -else +if test_have_prereq !FUNNYNAMES; then say 'Your filesystem does not allow newlines in filenames.' fi test_expect_success FUNNYNAMES 'prompt - with newline in path' ' + repo_with_newline="repo +with +newline" && + mkdir "$repo_with_newline" && printf " (master)" >expected && git init "$repo_with_newline" && test_when_finished "rm -rf \"$repo_with_newline\"" && @@ -516,10 +513,9 @@ test_expect_success 'prompt - format string starting with dash' ' test_expect_success 'prompt - pc mode' ' printf "BEFORE: (\${__git_ps1_branch_name}):AFTER\\nmaster" >expected && - printf "" >expected_output && ( __git_ps1 "BEFORE:" ":AFTER" >"$actual" && - test_cmp expected_output "$actual" && + test_must_be_empty "$actual" && printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual" ) && test_cmp expected "$actual" @@ -715,13 +711,12 @@ test_expect_success 'prompt - hide if pwd ignored - env var set, config disabled ' test_expect_success 'prompt - hide if pwd ignored - env var set, config unset' ' - printf "" >expected && ( cd ignored_dir && GIT_PS1_HIDE_IF_PWD_IGNORED=y && __git_ps1 >"$actual" ) && - test_cmp expected "$actual" + test_must_be_empty "$actual" ' test_expect_success 'prompt - hide if pwd ignored - env var set, config unset, pc mode' ' diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 2b2181dca0..4207af4077 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -565,6 +565,14 @@ test_path_is_dir () { fi } +test_path_exists () { + if ! test -e "$1" + then + echo "Path $1 doesn't exist. $2" + false + fi +} + # Check if the directory exists and is empty as expected, barf otherwise. test_dir_is_empty () { test_path_is_dir "$1" && diff --git a/t/test-lib.sh b/t/test-lib.sh index 78f7097746..44288cbb59 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -867,7 +867,7 @@ then # handle only executables, unless they are shell libraries that # need to be in the exec-path. test -x "$1" || - test "# " = "$(head -c 2 <"$1")" || + test "# " = "$(test_copy_bytes 2 <"$1")" || return; base=$(basename "$1") @@ -882,7 +882,7 @@ then # do not override scripts if test -x "$symlink_target" && test ! -d "$symlink_target" && - test "#!" != "$(head -c 2 < "$symlink_target")" + test "#!" != "$(test_copy_bytes 2 <"$symlink_target")" then symlink_target=../valgrind.sh fi @@ -1104,6 +1104,20 @@ test_lazy_prereq CASE_INSENSITIVE_FS ' test "$(cat CamelCase)" != good ' +test_lazy_prereq FUNNYNAMES ' + test_have_prereq !MINGW && + touch -- \ + "FUNNYNAMES tab embedded" \ + "FUNNYNAMES \"quote embedded\"" \ + "FUNNYNAMES newline +embedded" 2>/dev/null && + rm -- \ + "FUNNYNAMES tab embedded" \ + "FUNNYNAMES \"quote embedded\"" \ + "FUNNYNAMES newline +embedded" 2>/dev/null +' + test_lazy_prereq UTF8_NFD_TO_NFC ' # check whether FS converts nfd unicode to nfc auml=$(printf "\303\244") |