diff options
Diffstat (limited to 't')
155 files changed, 2579 insertions, 1103 deletions
@@ -168,6 +168,16 @@ appropriately before running "make". Using this option with a RAM-based filesystem (such as tmpfs) can massively speed up the test suite. +--chain-lint:: +--no-chain-lint:: + If --chain-lint is enabled, the test harness will check each + test to make sure that it properly "&&-chains" all commands (so + that a failure in the middle does not go unnoticed by the final + exit code of the test). This check is performed in addition to + running the tests themselves. You may also enable or disable + this feature by setting the GIT_TEST_CHAIN_LINT environment + variable to "1" or "0", respectively. + You can also set the GIT_TEST_INSTALLED environment variable to the bindir of an existing git installation to test that installation. You still need to have built this git sandbox, from which various diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh index 071e4d7d3e..f5c01758ca 100644 --- a/t/annotate-tests.sh +++ b/t/annotate-tests.sh @@ -405,7 +405,7 @@ test_expect_success 'setup -L :regex' ' mv hello.c hello.orig && echo "#include <stdio.h>" >hello.c && cat hello.orig >>hello.c && - tr Q "\\t" >>hello.c <<-\EOF + tr Q "\\t" >>hello.c <<-\EOF && void mail() { Qputs("mail"); diff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh index 5aa8adcf9c..75482254a3 100644 --- a/t/lib-git-p4.sh +++ b/t/lib-git-p4.sh @@ -69,7 +69,7 @@ start_p4d() { ( cd "$db" && { - p4d -q -p $P4DPORT & + p4d -q -p $P4DPORT "$@" & echo $! >"$pidfile" } ) && diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh index e6adf2f82d..e9714467d0 100644 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@ -30,6 +30,18 @@ # Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at> # +if test -n "$NO_CURL" +then + skip_all='skipping test, git built without http support' + test_done +fi + +if test -n "$NO_EXPAT" && test -n "$LIB_HTTPD_DAV" +then + skip_all='skipping test, git built without expat support' + test_done +fi + test_tristate GIT_TEST_HTTPD if test "$GIT_TEST_HTTPD" = false then diff --git a/t/lib-terminal.sh b/t/lib-terminal.sh index 51845491bb..cd220e378e 100644 --- a/t/lib-terminal.sh +++ b/t/lib-terminal.sh @@ -1,7 +1,7 @@ # Helpers for terminal output tests. # Catch tests which should depend on TTY but forgot to. There's no need -# to aditionally check that the TTY prereq is set here. If the test declared +# to additionally check that the TTY prereq is set here. If the test declared # it and we are running the test, then it must have been set. test_terminal () { if ! test_declared_prereq TTY diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh index a8c9574291..5cf74eddec 100644 --- a/t/perf/perf-lib.sh +++ b/t/perf/perf-lib.sh @@ -91,7 +91,7 @@ test_perf_create_repo_from () { */objects|*/hooks|*/config) ;; *) - cp -R "$stuff" . || break + cp -R "$stuff" . || exit 1 ;; esac done && diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh index f10ba4a01e..79b9074172 100755 --- a/t/t0000-basic.sh +++ b/t/t0000-basic.sh @@ -253,7 +253,7 @@ test_expect_success 'test --verbose' ' test_expect_success "failing test" false test_done EOF - mv test-verbose/out test-verbose/out+ + mv test-verbose/out test-verbose/out+ && grep -v "^Initialized empty" test-verbose/out+ >test-verbose/out && check_sub_test_lib_test test-verbose <<-\EOF > expecting success: true @@ -974,7 +974,7 @@ test_expect_success 'writing this tree with --missing-ok' ' ################################################################ test_expect_success 'git read-tree followed by write-tree should be idempotent' ' - rm -f .git/index + rm -f .git/index && git read-tree $tree && test -f .git/index && newtree=$(git write-tree) && diff --git a/t/t0005-signals.sh b/t/t0005-signals.sh index aeea50c633..e7f27ebbc1 100755 --- a/t/t0005-signals.sh +++ b/t/t0005-signals.sh @@ -10,8 +10,8 @@ one EOF test_expect_success 'sigchain works' ' - test-sigchain >actual - case "$?" in + { test-sigchain >actual; ret=$?; } && + case "$ret" in 143) true ;; # POSIX w/ SIGTERM=15 271) true ;; # ksh w/ SIGTERM=15 3) true ;; # Windows @@ -40,12 +40,12 @@ test_expect_success 'create blob' ' ' test_expect_success !MINGW 'a constipated git dies with SIGPIPE' ' - OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) + OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) && test "$OUT" -eq 141 ' test_expect_success !MINGW 'a constipated git dies with SIGPIPE even if parent ignores it' ' - OUT=$( ((trap "" PIPE; large_git; echo $? 1>&3) | :) 3>&1 ) + OUT=$( ((trap "" PIPE; large_git; echo $? 1>&3) | :) 3>&1 ) && test "$OUT" -eq 141 ' diff --git a/t/t0008-ignores.sh b/t/t0008-ignores.sh index 8dc6939b90..4ef5ed484c 100755 --- a/t/t0008-ignores.sh +++ b/t/t0008-ignores.sh @@ -831,4 +831,14 @@ test_expect_success !MINGW,!CYGWIN 'correct handling of backslashes' ' test_cmp err.expect err ' +test_expect_success 'info/exclude trumps core.excludesfile' ' + echo >>global-excludes usually-ignored && + echo >>.git/info/exclude "!usually-ignored" && + >usually-ignored && + echo "?? usually-ignored" >expect && + + git status --porcelain usually-ignored >actual && + test_cmp expect actual +' + test_done diff --git a/t/t0011-hashmap.sh b/t/t0011-hashmap.sh index f97c80556f..9c217d948c 100755 --- a/t/t0011-hashmap.sh +++ b/t/t0011-hashmap.sh @@ -218,7 +218,7 @@ test_expect_success 'grow / shrink' ' echo size >> in && echo 64 51 >> expect && echo put key52 value52 >> in && - echo NULL >> expect + echo NULL >> expect && echo size >> in && echo 256 52 >> expect && for n in $(test_seq 12) diff --git a/t/t0020-crlf.sh b/t/t0020-crlf.sh index d2e51a81bc..f94120a894 100755 --- a/t/t0020-crlf.sh +++ b/t/t0020-crlf.sh @@ -8,6 +8,13 @@ has_cr() { tr '\015' Q <"$1" | grep Q >/dev/null } +# add or remove CRs to disk file in-place +# usage: munge_cr <append|remove> <file> +munge_cr () { + "${1}_cr" <"$2" >tmp && + mv tmp "$2" +} + test_expect_success setup ' git config core.autocrlf false && @@ -28,9 +35,7 @@ test_expect_success setup ' for w in Some extra lines here; do echo $w; done >>one && git diff >patch.file && patched=$(git hash-object --stdin <one) && - git read-tree --reset -u HEAD && - - echo happy. + git read-tree --reset -u HEAD ' test_expect_success 'safecrlf: autocrlf=input, all CRLF' ' @@ -100,22 +105,11 @@ test_expect_success 'update with autocrlf=input' ' rm -f tmp one dir/two three && git read-tree --reset -u HEAD && git config core.autocrlf input && - - for f in one dir/two - do - append_cr <$f >tmp && mv -f tmp $f && - git update-index -- $f || { - echo Oops - false - break - } - done && - + munge_cr append one && + munge_cr append dir/two && + git update-index -- one dir/two && differs=$(git diff-index --cached HEAD) && - test -z "$differs" || { - echo Oops "$differs" - false - } + verbose test -z "$differs" ' @@ -124,22 +118,11 @@ test_expect_success 'update with autocrlf=true' ' rm -f tmp one dir/two three && git read-tree --reset -u HEAD && git config core.autocrlf true && - - for f in one dir/two - do - append_cr <$f >tmp && mv -f tmp $f && - git update-index -- $f || { - echo "Oops $f" - false - break - } - done && - + munge_cr append one && + munge_cr append dir/two && + git update-index -- one dir/two && differs=$(git diff-index --cached HEAD) && - test -z "$differs" || { - echo Oops "$differs" - false - } + verbose test -z "$differs" ' @@ -148,23 +131,13 @@ test_expect_success 'checkout with autocrlf=true' ' rm -f tmp one dir/two three && git config core.autocrlf true && git read-tree --reset -u HEAD && - - for f in one dir/two - do - remove_cr <"$f" >tmp && mv -f tmp $f && - git update-index -- $f || { - echo "Eh? $f" - false - break - } - done && + munge_cr remove one && + munge_cr remove dir/two && + git update-index -- one dir/two && test "$one" = $(git hash-object --stdin <one) && test "$two" = $(git hash-object --stdin <dir/two) && differs=$(git diff-index --cached HEAD) && - test -z "$differs" || { - echo Oops "$differs" - false - } + verbose test -z "$differs" ' test_expect_success 'checkout with autocrlf=input' ' @@ -172,25 +145,13 @@ test_expect_success 'checkout with autocrlf=input' ' rm -f tmp one dir/two three && git config core.autocrlf input && git read-tree --reset -u HEAD && - - for f in one dir/two - do - if has_cr "$f" - then - echo "Eh? $f" - false - break - else - git update-index -- $f - fi - done && + test_must_fail has_cr one && + test_must_fail has_cr two && + git update-index -- one dir/two && test "$one" = $(git hash-object --stdin <one) && test "$two" = $(git hash-object --stdin <dir/two) && differs=$(git diff-index --cached HEAD) && - test -z "$differs" || { - echo Oops "$differs" - false - } + verbose test -z "$differs" ' test_expect_success 'apply patch (autocrlf=input)' ' @@ -200,10 +161,7 @@ test_expect_success 'apply patch (autocrlf=input)' ' git read-tree --reset -u HEAD && git apply patch.file && - test "$patched" = "$(git hash-object --stdin <one)" || { - echo "Eh? apply without index" - false - } + verbose test "$patched" = "$(git hash-object --stdin <one)" ' test_expect_success 'apply patch --cached (autocrlf=input)' ' @@ -213,10 +171,7 @@ test_expect_success 'apply patch --cached (autocrlf=input)' ' git read-tree --reset -u HEAD && git apply --cached patch.file && - test "$patched" = $(git rev-parse :one) || { - echo "Eh? apply with --cached" - false - } + verbose test "$patched" = $(git rev-parse :one) ' test_expect_success 'apply patch --index (autocrlf=input)' ' @@ -226,11 +181,8 @@ test_expect_success 'apply patch --index (autocrlf=input)' ' git read-tree --reset -u HEAD && git apply --index patch.file && - test "$patched" = $(git rev-parse :one) && - test "$patched" = $(git hash-object --stdin <one) || { - echo "Eh? apply with --index" - false - } + verbose test "$patched" = $(git rev-parse :one) && + verbose test "$patched" = $(git hash-object --stdin <one) ' test_expect_success 'apply patch (autocrlf=true)' ' @@ -240,10 +192,7 @@ test_expect_success 'apply patch (autocrlf=true)' ' git read-tree --reset -u HEAD && git apply patch.file && - test "$patched" = "$(remove_cr <one | git hash-object --stdin)" || { - echo "Eh? apply without index" - false - } + verbose test "$patched" = "$(remove_cr <one | git hash-object --stdin)" ' test_expect_success 'apply patch --cached (autocrlf=true)' ' @@ -253,10 +202,7 @@ test_expect_success 'apply patch --cached (autocrlf=true)' ' git read-tree --reset -u HEAD && git apply --cached patch.file && - test "$patched" = $(git rev-parse :one) || { - echo "Eh? apply without index" - false - } + verbose test "$patched" = $(git rev-parse :one) ' test_expect_success 'apply patch --index (autocrlf=true)' ' @@ -266,11 +212,8 @@ test_expect_success 'apply patch --index (autocrlf=true)' ' git read-tree --reset -u HEAD && git apply --index patch.file && - test "$patched" = $(git rev-parse :one) && - test "$patched" = "$(remove_cr <one | git hash-object --stdin)" || { - echo "Eh? apply with --index" - false - } + verbose test "$patched" = $(git rev-parse :one) && + verbose test "$patched" = "$(remove_cr <one | git hash-object --stdin)" ' test_expect_success '.gitattributes says two is binary' ' @@ -280,29 +223,9 @@ test_expect_success '.gitattributes says two is binary' ' git config core.autocrlf true && git read-tree --reset -u HEAD && - if has_cr dir/two - then - echo "Huh?" - false - else - : happy - fi && - - if has_cr one - then - : happy - else - echo "Huh?" - false - fi && - - if has_cr three - then - echo "Huh?" - false - else - : happy - fi + test_must_fail has_cr dir/two && + verbose has_cr one && + test_must_fail has_cr three ' test_expect_success '.gitattributes says two is input' ' @@ -311,13 +234,7 @@ test_expect_success '.gitattributes says two is input' ' echo "two crlf=input" >.gitattributes && git read-tree --reset -u HEAD && - if has_cr dir/two - then - echo "Huh?" - false - else - : happy - fi + test_must_fail has_cr dir/two ' test_expect_success '.gitattributes says two and three are text' ' @@ -326,21 +243,8 @@ test_expect_success '.gitattributes says two and three are text' ' echo "t* crlf" >.gitattributes && git read-tree --reset -u HEAD && - if has_cr dir/two - then - : happy - else - echo "Huh?" - false - fi && - - if has_cr three - then - : happy - else - echo "Huh?" - false - fi + verbose has_cr dir/two && + verbose has_cr three ' test_expect_success 'in-tree .gitattributes (1)' ' @@ -352,17 +256,8 @@ test_expect_success 'in-tree .gitattributes (1)' ' rm -rf tmp one dir .gitattributes patch.file three && git read-tree --reset -u HEAD && - if has_cr one - then - echo "Eh? one should not have CRLF" - false - else - : happy - fi && - has_cr three || { - echo "Eh? three should still have CRLF" - false - } + test_must_fail has_cr one && + verbose has_cr three ' test_expect_success 'in-tree .gitattributes (2)' ' @@ -371,17 +266,8 @@ test_expect_success 'in-tree .gitattributes (2)' ' git read-tree --reset HEAD && git checkout-index -f -q -u -a && - if has_cr one - then - echo "Eh? one should not have CRLF" - false - else - : happy - fi && - has_cr three || { - echo "Eh? three should still have CRLF" - false - } + test_must_fail has_cr one && + verbose has_cr three ' test_expect_success 'in-tree .gitattributes (3)' ' @@ -391,17 +277,8 @@ test_expect_success 'in-tree .gitattributes (3)' ' git checkout-index -u .gitattributes && git checkout-index -u one dir/two three && - if has_cr one - then - echo "Eh? one should not have CRLF" - false - else - : happy - fi && - has_cr three || { - echo "Eh? three should still have CRLF" - false - } + test_must_fail has_cr one && + verbose has_cr three ' test_expect_success 'in-tree .gitattributes (4)' ' @@ -411,17 +288,8 @@ test_expect_success 'in-tree .gitattributes (4)' ' git checkout-index -u one dir/two three && git checkout-index -u .gitattributes && - if has_cr one - then - echo "Eh? one should not have CRLF" - false - else - : happy - fi && - has_cr three || { - echo "Eh? three should still have CRLF" - false - } + test_must_fail has_cr one && + verbose has_cr three ' test_expect_success 'checkout with existing .gitattributes' ' diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh index 452320df83..1a56e5e82e 100755 --- a/t/t0027-auto-crlf.sh +++ b/t/t0027-auto-crlf.sh @@ -57,28 +57,35 @@ create_gitattributes () { check_warning () { case "$1" in - LF_CRLF) grep "LF will be replaced by CRLF" $2;; - CRLF_LF) grep "CRLF will be replaced by LF" $2;; - '') - >expect - grep "will be replaced by" $2 >actual - test_cmp expect actual - ;; - *) false ;; + LF_CRLF) echo "warning: LF will be replaced by CRLF" >"$2".expect ;; + CRLF_LF) echo "warning: CRLF will be replaced by LF" >"$2".expect ;; + '') >"$2".expect ;; + *) echo >&2 "Illegal 1": "$1" ; return false ;; esac + grep "will be replaced by" "$2" | sed -e "s/\(.*\) in [^ ]*$/\1/" >"$2".actual + test_cmp "$2".expect "$2".actual } -create_file_in_repo () { +commit_check_warn () { crlf=$1 attr=$2 lfname=$3 crlfname=$4 - lfmixcrlf=$5 - lfmixcr=$6 - crlfnul=$7 - create_gitattributes "$attr" && + repoMIX=$5 + lfmixcrlf=$6 + lfmixcr=$7 + crlfnul=$8 pfx=crlf_${crlf}_attr_${attr} - for f in LF CRLF LF_mix_CR CRLF_mix_LF CRLF_nul + # Special handling for repoMIX: It should already be in the repo + # with CRLF + f=repoMIX + fname=${pfx}_$f.txt + echo >.gitattributes && + cp $f $fname && + git -c core.autocrlf=false add $fname 2>"${pfx}_$f.err" && + git commit -m "repoMIX" && + create_gitattributes "$attr" && + for f in LF CRLF repoMIX LF_mix_CR CRLF_mix_LF LF_nul CRLF_nul do fname=${pfx}_$f.txt && cp $f $fname && @@ -109,7 +116,7 @@ check_files_in_repo () { } -check_files_in_ws () { +checkout_files () { eol=$1 crlf=$2 attr=$3 @@ -122,7 +129,7 @@ check_files_in_ws () { git config core.autocrlf $crlf && pfx=eol_${eol}_crlf_${crlf}_attr_${attr}_ && src=crlf_false_attr__ && - for f in LF CRLF LF_mix_CR CRLF_mix_LF CRLF_nul + for f in LF CRLF LF_mix_CR CRLF_mix_LF LF_nul do rm $src$f.txt && if test -z "$eol"; then @@ -144,8 +151,8 @@ check_files_in_ws () { test_expect_success "checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=LF_mix_CR" " compare_ws_file $pfx $lfmixcr ${src}LF_mix_CR.txt " - test_expect_success "checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=CRLF_nul" " - compare_ws_file $pfx $crlfnul ${src}CRLF_nul.txt + test_expect_success "checkout core.eol=$eol core.autocrlf=$crlf gitattributes=$attr file=LF_nul" " + compare_ws_file $pfx $crlfnul ${src}LF_nul.txt " } @@ -157,6 +164,7 @@ test_expect_success 'setup master' ' git commit -m "add .gitattributes" "" && printf "line1\nline2\nline3" >LF && printf "line1\r\nline2\r\nline3" >CRLF && + printf "line1\r\nline2\nline3" >repoMIX && printf "line1\r\nline2\nline3" >CRLF_mix_LF && printf "line1\nline2\rline3" >LF_mix_CR && printf "line1\r\nline2\rline3" >CRLF_mix_CR && @@ -169,40 +177,55 @@ test_expect_success 'setup master' ' warn_LF_CRLF="LF will be replaced by CRLF" warn_CRLF_LF="CRLF will be replaced by LF" -test_expect_success 'add files empty attr' ' - create_file_in_repo false "" "" "" "" "" "" && - create_file_in_repo true "" "LF_CRLF" "" "LF_CRLF" "" "" && - create_file_in_repo input "" "" "CRLF_LF" "CRLF_LF" "" "" +# WILC stands for "Warn if (this OS) converts LF into CRLF". +# WICL: Warn if CRLF becomes LF +# WAMIX: Mixed line endings: either CRLF->LF or LF->CRLF +if test_have_prereq NATIVE_CRLF +then + WILC=LF_CRLF + WICL= + WAMIX=LF_CRLF +else + WILC= + WICL=CRLF_LF + WAMIX=CRLF_LF +fi + +# attr LF CRLF repoMIX CRLFmixLF LFmixCR CRLFNUL +test_expect_success 'commit files empty attr' ' + commit_check_warn false "" "" "" "" "" "" "" && + commit_check_warn true "" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" "" && + commit_check_warn input "" "" "CRLF_LF" "CRLF_LF" "CRLF_LF" "" "" ' -test_expect_success 'add files attr=auto' ' - create_file_in_repo false "auto" "" "CRLF_LF" "CRLF_LF" "" "" && - create_file_in_repo true "auto" "LF_CRLF" "" "LF_CRLF" "" "" && - create_file_in_repo input "auto" "" "CRLF_LF" "CRLF_LF" "" "" +test_expect_success 'commit files attr=auto' ' + commit_check_warn false "auto" "$WILC" "$WICL" "$WAMIX" "$WAMIX" "" "" && + commit_check_warn true "auto" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" "" && + commit_check_warn input "auto" "" "CRLF_LF" "CRLF_LF" "CRLF_LF" "" "" ' -test_expect_success 'add files attr=text' ' - create_file_in_repo false "text" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" && - create_file_in_repo true "text" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" && - create_file_in_repo input "text" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" +test_expect_success 'commit files attr=text' ' + commit_check_warn false "text" "$WILC" "$WICL" "$WAMIX" "$WAMIX" "$WILC" "$WICL" && + commit_check_warn true "text" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "LF_CRLF" "" && + commit_check_warn input "text" "" "CRLF_LF" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" ' -test_expect_success 'add files attr=-text' ' - create_file_in_repo false "-text" "" "" "" "" "" && - create_file_in_repo true "-text" "" "" "" "" "" && - create_file_in_repo input "-text" "" "" "" "" "" +test_expect_success 'commit files attr=-text' ' + commit_check_warn false "-text" "" "" "" "" "" "" && + commit_check_warn true "-text" "" "" "" "" "" "" && + commit_check_warn input "-text" "" "" "" "" "" "" ' -test_expect_success 'add files attr=lf' ' - create_file_in_repo false "lf" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" && - create_file_in_repo true "lf" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" && - create_file_in_repo input "lf" "" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" +test_expect_success 'commit files attr=lf' ' + commit_check_warn false "lf" "" "CRLF_LF" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" && + commit_check_warn true "lf" "" "CRLF_LF" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" && + commit_check_warn input "lf" "" "CRLF_LF" "CRLF_LF" "CRLF_LF" "" "CRLF_LF" ' -test_expect_success 'add files attr=crlf' ' - create_file_in_repo false "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" && - create_file_in_repo true "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" && - create_file_in_repo input "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" +test_expect_success 'commit files attr=crlf' ' + commit_check_warn false "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "LF_CRLF" "" && + commit_check_warn true "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "LF_CRLF" "" && + commit_check_warn input "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "LF_CRLF" "" ' test_expect_success 'create files cleanup' ' @@ -237,7 +260,7 @@ test_expect_success 'commit -text' ' ################################################################################ # Check how files in the repo are changed when they are checked out # How to read the table below: -# - check_files_in_ws will check multiple files with a combination of settings +# - checkout_files will check multiple files with a combination of settings # and attributes (core.autocrlf=input is forbidden with core.eol=crlf) # - parameter $1 : core.eol lf | crlf # - parameter $2 : core.autocrlf false | true | input @@ -249,87 +272,89 @@ test_expect_success 'commit -text' ' # - parameter $8 : reference for a file with CRLF and a NUL (should be handled as binary when auto) # What we have in the repo: -# ----------------- EOL in repo ---------------- -# LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul +# ----------------- EOL in repo ---------------- +# LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul # settings with checkout: # core. core. .gitattr # eol acrlf # ---------------------------------------------- # What we want to have in the working tree: -if test_have_prereq MINGW +if test_have_prereq NATIVE_CRLF then MIX_CRLF_LF=CRLF MIX_LF_CR=CRLF_mix_CR NL=CRLF +LFNUL=CRLF_nul else MIX_CRLF_LF=CRLF_mix_LF MIX_LF_CR=LF_mix_CR NL=LF +LFNUL=LF_nul fi export CRLF_MIX_LF_CR MIX NL -check_files_in_ws lf false "" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws lf true "" CRLF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws lf input "" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws lf false "auto" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws lf true "auto" CRLF CRLF CRLF LF_mix_CR CRLF_nul -check_files_in_ws lf input "auto" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws lf false "text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws lf true "text" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul -check_files_in_ws lf input "text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws lf false "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws lf true "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws lf input "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws lf false "lf" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws lf true "lf" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws lf input "lf" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws lf false "crlf" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul -check_files_in_ws lf true "crlf" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul -check_files_in_ws lf input "crlf" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul - -check_files_in_ws crlf false "" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws crlf true "" CRLF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws crlf false "auto" CRLF CRLF CRLF LF_mix_CR CRLF_nul -check_files_in_ws crlf true "auto" CRLF CRLF CRLF LF_mix_CR CRLF_nul -check_files_in_ws crlf false "text" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul -check_files_in_ws crlf true "text" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul -check_files_in_ws crlf false "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws crlf true "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws crlf false "lf" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws crlf true "lf" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws crlf false "crlf" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul -check_files_in_ws crlf true "crlf" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul - -check_files_in_ws "" false "" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws "" true "" CRLF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws "" input "" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws "" false "auto" $NL CRLF $MIX_CRLF_LF LF_mix_CR CRLF_nul -check_files_in_ws "" true "auto" CRLF CRLF CRLF LF_mix_CR CRLF_nul -check_files_in_ws "" input "auto" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws "" false "text" $NL CRLF $MIX_CRLF_LF $MIX_LF_CR CRLF_nul -check_files_in_ws "" true "text" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul -check_files_in_ws "" input "text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws "" false "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws "" true "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws "" input "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws "" false "lf" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws "" true "lf" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws "" input "lf" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws "" false "crlf" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul -check_files_in_ws "" true "crlf" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul -check_files_in_ws "" input "crlf" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul - -check_files_in_ws native false "" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws native true "" CRLF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws native false "auto" $NL CRLF $MIX_CRLF_LF LF_mix_CR CRLF_nul -check_files_in_ws native true "auto" CRLF CRLF CRLF LF_mix_CR CRLF_nul -check_files_in_ws native false "text" $NL CRLF $MIX_CRLF_LF $MIX_LF_CR CRLF_nul -check_files_in_ws native true "text" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul -check_files_in_ws native false "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws native true "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws native false "lf" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws native true "lf" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul -check_files_in_ws native false "crlf" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul -check_files_in_ws native true "crlf" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul +checkout_files lf false "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files lf true "" CRLF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files lf input "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files lf false "auto" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files lf true "auto" CRLF CRLF CRLF LF_mix_CR LF_nul +checkout_files lf input "auto" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files lf false "text" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files lf true "text" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul +checkout_files lf input "text" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files lf false "-text" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files lf true "-text" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files lf input "-text" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files lf false "lf" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files lf true "lf" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files lf input "lf" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files lf false "crlf" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul +checkout_files lf true "crlf" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul +checkout_files lf input "crlf" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul + +checkout_files crlf false "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files crlf true "" CRLF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files crlf false "auto" CRLF CRLF CRLF LF_mix_CR LF_nul +checkout_files crlf true "auto" CRLF CRLF CRLF LF_mix_CR LF_nul +checkout_files crlf false "text" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul +checkout_files crlf true "text" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul +checkout_files crlf false "-text" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files crlf true "-text" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files crlf false "lf" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files crlf true "lf" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files crlf false "crlf" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul +checkout_files crlf true "crlf" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul + +checkout_files "" false "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files "" true "" CRLF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files "" input "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files "" false "auto" $NL CRLF $MIX_CRLF_LF LF_mix_CR LF_nul +checkout_files "" true "auto" CRLF CRLF CRLF LF_mix_CR LF_nul +checkout_files "" input "auto" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files "" false "text" $NL CRLF $MIX_CRLF_LF $MIX_LF_CR $LFNUL +checkout_files "" true "text" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul +checkout_files "" input "text" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files "" false "-text" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files "" true "-text" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files "" input "-text" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files "" false "lf" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files "" true "lf" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files "" input "lf" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files "" false "crlf" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul +checkout_files "" true "crlf" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul +checkout_files "" input "crlf" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul + +checkout_files native false "" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files native true "" CRLF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files native false "auto" $NL CRLF $MIX_CRLF_LF LF_mix_CR LF_nul +checkout_files native true "auto" CRLF CRLF CRLF LF_mix_CR LF_nul +checkout_files native false "text" $NL CRLF $MIX_CRLF_LF $MIX_LF_CR $LFNUL +checkout_files native true "text" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul +checkout_files native false "-text" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files native true "-text" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files native false "lf" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files native true "lf" LF CRLF CRLF_mix_LF LF_mix_CR LF_nul +checkout_files native false "crlf" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul +checkout_files native true "crlf" CRLF CRLF CRLF CRLF_mix_CR CRLF_nul test_done diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh index a90c86bfa3..b044785175 100755 --- a/t/t0040-parse-options.sh +++ b/t/t0040-parse-options.sh @@ -172,12 +172,9 @@ test_expect_success 'long options' ' ' test_expect_success 'missing required value' ' - test-parse-options -s; - test $? = 129 && - test-parse-options --string; - test $? = 129 && - test-parse-options --file; - test $? = 129 + test_expect_code 129 test-parse-options -s && + test_expect_code 129 test-parse-options --string && + test_expect_code 129 test-parse-options --file ' cat > expect << EOF @@ -227,8 +224,7 @@ test_expect_success 'unambiguously abbreviated option with "="' ' ' test_expect_success 'ambiguously abbreviated option' ' - test-parse-options --strin 123; - test $? = 129 + test_expect_code 129 test-parse-options --strin 123 ' cat > expect << EOF diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh index 988c3925d5..b29d749bb7 100755 --- a/t/t0050-filesystem.sh +++ b/t/t0050-filesystem.sh @@ -33,16 +33,20 @@ test_expect_success "detection of case insensitive filesystem during repo init" ' else test_expect_success "detection of case insensitive filesystem during repo init" ' - test_must_fail git config --bool core.ignorecase >/dev/null || - test $(git config --bool core.ignorecase) = false + { + test_must_fail git config --bool core.ignorecase >/dev/null || + test $(git config --bool core.ignorecase) = false + } ' fi if test_have_prereq SYMLINKS then test_expect_success "detection of filesystem w/o symlink support during repo init" ' - test_must_fail git config --bool core.symlinks || - test "$(git config --bool core.symlinks)" = true + { + test_must_fail git config --bool core.symlinks || + test "$(git config --bool core.symlinks)" = true + } ' else test_expect_success "detection of filesystem w/o symlink support during repo init" ' diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh index c0143a0a70..93605f42f2 100755 --- a/t/t0060-path-utils.sh +++ b/t/t0060-path-utils.sh @@ -19,6 +19,14 @@ relative_path() { "test \"\$(test-path-utils relative_path '$1' '$2')\" = '$expected'" } +test_git_path() { + test_expect_success "git-path $1 $2 => $3" " + $1 git rev-parse --git-path $2 >actual && + echo $3 >expect && + test_cmp expect actual + " +} + # On Windows, we are using MSYS's bash, which mangles the paths. # Absolute paths are anchored at the MSYS installation directory, # which means that the path / accounts for this many characters: @@ -244,4 +252,32 @@ relative_path "<null>" "<empty>" ./ relative_path "<null>" "<null>" ./ relative_path "<null>" /foo/a/b ./ +test_git_path A=B info/grafts .git/info/grafts +test_git_path GIT_GRAFT_FILE=foo info/grafts foo +test_git_path GIT_GRAFT_FILE=foo info/////grafts foo +test_git_path GIT_INDEX_FILE=foo index foo +test_git_path GIT_INDEX_FILE=foo index/foo .git/index/foo +test_git_path GIT_INDEX_FILE=foo index2 .git/index2 +test_expect_success 'setup fake objects directory foo' 'mkdir foo' +test_git_path GIT_OBJECT_DIRECTORY=foo objects foo +test_git_path GIT_OBJECT_DIRECTORY=foo objects/foo foo/foo +test_git_path GIT_OBJECT_DIRECTORY=foo objects2 .git/objects2 +test_expect_success 'setup common repository' 'git --git-dir=bar init' +test_git_path GIT_COMMON_DIR=bar index .git/index +test_git_path GIT_COMMON_DIR=bar HEAD .git/HEAD +test_git_path GIT_COMMON_DIR=bar logs/HEAD .git/logs/HEAD +test_git_path GIT_COMMON_DIR=bar objects bar/objects +test_git_path GIT_COMMON_DIR=bar objects/bar bar/objects/bar +test_git_path GIT_COMMON_DIR=bar info/exclude bar/info/exclude +test_git_path GIT_COMMON_DIR=bar info/grafts bar/info/grafts +test_git_path GIT_COMMON_DIR=bar info/sparse-checkout .git/info/sparse-checkout +test_git_path GIT_COMMON_DIR=bar remotes/bar bar/remotes/bar +test_git_path GIT_COMMON_DIR=bar branches/bar bar/branches/bar +test_git_path GIT_COMMON_DIR=bar logs/refs/heads/master bar/logs/refs/heads/master +test_git_path GIT_COMMON_DIR=bar refs/heads/master bar/refs/heads/master +test_git_path GIT_COMMON_DIR=bar hooks/me bar/hooks/me +test_git_path GIT_COMMON_DIR=bar config bar/config +test_git_path GIT_COMMON_DIR=bar packed-refs bar/packed-refs +test_git_path GIT_COMMON_DIR=bar shallow bar/shallow + test_done diff --git a/t/t0062-revision-walking.sh b/t/t0062-revision-walking.sh index 3d98eb847f..113c728e67 100755 --- a/t/t0062-revision-walking.sh +++ b/t/t0062-revision-walking.sh @@ -26,7 +26,7 @@ test_expect_success 'setup' ' ' test_expect_success 'revision walking can be done twice' ' - test-revision-walking run-twice > run_twice_actual + test-revision-walking run-twice >run_twice_actual && test_cmp run_twice_expected run_twice_actual ' diff --git a/t/t0201-gettext-fallbacks.sh b/t/t0201-gettext-fallbacks.sh index 5d80a985fb..90da1c7ddc 100755 --- a/t/t0201-gettext-fallbacks.sh +++ b/t/t0201-gettext-fallbacks.sh @@ -50,17 +50,17 @@ test_expect_success 'eval_gettext: our eval_gettext() fallback can interpolate v test_expect_success 'eval_gettext: our eval_gettext() fallback can interpolate variables with spaces' ' cmdline="git am" && - export cmdline; + export cmdline && printf "When you have resolved this problem, run git am --resolved." >expect && - eval_gettext "When you have resolved this problem, run \$cmdline --resolved." >actual + eval_gettext "When you have resolved this problem, run \$cmdline --resolved." >actual && test_i18ncmp expect actual ' test_expect_success 'eval_gettext: our eval_gettext() fallback can interpolate variables with spaces and quotes' ' cmdline="git am" && - export cmdline; + export cmdline && printf "When you have resolved this problem, run \"git am --resolved\"." >expect && - eval_gettext "When you have resolved this problem, run \"\$cmdline --resolved\"." >actual + eval_gettext "When you have resolved this problem, run \"\$cmdline --resolved\"." >actual && test_i18ncmp expect actual ' diff --git a/t/t0302-credential-store.sh b/t/t0302-credential-store.sh index f61b40c69b..0979df93a1 100755 --- a/t/t0302-credential-store.sh +++ b/t/t0302-credential-store.sh @@ -6,4 +6,118 @@ test_description='credential-store tests' helper_test store +test_expect_success 'when xdg file does not exist, xdg file not created' ' + test_path_is_missing "$HOME/.config/git/credentials" && + test -s "$HOME/.git-credentials" +' + +test_expect_success 'setup xdg file' ' + rm -f "$HOME/.git-credentials" && + mkdir -p "$HOME/.config/git" && + >"$HOME/.config/git/credentials" +' + +helper_test store + +test_expect_success 'when xdg file exists, home file not created' ' + test -s "$HOME/.config/git/credentials" && + test_path_is_missing "$HOME/.git-credentials" +' + +test_expect_success 'setup custom xdg file' ' + rm -f "$HOME/.git-credentials" && + rm -f "$HOME/.config/git/credentials" && + mkdir -p "$HOME/xdg/git" && + >"$HOME/xdg/git/credentials" +' + +XDG_CONFIG_HOME="$HOME/xdg" +export XDG_CONFIG_HOME +helper_test store +unset XDG_CONFIG_HOME + +test_expect_success 'if custom xdg file exists, home and xdg files not created' ' + test_when_finished "rm -f $HOME/xdg/git/credentials" && + test -s "$HOME/xdg/git/credentials" && + test_path_is_missing "$HOME/.git-credentials" && + test_path_is_missing "$HOME/.config/git/credentials" +' + +test_expect_success 'get: use home file if both home and xdg files have matches' ' + echo "https://home-user:home-pass@example.com" >"$HOME/.git-credentials" && + mkdir -p "$HOME/.config/git" && + echo "https://xdg-user:xdg-pass@example.com" >"$HOME/.config/git/credentials" && + check fill store <<-\EOF + protocol=https + host=example.com + -- + protocol=https + host=example.com + username=home-user + password=home-pass + -- + EOF +' + +test_expect_success 'get: use xdg file if home file has no matches' ' + >"$HOME/.git-credentials" && + mkdir -p "$HOME/.config/git" && + echo "https://xdg-user:xdg-pass@example.com" >"$HOME/.config/git/credentials" && + check fill store <<-\EOF + protocol=https + host=example.com + -- + protocol=https + host=example.com + username=xdg-user + password=xdg-pass + -- + EOF +' + +test_expect_success POSIXPERM 'get: use xdg file if home file is unreadable' ' + echo "https://home-user:home-pass@example.com" >"$HOME/.git-credentials" && + chmod -r "$HOME/.git-credentials" && + mkdir -p "$HOME/.config/git" && + echo "https://xdg-user:xdg-pass@example.com" >"$HOME/.config/git/credentials" && + check fill store <<-\EOF + protocol=https + host=example.com + -- + protocol=https + host=example.com + username=xdg-user + password=xdg-pass + -- + EOF +' + +test_expect_success 'store: if both xdg and home files exist, only store in home file' ' + >"$HOME/.git-credentials" && + mkdir -p "$HOME/.config/git" && + >"$HOME/.config/git/credentials" && + check approve store <<-\EOF && + protocol=https + host=example.com + username=store-user + password=store-pass + EOF + echo "https://store-user:store-pass@example.com" >expected && + test_cmp expected "$HOME/.git-credentials" && + test_must_be_empty "$HOME/.config/git/credentials" +' + + +test_expect_success 'erase: erase matching credentials from both xdg and home files' ' + echo "https://home-user:home-pass@example.com" >"$HOME/.git-credentials" && + mkdir -p "$HOME/.config/git" && + echo "https://xdg-user:xdg-pass@example.com" >"$HOME/.config/git/credentials" && + check reject store <<-\EOF && + protocol=https + host=example.com + EOF + test_must_be_empty "$HOME/.git-credentials" && + test_must_be_empty "$HOME/.config/git/credentials" +' + test_done diff --git a/t/t1002-read-tree-m-u-2way.sh b/t/t1002-read-tree-m-u-2way.sh index fed877b20f..e3bf821694 100755 --- a/t/t1002-read-tree-m-u-2way.sh +++ b/t/t1002-read-tree-m-u-2way.sh @@ -75,8 +75,8 @@ test_expect_success \ echo yomin >yomin && git update-index --add yomin && read_tree_u_must_succeed -m -u $treeH $treeM && - git ls-files --stage >4.out || return 1 - git diff -U0 --no-index M.out 4.out >4diff.out + git ls-files --stage >4.out && + test_might_fail git diff -U0 --no-index M.out 4.out >4diff.out && compare_change 4diff.out expected && check_cache_at yomin clean && sum bozbar frotz nitfol >actual4.sum && @@ -94,8 +94,8 @@ test_expect_success \ git update-index --add yomin && echo yomin yomin >yomin && read_tree_u_must_succeed -m -u $treeH $treeM && - git ls-files --stage >5.out || return 1 - git diff -U0 --no-index M.out 5.out >5diff.out + git ls-files --stage >5.out && + test_might_fail git diff -U0 --no-index M.out 5.out >5diff.out && compare_change 5diff.out expected && check_cache_at yomin dirty && sum bozbar frotz nitfol >actual5.sum && diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh index a72e700ae4..4f225db9a7 100755 --- a/t/t1006-cat-file.sh +++ b/t/t1006-cat-file.sh @@ -47,6 +47,18 @@ $content" test_cmp expect actual ' + test_expect_success "Type of $type is correct using --allow-unknown-type" ' + echo $type >expect && + git cat-file -t --allow-unknown-type $sha1 >actual && + test_cmp expect actual + ' + + test_expect_success "Size of $type is correct using --allow-unknown-type" ' + echo $size >expect && + git cat-file -s --allow-unknown-type $sha1 >actual && + test_cmp expect actual + ' + test -z "$content" || test_expect_success "Content of $type is correct" ' maybe_remove_timestamp "$content" $no_ts >expect && @@ -274,7 +286,7 @@ test_expect_success 'setup blobs which are likely to delta' ' ' test_expect_success 'confirm that neither loose blob is a delta' ' - cat >expect <<-EOF + cat >expect <<-EOF && $_z40 $_z40 EOF @@ -296,4 +308,37 @@ test_expect_success '%(deltabase) reports packed delta bases' ' } ' +bogus_type="bogus" +bogus_content="bogus" +bogus_size=$(strlen "$bogus_content") +bogus_sha1=$(echo_without_newline "$bogus_content" | git hash-object -t $bogus_type --literally -w --stdin) + +test_expect_success "Type of broken object is correct" ' + echo $bogus_type >expect && + git cat-file -t --allow-unknown-type $bogus_sha1 >actual && + test_cmp expect actual +' + +test_expect_success "Size of broken object is correct" ' + echo $bogus_size >expect && + git cat-file -s --allow-unknown-type $bogus_sha1 >actual && + test_cmp expect actual +' +bogus_type="abcdefghijklmnopqrstuvwxyz1234679" +bogus_content="bogus" +bogus_size=$(strlen "$bogus_content") +bogus_sha1=$(echo_without_newline "$bogus_content" | git hash-object -t $bogus_type --literally -w --stdin) + +test_expect_success "Type of broken object is correct when type is large" ' + echo $bogus_type >expect && + git cat-file -t --allow-unknown-type $bogus_sha1 >actual && + test_cmp expect actual +' + +test_expect_success "Size of large broken object is correct when type is large" ' + echo $bogus_size >expect && + git cat-file -s --allow-unknown-type $bogus_sha1 >actual && + test_cmp expect actual +' + test_done diff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh index f83df8eb8b..7d2baa15bb 100755 --- a/t/t1007-hash-object.sh +++ b/t/t1007-hash-object.sh @@ -201,4 +201,23 @@ test_expect_success 'corrupt tag' ' test_must_fail git hash-object -t tag --stdin </dev/null ' +test_expect_success 'hash-object complains about bogus type name' ' + test_must_fail git hash-object -t bogus --stdin </dev/null +' + +test_expect_success 'hash-object complains about truncated type name' ' + test_must_fail git hash-object -t bl --stdin </dev/null +' + +test_expect_success '--literally' ' + t=1234567890 && + echo example | git hash-object -t $t --literally --stdin +' + +test_expect_success '--literally with extra-long type' ' + t=12345678901234567890123456789012345678901234567890 && + t="$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t" && + echo example | git hash-object -t $t --literally --stdin +' + test_done diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 938fc8bfd7..66dd28644f 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -677,7 +677,7 @@ test_expect_success 'invalid unit' ' echo 1auto >expect && git config aninvalid.unit >actual && test_cmp expect actual && - cat >expect <<-\EOF + cat >expect <<-\EOF && fatal: bad numeric config value '\''1auto'\'' for '\''aninvalid.unit'\'' in .git/config: invalid unit EOF test_must_fail git config --int --get aninvalid.unit 2>actual && @@ -1165,7 +1165,7 @@ test_expect_failure 'adding a key into an empty section reuses header' ' Qkey = value EOF - git config section.key value + git config section.key value && test_cmp expect .git/config ' diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh index 7eecfb836a..ac10875408 100755 --- a/t/t1301-shared-repo.sh +++ b/t/t1301-shared-repo.sh @@ -12,12 +12,11 @@ setfacl -k . 2>/dev/null # User must have read permissions to the repo -> failure on --shared=0400 test_expect_success 'shared = 0400 (faulty permission u-w)' ' + test_when_finished "rm -rf sub" && mkdir sub && ( - cd sub && git init --shared=0400 + cd sub && + test_must_fail git init --shared=0400 ) - ret="$?" - rm -rf sub - test $ret != "0" ' modebits () { @@ -33,7 +32,7 @@ do git init --shared=1 && test 1 = "$(git config core.sharedrepository)" ) && - actual=$(ls -l sub/.git/HEAD) + actual=$(ls -l sub/.git/HEAD) && case "$actual" in -rw-rw-r--*) : happy @@ -90,10 +89,8 @@ do rm -f .git/info/refs && git update-server-info && actual="$(modebits .git/info/refs)" && - test "x$actual" = "x-$y" || { - ls -lt .git/info - false - } + verbose test "x$actual" = "x-$y" + ' umask 077 && @@ -102,10 +99,7 @@ do rm -f .git/info/refs && git update-server-info && actual="$(modebits .git/info/refs)" && - test "x$actual" = "x-$x" || { - ls -lt .git/info - false - } + verbose test "x$actual" = "x-$x" ' diff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh index 3e500ed7da..7e10bcfe39 100755 --- a/t/t1403-show-ref.sh +++ b/t/t1403-show-ref.sh @@ -28,7 +28,7 @@ test_expect_success 'show-ref' ' >expect && - test_must_fail git show-ref D >actual + test_must_fail git show-ref D >actual && test_cmp expect actual ' @@ -62,7 +62,7 @@ test_expect_success 'show-ref --verify' ' test_must_fail git show-ref --verify tags/A >actual && test_cmp expect actual && - test_must_fail git show-ref --verify D >actual + test_must_fail git show-ref --verify D >actual && test_cmp expect actual ' @@ -78,7 +78,7 @@ test_expect_success 'show-ref --verify -q' ' test_must_fail git show-ref --verify -q tags/A >actual && test_cmp expect actual && - test_must_fail git show-ref --verify -q D >actual + test_must_fail git show-ref --verify -q D >actual && test_cmp expect actual ' @@ -105,10 +105,10 @@ test_expect_success 'show-ref -d' ' test_cmp expect actual && git show-ref -d refs/heads/master >actual && - test_cmp expect actual + test_cmp expect actual && git show-ref -d --verify refs/heads/master >actual && - test_cmp expect actual + test_cmp expect actual && >expect && diff --git a/t/t1430-bad-ref-name.sh b/t/t1430-bad-ref-name.sh index 468e85621a..16d0b8bd1a 100755 --- a/t/t1430-bad-ref-name.sh +++ b/t/t1430-bad-ref-name.sh @@ -68,6 +68,14 @@ test_expect_success 'branch -D cannot delete non-ref in .git dir' ' test_cmp expect .git/my-private-file ' +test_expect_success 'branch -D cannot delete ref in .git dir' ' + git rev-parse HEAD >.git/my-private-file && + git rev-parse HEAD >expect && + git branch foo/legit && + test_must_fail git branch -D foo////./././../../../my-private-file && + test_cmp expect .git/my-private-file +' + test_expect_success 'branch -D cannot delete absolute path' ' git branch -f extra && test_must_fail git branch -D "$(pwd)/.git/refs/heads/extra" && diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh index 8f36aa9fc4..cc5b870e58 100755 --- a/t/t1501-worktree.sh +++ b/t/t1501-worktree.sh @@ -346,4 +346,81 @@ test_expect_success 'relative $GIT_WORK_TREE and git subprocesses' ' test_cmp expected actual ' +test_expect_success 'Multi-worktree setup' ' + mkdir work && + mkdir -p repo.git/repos/foo && + cp repo.git/HEAD repo.git/index repo.git/repos/foo && + test_might_fail cp repo.git/sharedindex.* repo.git/repos/foo && + sane_unset GIT_DIR GIT_CONFIG GIT_WORK_TREE +' + +test_expect_success 'GIT_DIR set (1)' ' + echo "gitdir: repo.git/repos/foo" >gitfile && + echo ../.. >repo.git/repos/foo/commondir && + ( + cd work && + GIT_DIR=../gitfile git rev-parse --git-common-dir >actual && + test-path-utils real_path "$TRASH_DIRECTORY/repo.git" >expect && + test_cmp expect actual + ) +' + +test_expect_success 'GIT_DIR set (2)' ' + echo "gitdir: repo.git/repos/foo" >gitfile && + echo "$(pwd)/repo.git" >repo.git/repos/foo/commondir && + ( + cd work && + GIT_DIR=../gitfile git rev-parse --git-common-dir >actual && + test-path-utils real_path "$TRASH_DIRECTORY/repo.git" >expect && + test_cmp expect actual + ) +' + +test_expect_success 'Auto discovery' ' + echo "gitdir: repo.git/repos/foo" >.git && + echo ../.. >repo.git/repos/foo/commondir && + ( + cd work && + git rev-parse --git-common-dir >actual && + test-path-utils real_path "$TRASH_DIRECTORY/repo.git" >expect && + test_cmp expect actual && + echo haha >data1 && + git add data1 && + git ls-files --full-name :/ | grep data1 >actual && + echo work/data1 >expect && + test_cmp expect actual + ) +' + +test_expect_success '$GIT_DIR/common overrides core.worktree' ' + mkdir elsewhere && + git --git-dir=repo.git config core.worktree "$TRASH_DIRECTORY/elsewhere" && + echo "gitdir: repo.git/repos/foo" >.git && + echo ../.. >repo.git/repos/foo/commondir && + ( + cd work && + git rev-parse --git-common-dir >actual && + test-path-utils real_path "$TRASH_DIRECTORY/repo.git" >expect && + test_cmp expect actual && + echo haha >data2 && + git add data2 && + git ls-files --full-name :/ | grep data2 >actual && + echo work/data2 >expect && + test_cmp expect actual + ) +' + +test_expect_success '$GIT_WORK_TREE overrides $GIT_DIR/common' ' + echo "gitdir: repo.git/repos/foo" >.git && + echo ../.. >repo.git/repos/foo/commondir && + ( + cd work && + echo haha >data3 && + git --git-dir=../.git --work-tree=. add data3 && + git ls-files --full-name -- :/ | grep data3 >actual && + echo data3 >expect && + test_cmp expect actual + ) +' + test_done diff --git a/t/t1509/prepare-chroot.sh b/t/t1509/prepare-chroot.sh index 62691172e3..6d47e2c725 100755 --- a/t/t1509/prepare-chroot.sh +++ b/t/t1509/prepare-chroot.sh @@ -14,25 +14,45 @@ xmkdir() { R="$1" +[ "$(id -u)" -eq 0 ] && die "This script should not be run as root, what if it does rm -rf /?" [ -n "$R" ] || die "usage: prepare-chroot.sh <root>" [ -x git ] || die "This script needs to be executed at git source code's top directory" -[ -x /bin/busybox ] || die "You need busybox" +if [ -x /bin/busybox ]; then + BB=/bin/busybox +elif [ -x /usr/bin/busybox ]; then + BB=/usr/bin/busybox +else + die "You need busybox" +fi xmkdir "$R" "$R/bin" "$R/etc" "$R/lib" "$R/dev" -[ -c "$R/dev/null" ] || die "/dev/null is missing. Do mknod $R/dev/null c 1 3 && chmod 666 $R/dev/null" +touch "$R/dev/null" echo "root:x:0:0:root:/:/bin/sh" > "$R/etc/passwd" echo "$(id -nu):x:$(id -u):$(id -g)::$(pwd)/t:/bin/sh" >> "$R/etc/passwd" echo "root::0:root" > "$R/etc/group" echo "$(id -ng)::$(id -g):$(id -nu)" >> "$R/etc/group" -[ -x "$R/bin/busybox" ] || cp /bin/busybox "$R/bin/busybox" -[ -x "$R/bin/sh" ] || ln -s /bin/busybox "$R/bin/sh" -[ -x "$R/bin/su" ] || ln -s /bin/busybox "$R/bin/su" +[ -x "$R$BB" ] || cp $BB "$R/bin/busybox" +for cmd in sh su ls expr tr basename rm mkdir mv id uname dirname cat true sed diff; do + ln -f -s /bin/busybox "$R/bin/$cmd" +done mkdir -p "$R$(pwd)" rsync --exclude-from t/t1509/excludes -Ha . "$R$(pwd)" -ldd git | grep '/' | sed 's,.*\s\(/[^ ]*\).*,\1,' | while read i; do - mkdir -p "$R$(dirname $i)" - cp "$i" "$R/$i" +# Fake perl to reduce dependency, t1509 does not use perl, but some +# env might slip through, see test-lib.sh, unset.*PERL_PATH +sed 's|^PERL_PATH=.*|PERL_PATH=/bin/true|' GIT-BUILD-OPTIONS > "$R$(pwd)/GIT-BUILD-OPTIONS" +for cmd in git $BB;do + ldd $cmd | grep '/' | sed 's,.*\s\(/[^ ]*\).*,\1,' | while read i; do + mkdir -p "$R$(dirname $i)" + cp "$i" "$R/$i" + done done -echo "Execute this in root: 'chroot $R /bin/su - $(id -nu)'" +cat <<EOF +All is set up in $R, execute t1509 with the following commands: + +sudo chroot $R /bin/su - $(id -nu) +IKNOWWHATIAMDOING=YES ./t1509-root-worktree.sh -v -i + +When you are done, simply delete $R to clean up +EOF diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh index e1b2a99f10..33c1a587b3 100755 --- a/t/t1510-repo-setup.sh +++ b/t/t1510-repo-setup.sh @@ -106,6 +106,7 @@ setup_env () { expect () { cat >"$1/expected" <<-EOF setup: git_dir: $2 + setup: git_common_dir: $2 setup: worktree: $3 setup: cwd: $4 setup: prefix: $5 diff --git a/t/t1700-split-index.sh b/t/t1700-split-index.sh index 92f7298fba..193d55c3f4 100755 --- a/t/t1700-split-index.sh +++ b/t/t1700-split-index.sh @@ -191,7 +191,7 @@ test_expect_success 'unify index, two files remain' ' 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two EOF - test_cmp ls-files.expect ls-files.actual + test_cmp ls-files.expect ls-files.actual && test-dump-split-index .git/index | sed "/^own/d" >actual && cat >expect <<EOF && diff --git a/t/t2025-checkout-to.sh b/t/t2025-checkout-to.sh new file mode 100755 index 0000000000..f8e4df4818 --- /dev/null +++ b/t/t2025-checkout-to.sh @@ -0,0 +1,129 @@ +#!/bin/sh + +test_description='test git checkout --to' + +. ./test-lib.sh + +test_expect_success 'setup' ' + test_commit init +' + +test_expect_success 'checkout --to not updating paths' ' + test_must_fail git checkout --to -- init.t +' + +test_expect_success 'checkout --to an existing worktree' ' + mkdir -p existing/subtree && + test_must_fail git checkout --detach --to existing master +' + +test_expect_success 'checkout --to an existing empty worktree' ' + mkdir existing_empty && + git checkout --detach --to existing_empty master +' + +test_expect_success 'checkout --to refuses to checkout locked branch' ' + test_must_fail git checkout --to zere master && + ! test -d zere && + ! test -d .git/worktrees/zere +' + +test_expect_success 'checkout --to a new worktree' ' + git rev-parse HEAD >expect && + git checkout --detach --to here master && + ( + cd here && + test_cmp ../init.t init.t && + test_must_fail git symbolic-ref HEAD && + git rev-parse HEAD >actual && + test_cmp ../expect actual && + git fsck + ) +' + +test_expect_success 'checkout --to a new worktree from a subdir' ' + ( + mkdir sub && + cd sub && + git checkout --detach --to here master && + cd here && + test_cmp ../../init.t init.t + ) +' + +test_expect_success 'checkout --to from a linked checkout' ' + ( + cd here && + git checkout --detach --to nested-here master && + cd nested-here && + git fsck + ) +' + +test_expect_success 'checkout --to a new worktree creating new branch' ' + git checkout --to there -b newmaster master && + ( + cd there && + test_cmp ../init.t init.t && + git symbolic-ref HEAD >actual && + echo refs/heads/newmaster >expect && + test_cmp expect actual && + git fsck + ) +' + +test_expect_success 'die the same branch is already checked out' ' + ( + cd here && + test_must_fail git checkout newmaster + ) +' + +test_expect_success 'not die the same branch is already checked out' ' + ( + cd here && + git checkout --ignore-other-worktrees --to anothernewmaster newmaster + ) +' + +test_expect_success 'not die on re-checking out current branch' ' + ( + cd there && + git checkout newmaster + ) +' + +test_expect_success 'checkout --to from a bare repo' ' + ( + git clone --bare . bare && + cd bare && + git checkout --to ../there2 -b bare-master master + ) +' + +test_expect_success 'checkout from a bare repo without --to' ' + ( + cd bare && + test_must_fail git checkout master + ) +' + +test_expect_success 'checkout with grafts' ' + test_when_finished rm .git/info/grafts && + test_commit abc && + SHA1=`git rev-parse HEAD` && + test_commit def && + test_commit xyz && + echo "`git rev-parse HEAD` $SHA1" >.git/info/grafts && + cat >expected <<-\EOF && + xyz + abc + EOF + git log --format=%s -2 >actual && + test_cmp expected actual && + git checkout --detach --to grafted master && + git --git-dir=grafted/.git log --format=%s -2 >actual && + test_cmp expected actual +' + +test_done diff --git a/t/t2026-prune-linked-checkouts.sh b/t/t2026-prune-linked-checkouts.sh new file mode 100755 index 0000000000..1821a480c5 --- /dev/null +++ b/t/t2026-prune-linked-checkouts.sh @@ -0,0 +1,96 @@ +#!/bin/sh + +test_description='prune $GIT_DIR/worktrees' + +. ./test-lib.sh + +test_expect_success initialize ' + git commit --allow-empty -m init +' + +test_expect_success 'prune --worktrees on normal repo' ' + git prune --worktrees && + test_must_fail git prune --worktrees abc +' + +test_expect_success 'prune files inside $GIT_DIR/worktrees' ' + mkdir .git/worktrees && + : >.git/worktrees/abc && + git prune --worktrees --verbose >actual && + cat >expect <<EOF && +Removing worktrees/abc: not a valid directory +EOF + test_i18ncmp expect actual && + ! test -f .git/worktrees/abc && + ! test -d .git/worktrees +' + +test_expect_success 'prune directories without gitdir' ' + mkdir -p .git/worktrees/def/abc && + : >.git/worktrees/def/def && + cat >expect <<EOF && +Removing worktrees/def: gitdir file does not exist +EOF + git prune --worktrees --verbose >actual && + test_i18ncmp expect actual && + ! test -d .git/worktrees/def && + ! test -d .git/worktrees +' + +test_expect_success SANITY 'prune directories with unreadable gitdir' ' + mkdir -p .git/worktrees/def/abc && + : >.git/worktrees/def/def && + : >.git/worktrees/def/gitdir && + chmod u-r .git/worktrees/def/gitdir && + git prune --worktrees --verbose >actual && + test_i18ngrep "Removing worktrees/def: unable to read gitdir file" actual && + ! test -d .git/worktrees/def && + ! test -d .git/worktrees +' + +test_expect_success 'prune directories with invalid gitdir' ' + mkdir -p .git/worktrees/def/abc && + : >.git/worktrees/def/def && + : >.git/worktrees/def/gitdir && + git prune --worktrees --verbose >actual && + test_i18ngrep "Removing worktrees/def: invalid gitdir file" actual && + ! test -d .git/worktrees/def && + ! test -d .git/worktrees +' + +test_expect_success 'prune directories with gitdir pointing to nowhere' ' + mkdir -p .git/worktrees/def/abc && + : >.git/worktrees/def/def && + echo "$(pwd)"/nowhere >.git/worktrees/def/gitdir && + git prune --worktrees --verbose >actual && + test_i18ngrep "Removing worktrees/def: gitdir file points to non-existent location" actual && + ! test -d .git/worktrees/def && + ! test -d .git/worktrees +' + +test_expect_success 'not prune locked checkout' ' + test_when_finished rm -r .git/worktrees && + mkdir -p .git/worktrees/ghi && + : >.git/worktrees/ghi/locked && + git prune --worktrees && + test -d .git/worktrees/ghi +' + +test_expect_success 'not prune recent checkouts' ' + test_when_finished rm -r .git/worktrees && + mkdir zz && + mkdir -p .git/worktrees/jlm && + echo "$(pwd)"/zz >.git/worktrees/jlm/gitdir && + rmdir zz && + git prune --worktrees --verbose --expire=2.days.ago && + test -d .git/worktrees/jlm +' + +test_expect_success 'not prune proper checkouts' ' + test_when_finished rm -r .git/worktrees && + git checkout "--to=$PWD/nop" --detach master && + git prune --worktrees && + test -d .git/worktrees/nop +' + +test_done diff --git a/t/t2203-add-intent.sh b/t/t2203-add-intent.sh index 2a4a749b4f..7c641bfaf4 100755 --- a/t/t2203-add-intent.sh +++ b/t/t2203-add-intent.sh @@ -5,10 +5,24 @@ test_description='Intent to add' . ./test-lib.sh test_expect_success 'intent to add' ' + test_commit 1 && + git rm 1.t && + echo hello >1.t && echo hello >file && echo hello >elif && git add -N file && - git add elif + git add elif && + git add -N 1.t +' + +test_expect_success 'git status' ' + git status --porcelain | grep -v actual >actual && + cat >expect <<-\EOF && + DA 1.t + A elif + A file + EOF + test_cmp expect actual ' test_expect_success 'check result of "add -N"' ' @@ -43,7 +57,8 @@ test_expect_success 'i-t-a entry is simply ignored' ' git add -N nitfol && git commit -m second && test $(git ls-tree HEAD -- nitfol | wc -l) = 0 && - test $(git diff --name-only HEAD -- nitfol | wc -l) = 1 + test $(git diff --name-only HEAD -- nitfol | wc -l) = 0 && + test $(git diff --name-only -- nitfol | wc -l) = 1 ' test_expect_success 'can commit with an unrelated i-t-a entry in index' ' @@ -72,13 +87,13 @@ test_expect_success 'cache-tree invalidates i-t-a paths' ' : >dir/bar && git add -N dir/bar && git diff --cached --name-only >actual && - echo dir/bar >expect && + >expect && test_cmp expect actual && git write-tree >/dev/null && git diff --cached --name-only >actual && - echo dir/bar >expect && + >expect && test_cmp expect actual ' diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh index b2798feef7..3fc484e8c3 100755 --- a/t/t3001-ls-files-others-exclude.sh +++ b/t/t3001-ls-files-others-exclude.sh @@ -294,7 +294,7 @@ one/a.1 one/two/a.1 three/a.1 EOF - git ls-files -o -i --exclude "**/a.1" >actual + git ls-files -o -i --exclude "**/a.1" >actual && test_cmp expect actual ' diff --git a/t/t3010-ls-files-killed-modified.sh b/t/t3010-ls-files-killed-modified.sh index 6d3b828a95..580e158f99 100755 --- a/t/t3010-ls-files-killed-modified.sh +++ b/t/t3010-ls-files-killed-modified.sh @@ -55,14 +55,11 @@ test_expect_success 'git update-index --add to add various paths.' ' : >path9 && date >path10 && git update-index --add -- path0 path?/file? pathx/ju path7 path8 path9 path10 && - for i in 1 2 - do - git init submod$i && - ( - cd submod$i && git commit --allow-empty -m "empty $i" - ) || break - done && - git update-index --add submod[12] + git init submod1 && + git -C submod1 commit --allow-empty -m "empty 1" && + git init submod2 && + git -C submod2 commit --allow-empty -m "empty 2" && + git update-index --add submod[12] && ( cd submod1 && git commit --allow-empty -m "empty 1 (updated)" @@ -99,12 +96,12 @@ test_expect_success 'git ls-files -k to show killed files.' ' ' test_expect_success 'git ls-files -k output (w/o icase)' ' - git ls-files -k >.output + git ls-files -k >.output && test_cmp .expected .output ' test_expect_success 'git ls-files -k output (w/ icase)' ' - git -c core.ignorecase=true ls-files -k >.output + git -c core.ignorecase=true ls-files -k >.output && test_cmp .expected .output ' diff --git a/t/t3031-merge-criscross.sh b/t/t3031-merge-criscross.sh index 7f41607c56..e59b0a32d6 100755 --- a/t/t3031-merge-criscross.sh +++ b/t/t3031-merge-criscross.sh @@ -32,7 +32,7 @@ test_expect_success 'setup repo with criss-cross history' ' do echo $n > data/$n && n=$(($n+1)) || - break + return 1 done && # check them in diff --git a/t/t3033-merge-toplevel.sh b/t/t3033-merge-toplevel.sh new file mode 100755 index 0000000000..46aadc410b --- /dev/null +++ b/t/t3033-merge-toplevel.sh @@ -0,0 +1,136 @@ +#!/bin/sh + +test_description='"git merge" top-level frontend' + +. ./test-lib.sh + +t3033_reset () { + git checkout -B master two && + git branch -f left three && + git branch -f right four +} + +test_expect_success setup ' + test_commit one && + git branch left && + git branch right && + test_commit two && + git checkout left && + test_commit three && + git checkout right && + test_commit four && + git checkout master +' + +# Local branches + +test_expect_success 'merge an octopus into void' ' + t3033_reset && + git checkout --orphan test && + git rm -fr . && + test_must_fail git merge left right && + test_must_fail git rev-parse --verify HEAD && + git diff --quiet && + test_must_fail git rev-parse HEAD +' + +test_expect_success 'merge an octopus, fast-forward (ff)' ' + t3033_reset && + git reset --hard one && + git merge left right && + # one is ancestor of three (left) and four (right) + test_must_fail git rev-parse --verify HEAD^3 && + git rev-parse HEAD^1 HEAD^2 | sort >actual && + git rev-parse three four | sort >expect && + test_cmp expect actual +' + +test_expect_success 'merge octopus, non-fast-forward (ff)' ' + t3033_reset && + git reset --hard one && + git merge --no-ff left right && + # one is ancestor of three (left) and four (right) + test_must_fail git rev-parse --verify HEAD^4 && + git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual && + git rev-parse one three four | sort >expect && + test_cmp expect actual +' + +test_expect_success 'merge octopus, fast-forward (does not ff)' ' + t3033_reset && + git merge left right && + # two (master) is not an ancestor of three (left) and four (right) + test_must_fail git rev-parse --verify HEAD^4 && + git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual && + git rev-parse two three four | sort >expect && + test_cmp expect actual +' + +test_expect_success 'merge octopus, non-fast-forward' ' + t3033_reset && + git merge --no-ff left right && + test_must_fail git rev-parse --verify HEAD^4 && + git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual && + git rev-parse two three four | sort >expect && + test_cmp expect actual +' + +# The same set with FETCH_HEAD + +test_expect_success 'merge FETCH_HEAD octopus into void' ' + t3033_reset && + git checkout --orphan test && + git rm -fr . && + git fetch . left right && + test_must_fail git merge FETCH_HEAD && + test_must_fail git rev-parse --verify HEAD && + git diff --quiet && + test_must_fail git rev-parse HEAD +' + +test_expect_success 'merge FETCH_HEAD octopus fast-forward (ff)' ' + t3033_reset && + git reset --hard one && + git fetch . left right && + git merge FETCH_HEAD && + # one is ancestor of three (left) and four (right) + test_must_fail git rev-parse --verify HEAD^3 && + git rev-parse HEAD^1 HEAD^2 | sort >actual && + git rev-parse three four | sort >expect && + test_cmp expect actual +' + +test_expect_success 'merge FETCH_HEAD octopus non-fast-forward (ff)' ' + t3033_reset && + git reset --hard one && + git fetch . left right && + git merge --no-ff FETCH_HEAD && + # one is ancestor of three (left) and four (right) + test_must_fail git rev-parse --verify HEAD^4 && + git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual && + git rev-parse one three four | sort >expect && + test_cmp expect actual +' + +test_expect_success 'merge FETCH_HEAD octopus fast-forward (does not ff)' ' + t3033_reset && + git fetch . left right && + git merge FETCH_HEAD && + # two (master) is not an ancestor of three (left) and four (right) + test_must_fail git rev-parse --verify HEAD^4 && + git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual && + git rev-parse two three four | sort >expect && + test_cmp expect actual +' + +test_expect_success 'merge FETCH_HEAD octopus non-fast-forward' ' + t3033_reset && + git fetch . left right && + git merge --no-ff FETCH_HEAD && + test_must_fail git rev-parse --verify HEAD^4 && + git rev-parse HEAD^1 HEAD^2 HEAD^3 | sort >actual && + git rev-parse two three four | sort >expect && + test_cmp expect actual +' + +test_done diff --git a/t/t3060-ls-files-with-tree.sh b/t/t3060-ls-files-with-tree.sh index 61c1f53d1b..44f378ce41 100755 --- a/t/t3060-ls-files-with-tree.sh +++ b/t/t3060-ls-files-with-tree.sh @@ -18,22 +18,16 @@ test_expect_success setup ' echo file >expected && mkdir sub && - bad= && for n in 0 1 2 3 4 5 do for m in 0 1 2 3 4 5 6 7 8 9 do num=00$n$m && >sub/file-$num && - echo file-$num >>expected || { - bad=t - break - } - done && test -z "$bad" || { - bad=t - break - } - done && test -z "$bad" && + echo file-$num >>expected || + return 1 + done + done && git add . && git commit -m "add a bunch of files" && diff --git a/t/t3202-show-branch-octopus.sh b/t/t3202-show-branch-octopus.sh index 0a5d5e669f..6adf47869c 100755 --- a/t/t3202-show-branch-octopus.sh +++ b/t/t3202-show-branch-octopus.sh @@ -19,7 +19,7 @@ test_expect_success 'setup' ' > file$i && git add file$i && test_tick && - git commit -m branch$i || break + git commit -m branch$i || return 1 done ' diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh index ba4f98e800..f51d0f3cad 100755 --- a/t/t3203-branch-output.sh +++ b/t/t3203-branch-output.sh @@ -96,7 +96,7 @@ test_expect_success 'git branch -v pattern does not show branch summaries' ' test_expect_success 'git branch shows detached HEAD properly' ' cat >expect <<EOF && -* (detached from $(git rev-parse --short HEAD^0)) +* (HEAD detached at $(git rev-parse --short HEAD^0)) branch-one branch-two master @@ -106,4 +106,41 @@ EOF test_i18ncmp expect actual ' +test_expect_success 'git branch shows detached HEAD properly after moving' ' + cat >expect <<EOF && +* (HEAD detached from $(git rev-parse --short HEAD)) + branch-one + branch-two + master +EOF + git reset --hard HEAD^1 && + git branch >actual && + test_i18ncmp expect actual +' + +test_expect_success 'git branch shows detached HEAD properly from tag' ' + cat >expect <<EOF && +* (HEAD detached at fromtag) + branch-one + branch-two + master +EOF + git tag fromtag master && + git checkout fromtag && + git branch >actual && + test_i18ncmp expect actual +' + +test_expect_success 'git branch shows detached HEAD properly after moving from tag' ' + cat >expect <<EOF && +* (HEAD detached from fromtag) + branch-one + branch-two + master +EOF + git reset --hard HEAD^1 && + git branch >actual && + test_i18ncmp expect actual +' + test_done diff --git a/t/t3305-notes-fanout.sh b/t/t3305-notes-fanout.sh index b1ea64b213..54460beec4 100755 --- a/t/t3305-notes-fanout.sh +++ b/t/t3305-notes-fanout.sh @@ -51,15 +51,12 @@ test_expect_success 'deleting most notes with git-notes' ' num_notes=250 && i=0 && git rev-list HEAD | - while read sha1 + while test $i -lt $num_notes && read sha1 do i=$(($i + 1)) && - if test $i -gt $num_notes - then - break - fi && test_tick && - git notes remove "$sha1" + git notes remove "$sha1" || + exit 1 done ' diff --git a/t/t3402-rebase-merge.sh b/t/t3402-rebase-merge.sh index 5a27ec9b5e..8f64505e4f 100755 --- a/t/t3402-rebase-merge.sh +++ b/t/t3402-rebase-merge.sh @@ -47,7 +47,7 @@ test_expect_success setup ' ' test_expect_success 'reference merge' ' - git merge -s recursive "reference merge" HEAD master + git merge -s recursive -m "reference merge" master ' PRE_REBASE=$(git rev-parse test-rebase) diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 034eb35cdf..ac429a0bbb 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -950,7 +950,7 @@ test_expect_success 'rebase --edit-todo can be used to modify todo' ' set_fake_editor && FAKE_LINES="edit 1 2 3" git rebase -i HEAD~3 && FAKE_LINES="2 1" git rebase --edit-todo && - git rebase --continue + git rebase --continue && test M = $(git cat-file commit HEAD^ | sed -ne \$p) && test L = $(git cat-file commit HEAD | sed -ne \$p) ' @@ -1007,7 +1007,7 @@ test_expect_success 'rebase -i with --strategy and -X' ' ' test_expect_success 'rebase -i error on commits with \ in message' ' - current_head=$(git rev-parse HEAD) + current_head=$(git rev-parse HEAD) && test_when_finished "git rebase --abort; git reset --hard $current_head; rm -f error" && test_commit TO-REMOVE will-conflict old-content && test_commit "\temp" will-conflict new-content dummy && @@ -1055,4 +1055,51 @@ test_expect_success 'todo count' ' grep "^# Rebase ..* onto ..* ([0-9]" actual ' +test_expect_success 'rebase -i commits that overwrite untracked files (pick)' ' + git checkout --force branch2 && + git clean -f && + set_fake_editor && + FAKE_LINES="edit 1 2" git rebase -i A && + test_cmp_rev HEAD F && + test_path_is_missing file6 && + >file6 && + test_must_fail git rebase --continue && + test_cmp_rev HEAD F && + rm file6 && + git rebase --continue && + test_cmp_rev HEAD I +' + +test_expect_success 'rebase -i commits that overwrite untracked files (squash)' ' + git checkout --force branch2 && + git clean -f && + git tag original-branch2 && + set_fake_editor && + FAKE_LINES="edit 1 squash 2" git rebase -i A && + test_cmp_rev HEAD F && + test_path_is_missing file6 && + >file6 && + test_must_fail git rebase --continue && + test_cmp_rev HEAD F && + rm file6 && + git rebase --continue && + test $(git cat-file commit HEAD | sed -ne \$p) = I && + git reset --hard original-branch2 +' + +test_expect_success 'rebase -i commits that overwrite untracked files (no ff)' ' + git checkout --force branch2 && + git clean -f && + set_fake_editor && + FAKE_LINES="edit 1 2" git rebase -i --no-ff A && + test $(git cat-file commit HEAD | sed -ne \$p) = F && + test_path_is_missing file6 && + >file6 && + test_must_fail git rebase --continue && + test $(git cat-file commit HEAD | sed -ne \$p) = F && + rm file6 && + git rebase --continue && + test $(git cat-file commit HEAD | sed -ne \$p) = I +' + test_done diff --git a/t/t3405-rebase-malformed.sh b/t/t3405-rebase-malformed.sh index 19eddadcf7..ff8c360cd5 100755 --- a/t/t3405-rebase-malformed.sh +++ b/t/t3405-rebase-malformed.sh @@ -24,7 +24,7 @@ test_expect_success setup ' git add file1 file2 && test_tick && git commit -m "Initial commit" && - git branch diff-in-message + git branch diff-in-message && git checkout -b multi-line-subject && cat F >file2 && @@ -36,7 +36,7 @@ test_expect_success setup ' git checkout diff-in-message && echo "commit log message containing a diff" >G && - echo "" >>G + echo "" >>G && cat G >file2 && git add file2 && git diff --cached >>G && diff --git a/t/t3425-rebase-topology-merges.sh b/t/t3425-rebase-topology-merges.sh index 1d195fbd64..846f85c27e 100755 --- a/t/t3425-rebase-topology-merges.sh +++ b/t/t3425-rebase-topology-merges.sh @@ -24,7 +24,7 @@ test_expect_success 'setup of non-linear-history' ' test_commit c && git checkout b && test_commit d && - test_commit e + test_commit e && git checkout c && test_commit g && @@ -33,7 +33,7 @@ test_expect_success 'setup of non-linear-history' ' cherry_pick gp g && test_commit i && git checkout b && - test_commit f + test_commit f && git checkout d && test_commit n && diff --git a/t/t3511-cherry-pick-x.sh b/t/t3511-cherry-pick-x.sh index f97727975b..b7dff09d06 100755 --- a/t/t3511-cherry-pick-x.sh +++ b/t/t3511-cherry-pick-x.sh @@ -36,6 +36,20 @@ mesg_with_cherry_footer="$mesg_with_footer_sob (cherry picked from commit da39a3ee5e6b4b0d3255bfef95601890afd80709) Tested-by: C.U. Thor <cuthor@example.com>" +mesg_unclean="$mesg_one_line + + +leading empty lines + + +consecutive empty lines + +# hash tag comment + +trailing empty lines + + +" test_expect_success setup ' git config advice.detachedhead false && @@ -53,6 +67,10 @@ test_expect_success setup ' test_commit "$mesg_with_footer_sob" foo b mesg-with-footer-sob && git reset --hard initial && test_commit "$mesg_with_cherry_footer" foo b mesg-with-cherry-footer && + git reset --hard initial && + test_config commit.cleanup verbatim && + test_commit "$mesg_unclean" foo b mesg-unclean && + test_unconfig commit.cleanup && pristine_detach initial && test_commit conflicting unrelated ' @@ -216,4 +234,14 @@ test_expect_success 'cherry-pick -x -s treats "(cherry picked from..." line as p test_cmp expect actual ' +test_expect_success 'cherry-pick preserves commit message' ' + pristine_detach initial && + printf "$mesg_unclean" >expect && + git log -1 --pretty=format:%B mesg-unclean >actual && + test_cmp expect actual && + git cherry-pick mesg-unclean && + git log -1 --pretty=format:%B >actual && + test_cmp expect actual +' + test_done diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index e00d7d2b61..9d90d2c935 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -38,37 +38,37 @@ test_expect_success \ test_expect_success \ 'Test that git rm --cached foo succeeds if the index matches the file' \ - 'echo content > foo - git add foo + 'echo content >foo && + git add foo && git rm --cached foo' test_expect_success \ 'Test that git rm --cached foo succeeds if the index matches the file' \ - 'echo content > foo - git add foo - git commit -m foo - echo "other content" > foo + 'echo content >foo && + git add foo && + git commit -m foo && + echo "other content" >foo && git rm --cached foo' test_expect_success \ 'Test that git rm --cached foo fails if the index matches neither the file nor HEAD' ' - echo content > foo - git add foo - git commit -m foo - echo "other content" > foo - git add foo - echo "yet another content" > foo + echo content >foo && + git add foo && + git commit -m foo --allow-empty && + echo "other content" >foo && + git add foo && + echo "yet another content" >foo && test_must_fail git rm --cached foo ' test_expect_success \ 'Test that git rm --cached -f foo works in case where --cached only did not' \ - 'echo content > foo - git add foo - git commit -m foo - echo "other content" > foo - git add foo - echo "yet another content" > foo + 'echo content >foo && + git add foo && + git commit -m foo --allow-empty && + echo "other content" >foo && + git add foo && + echo "yet another content" >foo && git rm --cached -f foo' test_expect_success \ @@ -170,7 +170,7 @@ test_expect_success 'but with -f it should work.' ' git rm -f foo baz && test ! -f foo && test ! -f baz && - test_must_fail git ls-files --error-unmatch foo + test_must_fail git ls-files --error-unmatch foo && test_must_fail git ls-files --error-unmatch baz ' @@ -183,7 +183,7 @@ test_expect_success 'refuse to remove cached empty file with modifications' ' test_expect_success 'remove intent-to-add file without --force' ' echo content >intent-to-add && - git add -N intent-to-add + git add -N intent-to-add && git rm --cached intent-to-add ' @@ -201,7 +201,7 @@ test_expect_success 'Recursive without -r fails' ' ' test_expect_success 'Recursive with -r but dirty' ' - echo qfwfq >>frotz/nitfol + echo qfwfq >>frotz/nitfol && test_must_fail git rm -r frotz && test -d frotz && test -f frotz/nitfol diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index 24ddd8a704..deae948c76 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -326,15 +326,34 @@ test_expect_success 'split hunk "add -p (edit)"' ' # 2. Correct version applies the (not)edited version, and asks # about the next hunk, against which we say q and program # exits. - for a in s e q n q q - do - echo $a - done | + printf "%s\n" s e q n q q | EDITOR=: git add -p && git diff >actual && ! grep "^+15" actual ' +test_expect_failure 'split hunk "add -p (no, yes, edit)"' ' + cat >test <<-\EOF && + 5 + 10 + 20 + 21 + 30 + 31 + 40 + 50 + 60 + EOF + git reset && + # test sequence is s(plit), n(o), y(es), e(dit) + # q n q q is there to make sure we exit at the end. + printf "%s\n" s n y e q n q q | + EDITOR=: git add -p 2>error && + test_must_be_empty error && + git diff >actual && + ! grep "^+31" actual +' + test_expect_success 'patch mode ignores unmerged entries' ' git reset --hard && test_commit conflict && diff --git a/t/t3901-i18n-patch.sh b/t/t3901-i18n-patch.sh index a392f3d1d6..75cf3ff9bd 100755 --- a/t/t3901-i18n-patch.sh +++ b/t/t3901-i18n-patch.sh @@ -9,7 +9,7 @@ test_description='i18n settings and format-patch | am pipe' check_encoding () { # Make sure characters are not corrupted - cnt="$1" header="$2" i=1 j=0 bad=0 + cnt="$1" header="$2" i=1 j=0 while test "$i" -le $cnt do git format-patch --encoding=UTF-8 --stdout HEAD~$i..HEAD~$j | @@ -20,14 +20,10 @@ check_encoding () { grep "^encoding ISO8859-1" ;; *) grep "^encoding ISO8859-1"; test "$?" != 0 ;; - esac || { - bad=1 - break - } + esac || return 1 j=$i i=$(($i+1)) done - (exit $bad) } test_expect_success setup ' diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 1e29962fad..0746eeeff7 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -10,6 +10,8 @@ test_description='Test git stash' test_expect_success 'stash some dirty working directory' ' echo 1 > file && git add file && + echo unrelated >other-file && + git add other-file && test_tick && git commit -m initial && echo 2 > file && @@ -43,10 +45,15 @@ test_expect_success 'applying bogus stash does nothing' ' test_cmp expect file ' +test_expect_success 'apply requires a clean index' ' + test_when_finished "git reset --hard" && + echo changed >other-file && + git add other-file && + test_must_fail git stash apply +' + test_expect_success 'apply does not need clean working directory' ' echo 4 >other-file && - git add other-file && - echo 5 >other-file && git stash apply && echo 3 >expect && test_cmp expect file @@ -695,8 +702,8 @@ test_expect_success 'setup stash with index and worktree changes' ' ' test_expect_success 'stash list implies --first-parent -m' ' - cat >expect <<-\EOF && - stash@{0}: WIP on master: b27a2bc subdir + cat >expect <<-EOF && + stash@{0} diff --git a/file b/file index 257cc56..d26b33d 100644 @@ -706,13 +713,13 @@ test_expect_success 'stash list implies --first-parent -m' ' -foo +working EOF - git stash list -p >actual && + git stash list --format=%gd -p >actual && test_cmp expect actual ' test_expect_success 'stash list --cc shows combined diff' ' cat >expect <<-\EOF && - stash@{0}: WIP on master: b27a2bc subdir + stash@{0} diff --cc file index 257cc56,9015a7a..d26b33d @@ -723,7 +730,7 @@ test_expect_success 'stash list --cc shows combined diff' ' -index ++working EOF - git stash list -p --cc >actual && + git stash list --format=%gd -p --cc >actual && test_cmp expect actual ' diff --git a/t/t3904-stash-patch.sh b/t/t3904-stash-patch.sh index 70655c1848..38e730090f 100755 --- a/t/t3904-stash-patch.sh +++ b/t/t3904-stash-patch.sh @@ -1,9 +1,15 @@ #!/bin/sh -test_description='git checkout --patch' +test_description='stash -p' . ./lib-patch-mode.sh -test_expect_success PERL 'setup' ' +if ! test_have_prereq PERL +then + skip_all='skipping stash -p tests, perl not available' + test_done +fi + +test_expect_success 'setup' ' mkdir dir && echo parent > dir/foo && echo dummy > bar && @@ -20,7 +26,7 @@ test_expect_success PERL 'setup' ' # note: order of files with unstaged changes: HEAD bar dir/foo -test_expect_success PERL 'saying "n" does nothing' ' +test_expect_success 'saying "n" does nothing' ' set_state HEAD HEADfile_work HEADfile_index && set_state dir/foo work index && (echo n; echo n; echo n) | test_must_fail git stash save -p && @@ -29,7 +35,7 @@ test_expect_success PERL 'saying "n" does nothing' ' verify_state dir/foo work index ' -test_expect_success PERL 'git stash -p' ' +test_expect_success 'git stash -p' ' (echo y; echo n; echo y) | git stash save -p && verify_state HEAD committed HEADfile_index && verify_saved_state bar && @@ -41,7 +47,7 @@ test_expect_success PERL 'git stash -p' ' verify_state dir/foo work head ' -test_expect_success PERL 'git stash -p --no-keep-index' ' +test_expect_success 'git stash -p --no-keep-index' ' set_state HEAD HEADfile_work HEADfile_index && set_state bar bar_work bar_index && set_state dir/foo work index && @@ -56,7 +62,7 @@ test_expect_success PERL 'git stash -p --no-keep-index' ' verify_state dir/foo work index ' -test_expect_success PERL 'git stash --no-keep-index -p' ' +test_expect_success 'git stash --no-keep-index -p' ' set_state HEAD HEADfile_work HEADfile_index && set_state bar bar_work bar_index && set_state dir/foo work index && @@ -71,8 +77,31 @@ test_expect_success PERL 'git stash --no-keep-index -p' ' verify_state dir/foo work index ' -test_expect_success PERL 'none of this moved HEAD' ' +test_expect_success 'none of this moved HEAD' ' verify_saved_head ' +test_expect_failure 'stash -p with split hunk' ' + git reset --hard && + cat >test <<-\EOF && + aaa + bbb + ccc + EOF + git add test && + git commit -m "initial" && + cat >test <<-\EOF && + aaa + added line 1 + bbb + added line 2 + ccc + EOF + printf "%s\n" s n y q | + test_might_fail git stash -p 2>error && + ! test_must_be_empty error && + grep "added line 1" test && + ! grep "added line 2" test +' + test_done diff --git a/t/t4011-diff-symlink.sh b/t/t4011-diff-symlink.sh index 13e7f621ab..7452fce0da 100755 --- a/t/t4011-diff-symlink.sh +++ b/t/t4011-diff-symlink.sh @@ -139,11 +139,13 @@ test_expect_success SYMLINKS 'setup symlinks with attributes' ' test_expect_success SYMLINKS 'symlinks do not respect userdiff config by path' ' cat >expect <<-\EOF && diff --git a/file.bin b/file.bin - index e69de29..d95f3ad 100644 - Binary files a/file.bin and b/file.bin differ + new file mode 100644 + index 0000000..d95f3ad + Binary files /dev/null and b/file.bin differ diff --git a/link.bin b/link.bin - index e69de29..dce41ec 120000 - --- a/link.bin + new file mode 120000 + index 0000000..dce41ec + --- /dev/null +++ b/link.bin @@ -0,0 +1 @@ +file.bin diff --git a/t/t4013/diff.log_--decorate_--all b/t/t4013/diff.log_--decorate_--all index 27d3eabc26..3aa16a9e42 100644 --- a/t/t4013/diff.log_--decorate_--all +++ b/t/t4013/diff.log_--decorate_--all @@ -5,7 +5,7 @@ Date: Mon Jun 26 00:06:00 2006 +0000 Rearranged lines in dir/sub -commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (HEAD, master) +commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (HEAD -> master) Merge: 9a6d494 c7a2ab9 Author: A U Thor <author@example.com> Date: Mon Jun 26 00:04:00 2006 +0000 diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 256affce89..c39e50028f 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -802,7 +802,7 @@ test_expect_success '--no-signature suppresses format.signaturefile ' ' ' test_expect_success '--signature-file overrides format.signaturefile' ' - cat >other-mail-signature <<-\EOF + cat >other-mail-signature <<-\EOF && Use this other signature instead of mail-signature. EOF test_config format.signaturefile mail-signature && diff --git a/t/t4022-diff-rewrite.sh b/t/t4022-diff-rewrite.sh index 2d030a4ec3..cb51d9f9d4 100755 --- a/t/t4022-diff-rewrite.sh +++ b/t/t4022-diff-rewrite.sh @@ -20,10 +20,7 @@ test_expect_success setup ' test_expect_success 'detect rewrite' ' actual=$(git diff-files -B --summary test) && - expr "$actual" : " rewrite test ([0-9]*%)$" || { - echo "Eh? <<$actual>>" - false - } + verbose expr "$actual" : " rewrite test ([0-9]*%)$" ' diff --git a/t/t4024-diff-optimize-common.sh b/t/t4024-diff-optimize-common.sh index c4d733f5db..7e76018296 100755 --- a/t/t4024-diff-optimize-common.sh +++ b/t/t4024-diff-optimize-common.sh @@ -139,7 +139,7 @@ test_expect_success setup ' ( printf C; zs $n ) >file-c$n && ( echo D; zs $n ) >file-d$n && - expect_pattern $n || break + expect_pattern $n || return 1 done >expect ' diff --git a/t/t4026-color.sh b/t/t4026-color.sh index 4d20feacfe..2b32c4fbe6 100755 --- a/t/t4026-color.sh +++ b/t/t4026-color.sh @@ -111,9 +111,9 @@ test_expect_success 'unknown color slots are ignored (branch)' ' ' test_expect_success 'unknown color slots are ignored (status)' ' - git config color.status.nosuchslotwilleverbedefined white || exit - git status - case $? in 0|1) : ok ;; *) false ;; esac + git config color.status.nosuchslotwilleverbedefined white && + { git status; ret=$?; } && + case $ret in 0|1) : ok ;; *) false ;; esac ' test_done diff --git a/t/t4035-diff-quiet.sh b/t/t4035-diff-quiet.sh index e8ae2a03fd..461f4bb583 100755 --- a/t/t4035-diff-quiet.sh +++ b/t/t4035-diff-quiet.sh @@ -29,67 +29,65 @@ test_expect_success 'setup' ' ' test_expect_success 'git diff-tree HEAD^ HEAD' ' - git diff-tree --quiet HEAD^ HEAD >cnt - test $? = 1 && test_line_count = 0 cnt + test_expect_code 1 git diff-tree --quiet HEAD^ HEAD >cnt && + test_line_count = 0 cnt ' test_expect_success 'git diff-tree HEAD^ HEAD -- a' ' - git diff-tree --quiet HEAD^ HEAD -- a >cnt - test $? = 0 && test_line_count = 0 cnt + test_expect_code 0 git diff-tree --quiet HEAD^ HEAD -- a >cnt && + test_line_count = 0 cnt ' test_expect_success 'git diff-tree HEAD^ HEAD -- b' ' - git diff-tree --quiet HEAD^ HEAD -- b >cnt - test $? = 1 && test_line_count = 0 cnt + test_expect_code 1 git diff-tree --quiet HEAD^ HEAD -- b >cnt && + test_line_count = 0 cnt ' # this diff outputs one line: sha1 of the given head test_expect_success 'echo HEAD | git diff-tree --stdin' ' - echo $(git rev-parse HEAD) | git diff-tree --quiet --stdin >cnt - test $? = 1 && test_line_count = 1 cnt + echo $(git rev-parse HEAD) | + test_expect_code 1 git diff-tree --quiet --stdin >cnt && + test_line_count = 1 cnt ' test_expect_success 'git diff-tree HEAD HEAD' ' - git diff-tree --quiet HEAD HEAD >cnt - test $? = 0 && test_line_count = 0 cnt + test_expect_code 0 git diff-tree --quiet HEAD HEAD >cnt && + test_line_count = 0 cnt ' test_expect_success 'git diff-files' ' - git diff-files --quiet >cnt - test $? = 0 && test_line_count = 0 cnt + test_expect_code 0 git diff-files --quiet >cnt && + test_line_count = 0 cnt ' test_expect_success 'git diff-index --cached HEAD' ' - git diff-index --quiet --cached HEAD >cnt - test $? = 0 && test_line_count = 0 cnt + test_expect_code 0 git diff-index --quiet --cached HEAD >cnt && + test_line_count = 0 cnt ' test_expect_success 'git diff-index --cached HEAD^' ' - git diff-index --quiet --cached HEAD^ >cnt - test $? = 1 && test_line_count = 0 cnt + test_expect_code 1 git diff-index --quiet --cached HEAD^ >cnt && + test_line_count = 0 cnt ' test_expect_success 'git diff-index --cached HEAD^' ' echo text >>b && echo 3 >c && - git add . && { - git diff-index --quiet --cached HEAD^ >cnt - test $? = 1 && test_line_count = 0 cnt - } + git add . && + test_expect_code 1 git diff-index --quiet --cached HEAD^ >cnt && + test_line_count = 0 cnt ' test_expect_success 'git diff-tree -Stext HEAD^ HEAD -- b' ' - git commit -m "text in b" && { - git diff-tree --quiet -Stext HEAD^ HEAD -- b >cnt - test $? = 1 && test_line_count = 0 cnt - } + git commit -m "text in b" && + test_expect_code 1 git diff-tree --quiet -Stext HEAD^ HEAD -- b >cnt && + test_line_count = 0 cnt ' test_expect_success 'git diff-tree -Snot-found HEAD^ HEAD -- b' ' - git diff-tree --quiet -Snot-found HEAD^ HEAD -- b >cnt - test $? = 0 && test_line_count = 0 cnt + test_expect_code 0 git diff-tree --quiet -Snot-found HEAD^ HEAD -- b >cnt && + test_line_count = 0 cnt ' test_expect_success 'git diff-files' ' - echo 3 >>c && { - git diff-files --quiet >cnt - test $? = 1 && test_line_count = 0 cnt - } + echo 3 >>c && + test_expect_code 1 git diff-files --quiet >cnt && + test_line_count = 0 cnt ' + test_expect_success 'git diff-index --cached HEAD' ' - git update-index c && { - git diff-index --quiet --cached HEAD >cnt - test $? = 1 && test_line_count = 0 cnt - } + git update-index c && + test_expect_code 1 git diff-index --quiet --cached HEAD >cnt && + test_line_count = 0 cnt ' test_expect_success 'git diff, one file outside repo' ' diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh index e4328964a7..2d9731b52d 100755 --- a/t/t4041-diff-submodule-option.sh +++ b/t/t4041-diff-submodule-option.sh @@ -528,10 +528,12 @@ test_expect_success 'diff --submodule with objects referenced by alternates' ' sha1_before=$(git rev-parse --short HEAD) echo b >b && git add b && - git commit -m b - sha1_after=$(git rev-parse --short HEAD) - echo "Submodule sub $sha1_before..$sha1_after: - > b" >../expected + git commit -m b && + sha1_after=$(git rev-parse --short HEAD) && + { + echo "Submodule sub $sha1_before..$sha1_after:" && + echo " > b" + } >../expected ) && (cd super && (cd sub && @@ -539,7 +541,7 @@ test_expect_success 'diff --submodule with objects referenced by alternates' ' git checkout origin/master ) && git diff --submodule > ../actual - ) + ) && test_cmp expected actual ' diff --git a/t/t4046-diff-unmerged.sh b/t/t4046-diff-unmerged.sh index 25d50a654a..d0f14475ca 100755 --- a/t/t4046-diff-unmerged.sh +++ b/t/t4046-diff-unmerged.sh @@ -8,7 +8,7 @@ test_expect_success setup ' do blob=$(echo $i | git hash-object --stdin) && eval "blob$i=$blob" && - eval "m$i=\"100644 \$blob$i $i\"" || break + eval "m$i=\"100644 \$blob$i $i\"" || return 1 done && paths= && for b in o x @@ -24,9 +24,9 @@ test_expect_success setup ' case "$b" in x) echo "$m1$p" ;; esac && case "$o" in x) echo "$m2$p" ;; esac && case "$t" in x) echo "$m3$p" ;; esac || - break - done || break - done || break + return 1 + done + done done >ls-files-s.expect && git update-index --index-info <ls-files-s.expect && git ls-files -s >ls-files-s.actual && diff --git a/t/t4047-diff-dirstat.sh b/t/t4047-diff-dirstat.sh index 0d50dce97e..3b8b7921d6 100755 --- a/t/t4047-diff-dirstat.sh +++ b/t/t4047-diff-dirstat.sh @@ -374,7 +374,7 @@ test_expect_success 'later options override earlier options:' ' git diff --dirstat=files,10,cumulative,changes,noncumulative,3 -M HEAD^..HEAD >actual_diff_dirstat_M && test_cmp expect_diff_dirstat_M actual_diff_dirstat_M && git diff --dirstat=files,10,cumulative,changes,noncumulative,3 -C -C HEAD^..HEAD >actual_diff_dirstat_CC && - test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC + test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC && git diff --dirstat=files --dirstat=10 --dirstat=cumulative --dirstat=changes --dirstat=noncumulative -X3 HEAD^..HEAD >actual_diff_dirstat && test_cmp expect_diff_dirstat actual_diff_dirstat && git diff --dirstat=files --dirstat=10 --dirstat=cumulative --dirstat=changes --dirstat=noncumulative -X3 -M HEAD^..HEAD >actual_diff_dirstat_M && diff --git a/t/t4049-diff-stat-count.sh b/t/t4049-diff-stat-count.sh index 5b594e878f..a34121740a 100755 --- a/t/t4049-diff-stat-count.sh +++ b/t/t4049-diff-stat-count.sh @@ -18,7 +18,7 @@ test_expect_success 'mode-only change show as a 0-line change' ' test_chmod +x b d && echo a >a && echo c >c && - cat >expect <<-\EOF + cat >expect <<-\EOF && a | 1 + b | 0 ... @@ -33,7 +33,7 @@ test_expect_success 'binary changes do not count in lines' ' echo a >a && echo c >c && cat "$TEST_DIRECTORY"/test-binary-1.png >d && - cat >expect <<-\EOF + cat >expect <<-\EOF && a | 1 + c | 1 + ... @@ -55,7 +55,7 @@ test_expect_success 'exclude unmerged entries from total file count' ' done | git update-index --index-info && echo d >d && - cat >expect <<-\EOF + cat >expect <<-\EOF && a | 1 + b | 1 + ... diff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh index b68afefa3c..9f563db20a 100755 --- a/t/t4052-stat-output.sh +++ b/t/t4052-stat-output.sh @@ -94,15 +94,15 @@ EOF while read verb expect cmd args do test_expect_success "$cmd $verb COLUMNS (big change)" ' - COLUMNS=200 git $cmd $args >output + COLUMNS=200 git $cmd $args >output && grep " | " output >actual && test_cmp "$expect" actual ' - test "$cmd" != diff || continue + case "$cmd" in diff|show) continue;; esac test_expect_success "$cmd --graph $verb COLUMNS (big change)" ' - COLUMNS=200 git $cmd $args --graph >output + COLUMNS=200 git $cmd $args --graph >output && grep " | " output >actual && test_cmp "$expect-graph" actual ' @@ -122,15 +122,15 @@ EOF while read verb expect cmd args do test_expect_success "$cmd $verb not enough COLUMNS (big change)" ' - COLUMNS=40 git $cmd $args >output + COLUMNS=40 git $cmd $args >output && grep " | " output >actual && test_cmp "$expect" actual ' - test "$cmd" != diff || continue + case "$cmd" in diff|show) continue;; esac test_expect_success "$cmd --graph $verb not enough COLUMNS (big change)" ' - COLUMNS=40 git $cmd $args --graph >output + COLUMNS=40 git $cmd $args --graph >output && grep " | " output >actual && test_cmp "$expect-graph" actual ' @@ -150,15 +150,15 @@ EOF while read verb expect cmd args do test_expect_success "$cmd $verb statGraphWidth config" ' - git -c diff.statGraphWidth=26 $cmd $args >output + git -c diff.statGraphWidth=26 $cmd $args >output && grep " | " output >actual && test_cmp "$expect" actual ' - test "$cmd" != diff || continue + case "$cmd" in diff|show) continue;; esac test_expect_success "$cmd --graph $verb statGraphWidth config" ' - git -c diff.statGraphWidth=26 $cmd $args --graph >output + git -c diff.statGraphWidth=26 $cmd $args --graph >output && grep " | " output >actual && test_cmp "$expect-graph" actual ' @@ -179,33 +179,33 @@ EOF while read cmd args do test_expect_success "$cmd --stat=width with big change" ' - git $cmd $args --stat=40 >output + git $cmd $args --stat=40 >output && grep " | " output >actual && test_cmp expect actual ' test_expect_success "$cmd --stat-width=width with big change" ' - git $cmd $args --stat-width=40 >output + git $cmd $args --stat-width=40 >output && grep " | " output >actual && test_cmp expect actual ' test_expect_success "$cmd --stat-graph-width with big change" ' - git $cmd $args --stat-graph-width=26 >output + git $cmd $args --stat-graph-width=26 >output && grep " | " output >actual && test_cmp expect actual ' - test "$cmd" != diff || continue + case "$cmd" in diff|show) continue;; esac test_expect_success "$cmd --stat-width=width --graph with big change" ' - git $cmd $args --stat-width=40 --graph >output + git $cmd $args --stat-width=40 --graph >output && grep " | " output >actual && test_cmp expect-graph actual ' test_expect_success "$cmd --stat-graph-width --graph with big change" ' - git $cmd $args --stat-graph-width=26 --graph >output + git $cmd $args --stat-graph-width=26 --graph >output && grep " | " output >actual && test_cmp expect-graph actual ' @@ -236,7 +236,7 @@ do test_cmp expect actual ' - test "$cmd" != diff || continue + case "$cmd" in diff|show) continue;; esac test_expect_success "$cmd --stat=width --graph with big change is balanced" ' git $cmd $args --stat-width=60 --graph >output && @@ -265,15 +265,15 @@ EOF while read verb expect cmd args do test_expect_success "$cmd $verb COLUMNS (long filename)" ' - COLUMNS=200 git $cmd $args >output + COLUMNS=200 git $cmd $args >output && grep " | " output >actual && test_cmp "$expect" actual ' - test "$cmd" != diff || continue + case "$cmd" in diff|show) continue;; esac test_expect_success "$cmd --graph $verb COLUMNS (long filename)" ' - COLUMNS=200 git $cmd $args --graph >output + COLUMNS=200 git $cmd $args --graph >output && grep " | " output >actual && test_cmp "$expect-graph" actual ' @@ -294,16 +294,16 @@ while read verb expect cmd args do test_expect_success COLUMNS_CAN_BE_1 \ "$cmd $verb prefix greater than COLUMNS (big change)" ' - COLUMNS=1 git $cmd $args >output + COLUMNS=1 git $cmd $args >output && grep " | " output >actual && test_cmp "$expect" actual ' - test "$cmd" != diff || continue + case "$cmd" in diff|show) continue;; esac test_expect_success COLUMNS_CAN_BE_1 \ "$cmd --graph $verb prefix greater than COLUMNS (big change)" ' - COLUMNS=1 git $cmd $args --graph >output + COLUMNS=1 git $cmd $args --graph >output && grep " | " output >actual && test_cmp "$expect-graph" actual ' @@ -320,7 +320,7 @@ EOF test_expect_success 'merge --stat respects COLUMNS (big change)' ' git checkout -b branch HEAD^^ && COLUMNS=100 git merge --stat --no-ff master^ >output && - grep " | " output >actual + grep " | " output >actual && test_cmp expect actual ' @@ -329,7 +329,7 @@ cat >expect <<'EOF' EOF test_expect_success 'merge --stat respects COLUMNS (long filename)' ' COLUMNS=100 git merge --stat --no-ff master >output && - grep " | " output >actual + grep " | " output >actual && test_cmp expect actual ' diff --git a/t/t4053-diff-no-index.sh b/t/t4053-diff-no-index.sh index 2ab3c48734..6eb83211b5 100755 --- a/t/t4053-diff-no-index.sh +++ b/t/t4053-diff-no-index.sh @@ -17,8 +17,8 @@ test_expect_success 'setup' ' ' test_expect_success 'git diff --no-index directories' ' - git diff --no-index a b >cnt - test $? = 1 && test_line_count = 14 cnt + test_expect_code 1 git diff --no-index a b >cnt && + test_line_count = 14 cnt ' test_expect_success 'git diff --no-index relative path outside repo' ' @@ -55,4 +55,38 @@ test_expect_success 'git diff --no-index executed outside repo gives correct err ) ' +test_expect_success 'diff D F and diff F D' ' + ( + cd repo && + echo in-repo >a && + echo non-repo >../non/git/a && + mkdir sub && + echo sub-repo >sub/a && + + test_must_fail git diff --no-index sub/a ../non/git/a >expect && + test_must_fail git diff --no-index sub/a ../non/git/ >actual && + test_cmp expect actual && + + test_must_fail git diff --no-index a ../non/git/a >expect && + test_must_fail git diff --no-index a ../non/git/ >actual && + test_cmp expect actual && + + test_must_fail git diff --no-index ../non/git/a a >expect && + test_must_fail git diff --no-index ../non/git a >actual && + test_cmp expect actual + ) +' + +test_expect_success 'turning a file into a directory' ' + ( + cd non/git && + mkdir d e e/sub && + echo 1 >d/sub && + echo 2 >e/sub/file && + printf "D\td/sub\nA\te/sub/file\n" >expect && + test_must_fail git diff --no-index --name-status d e >actual && + test_cmp expect actual + ) +' + test_done diff --git a/t/t4054-diff-bogus-tree.sh b/t/t4054-diff-bogus-tree.sh index 0843c87890..1d6efab3c5 100755 --- a/t/t4054-diff-bogus-tree.sh +++ b/t/t4054-diff-bogus-tree.sh @@ -16,7 +16,7 @@ test_expect_success 'create bogus tree' ' test_expect_success 'create tree with matching file' ' echo bar >foo && git add foo && - good_tree=$(git write-tree) + good_tree=$(git write-tree) && blob=$(git rev-parse :foo) ' diff --git a/t/t4104-apply-boundary.sh b/t/t4104-apply-boundary.sh index c617c2a33d..32e3b0ee0b 100755 --- a/t/t4104-apply-boundary.sh +++ b/t/t4104-apply-boundary.sh @@ -18,7 +18,7 @@ test_expect_success setup ' cat victim >original && git update-index --add victim && - : add to the head + # add to the head for i in a b '"$L"' y do echo $i @@ -27,7 +27,7 @@ test_expect_success setup ' git diff victim >add-a-patch.with && git diff --unified=0 >add-a-patch.without && - : insert at line two + # insert at line two for i in b a '"$L"' y do echo $i @@ -36,7 +36,7 @@ test_expect_success setup ' git diff victim >insert-a-patch.with && git diff --unified=0 >insert-a-patch.without && - : modify at the head + # modify at the head for i in a '"$L"' y do echo $i @@ -45,16 +45,16 @@ test_expect_success setup ' git diff victim >mod-a-patch.with && git diff --unified=0 >mod-a-patch.without && - : remove from the head + # remove from the head for i in '"$L"' y do echo $i done >victim && cat victim >del-a-expect && - git diff victim >del-a-patch.with + git diff victim >del-a-patch.with && git diff --unified=0 >del-a-patch.without && - : add to the tail + # add to the tail for i in b '"$L"' y z do echo $i @@ -63,7 +63,7 @@ test_expect_success setup ' git diff victim >add-z-patch.with && git diff --unified=0 >add-z-patch.without && - : modify at the tail + # modify at the tail for i in b '"$L"' z do echo $i @@ -72,16 +72,16 @@ test_expect_success setup ' git diff victim >mod-z-patch.with && git diff --unified=0 >mod-z-patch.without && - : remove from the tail + # remove from the tail for i in b '"$L"' do echo $i done >victim && cat victim >del-z-expect && - git diff victim >del-z-patch.with - git diff --unified=0 >del-z-patch.without && + git diff victim >del-z-patch.with && + git diff --unified=0 >del-z-patch.without - : done + # done ' for with in with without @@ -95,10 +95,7 @@ do test_expect_success "apply $kind-patch $with context" ' cat original >victim && git update-index victim && - git apply --index '"$u$kind-patch.$with"' || { - cat '"$kind-patch.$with"' - (exit 1) - } && + git apply --index '"$u$kind-patch.$with"' && test_cmp '"$kind"'-expect victim ' done @@ -113,10 +110,7 @@ do test_expect_success "apply non-git $kind-patch without context" ' cat original >victim && git update-index victim && - git apply --unidiff-zero --index '"$kind-ng.without"' || { - cat '"$kind-ng.without"' - (exit 1) - } && + git apply --unidiff-zero --index '"$kind-ng.without"' && test_cmp '"$kind"'-expect victim ' done diff --git a/t/t4117-apply-reject.sh b/t/t4117-apply-reject.sh index 8e15ecbdfd..d80187de94 100755 --- a/t/t4117-apply-reject.sh +++ b/t/t4117-apply-reject.sh @@ -56,23 +56,13 @@ test_expect_success 'apply --reject is incompatible with --3way' ' test_expect_success 'apply without --reject should fail' ' - if git apply patch.1 - then - echo "Eh? Why?" - exit 1 - fi - + test_must_fail git apply patch.1 && test_cmp file1 saved.file1 ' test_expect_success 'apply without --reject should fail' ' - if git apply --verbose patch.1 - then - echo "Eh? Why?" - exit 1 - fi - + test_must_fail git apply --verbose patch.1 && test_cmp file1 saved.file1 ' @@ -81,21 +71,11 @@ test_expect_success 'apply with --reject should fail but update the file' ' cat saved.file1 >file1 && rm -f file1.rej file2.rej && - if git apply --reject patch.1 - then - echo "succeeds with --reject?" - exit 1 - fi - + test_must_fail git apply --reject patch.1 && test_cmp file1 expected && cat file1.rej && - - if test -f file2.rej - then - echo "file2 should not have been touched" - exit 1 - fi + test_path_is_missing file2.rej ' test_expect_success 'apply with --reject should fail but update the file' ' @@ -103,25 +83,12 @@ test_expect_success 'apply with --reject should fail but update the file' ' cat saved.file1 >file1 && rm -f file1.rej file2.rej file2 && - if git apply --reject patch.2 >rejects - then - echo "succeeds with --reject?" - exit 1 - fi - - test -f file1 && { - echo "file1 still exists?" - exit 1 - } + test_must_fail git apply --reject patch.2 >rejects && + test_path_is_missing file1 && test_cmp file2 expected && cat file2.rej && - - if test -f file1.rej - then - echo "file2 should not have been touched" - exit 1 - fi + test_path_is_missing file1.rej ' @@ -130,25 +97,12 @@ test_expect_success 'the same test with --verbose' ' cat saved.file1 >file1 && rm -f file1.rej file2.rej file2 && - if git apply --reject --verbose patch.2 >rejects - then - echo "succeeds with --reject?" - exit 1 - fi - - test -f file1 && { - echo "file1 still exists?" - exit 1 - } + test_must_fail git apply --reject --verbose patch.2 >rejects && + test_path_is_missing file1 && test_cmp file2 expected && cat file2.rej && - - if test -f file1.rej - then - echo "file2 should not have been touched" - exit 1 - fi + test_path_is_missing file1.rej ' diff --git a/t/t4122-apply-symlink-inside.sh b/t/t4122-apply-symlink-inside.sh index 1779c0a568..4acb3f336e 100755 --- a/t/t4122-apply-symlink-inside.sh +++ b/t/t4122-apply-symlink-inside.sh @@ -3,17 +3,10 @@ test_description='apply to deeper directory without getting fooled with symlink' . ./test-lib.sh -lecho () { - for l_ - do - echo "$l_" - done -} - test_expect_success setup ' mkdir -p arch/i386/boot arch/x86_64 && - lecho 1 2 3 4 5 >arch/i386/boot/Makefile && + test_write_lines 1 2 3 4 5 >arch/i386/boot/Makefile && test_ln_s_add ../i386/boot arch/x86_64/boot && git add . && test_tick && @@ -22,7 +15,7 @@ test_expect_success setup ' rm arch/x86_64/boot && mkdir arch/x86_64/boot && - lecho 2 3 4 5 6 >arch/x86_64/boot/Makefile && + test_write_lines 2 3 4 5 6 >arch/x86_64/boot/Makefile && git add . && test_tick && git commit -a -m second && diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh index c6474de4c8..d350065f25 100755 --- a/t/t4124-apply-ws-rule.sh +++ b/t/t4124-apply-ws-rule.sh @@ -99,9 +99,8 @@ test_expect_success 'whitespace=warn, default rule' ' test_expect_success 'whitespace=error-all, default rule' ' - apply_patch --whitespace=error-all && return 1 - test -s target && return 1 - : happy + test_must_fail apply_patch --whitespace=error-all && + ! test -s target ' diff --git a/t/t4151-am-abort.sh b/t/t4151-am-abort.sh index 1176bcccf3..8d90634ab8 100755 --- a/t/t4151-am-abort.sh +++ b/t/t4151-am-abort.sh @@ -20,7 +20,7 @@ test_expect_success setup ' echo $i >otherfile-$i && git add otherfile-$i && test_tick && - git commit -a -m $i || break + git commit -a -m $i || return 1 done && git format-patch --no-numbered initial && git checkout -b side initial && diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 99ab7ca21f..1b2e981a00 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -113,11 +113,7 @@ test_expect_success 'diff-filter=M' ' actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) && expect=$(echo second) && - test "$actual" = "$expect" || { - echo Oops - echo "Actual: $actual" - false - } + verbose test "$actual" = "$expect" ' @@ -125,11 +121,7 @@ test_expect_success 'diff-filter=D' ' actual=$(git log --pretty="format:%s" --diff-filter=D HEAD) && expect=$(echo sixth ; echo third) && - test "$actual" = "$expect" || { - echo Oops - echo "Actual: $actual" - false - } + verbose test "$actual" = "$expect" ' @@ -137,11 +129,7 @@ test_expect_success 'diff-filter=R' ' actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) && expect=$(echo third) && - test "$actual" = "$expect" || { - echo Oops - echo "Actual: $actual" - false - } + verbose test "$actual" = "$expect" ' @@ -149,11 +137,7 @@ test_expect_success 'diff-filter=C' ' actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) && expect=$(echo fourth) && - test "$actual" = "$expect" || { - echo Oops - echo "Actual: $actual" - false - } + verbose test "$actual" = "$expect" ' @@ -161,11 +145,7 @@ test_expect_success 'git log --follow' ' actual=$(git log --follow --pretty="format:%s" ichi) && expect=$(echo third ; echo second ; echo initial) && - test "$actual" = "$expect" || { - echo Oops - echo "Actual: $actual" - false - } + verbose test "$actual" = "$expect" ' @@ -212,6 +192,21 @@ test_expect_success 'log --grep' ' test_cmp expect actual ' +cat > expect << EOF +second +initial +EOF +test_expect_success 'log --invert-grep --grep' ' + git log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual && + test_cmp expect actual +' + +test_expect_success 'log --invert-grep --grep -i' ' + echo initial >expect && + git log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual && + test_cmp expect actual +' + test_expect_success 'log --grep option parsing' ' echo second >expect && git log -1 --pretty="tformat:%s" --grep sec >actual && @@ -466,7 +461,7 @@ test_expect_success 'log.decorate configuration' ' git log --oneline --no-decorate >actual && test_cmp expect.none actual && git log --oneline --decorate >actual && - test_cmp expect.short actual + test_cmp expect.short actual && test_unconfig log.decorate && git log --pretty=raw >expect.raw && @@ -872,4 +867,8 @@ test_expect_success GPG 'log --graph --show-signature for merged tag' ' grep "^| | gpg: Good signature" actual ' +test_expect_success 'log --graph --no-walk is forbidden' ' + test_must_fail git log --graph --no-walk +' + test_done diff --git a/t/t4207-log-decoration-colors.sh b/t/t4207-log-decoration-colors.sh index 6b8ad4f5b0..f8008b6a3d 100755 --- a/t/t4207-log-decoration-colors.sh +++ b/t/t4207-log-decoration-colors.sh @@ -44,10 +44,10 @@ test_expect_success setup ' ' cat >expected <<EOF -${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD${c_reset}${c_commit},\ +${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD${c_reset}${c_commit} ->\ + ${c_reset}${c_branch}master${c_reset}${c_commit},\ ${c_reset}${c_tag}tag: v1.0${c_reset}${c_commit},\ - ${c_reset}${c_tag}tag: B${c_reset}${c_commit},\ - ${c_reset}${c_branch}master${c_reset}${c_commit})${c_reset} B + ${c_reset}${c_tag}tag: B${c_reset}${c_commit})${c_reset} B ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: A1${c_reset}${c_commit},\ ${c_reset}${c_remoteBranch}other/master${c_reset}${c_commit})${c_reset} A1 ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_stash}refs/stash${c_reset}${c_commit})${c_reset}\ diff --git a/t/t4211-line-log.sh b/t/t4211-line-log.sh index 0901b30982..4451127eb2 100755 --- a/t/t4211-line-log.sh +++ b/t/t4211-line-log.sh @@ -54,14 +54,14 @@ canned_test "-L 4:a.c -L 8,12:a.c simple" multiple-superset canned_test "-L 8,12:a.c -L 4:a.c simple" multiple-superset test_bad_opts "-L" "switch.*requires a value" -test_bad_opts "-L b.c" "argument.*not of the form" -test_bad_opts "-L 1:" "argument.*not of the form" +test_bad_opts "-L b.c" "argument not .start,end:file" +test_bad_opts "-L 1:" "argument not .start,end:file" test_bad_opts "-L 1:nonexistent" "There is no path" test_bad_opts "-L 1:simple" "There is no path" -test_bad_opts "-L '/foo:b.c'" "argument.*not of the form" +test_bad_opts "-L '/foo:b.c'" "argument not .start,end:file" test_bad_opts "-L 1000:b.c" "has only.*lines" test_bad_opts "-L 1,1000:b.c" "has only.*lines" -test_bad_opts "-L :b.c" "argument.*not of the form" +test_bad_opts "-L :b.c" "argument not .start,end:file" test_bad_opts "-L :foo:b.c" "no match" test_expect_success '-L X (X == nlines)' ' diff --git a/t/t4212-log-corrupt.sh b/t/t4212-log-corrupt.sh index 67bd8ec020..22aa8b7c0e 100755 --- a/t/t4212-log-corrupt.sh +++ b/t/t4212-log-corrupt.sh @@ -61,7 +61,7 @@ test_expect_success 'unparsable dates produce sentinel value' ' test_expect_success 'unparsable dates produce sentinel value (%ad)' ' commit=$(munge_author_date HEAD totally_bogus) && echo >expect && - git log -1 --format=%ad $commit >actual + git log -1 --format=%ad $commit >actual && test_cmp expect actual ' diff --git a/t/t5003-archive-zip.sh b/t/t5003-archive-zip.sh index c929db5633..14744b2a4b 100755 --- a/t/t5003-archive-zip.sh +++ b/t/t5003-archive-zip.sh @@ -33,6 +33,37 @@ check_zip() { test_expect_success UNZIP " validate file contents" " diff -r a ${dir_with_prefix}a " + + dir=eol_$1 + dir_with_prefix=$dir/$2 + extracted=${dir_with_prefix}a + original=a + + test_expect_success UNZIP " extract ZIP archive with EOL conversion" ' + (mkdir $dir && cd $dir && "$GIT_UNZIP" -a ../$zipfile) + ' + + test_expect_success UNZIP " validate that text files are converted" " + test_cmp_bin $extracted/text.cr $extracted/text.crlf && + test_cmp_bin $extracted/text.cr $extracted/text.lf + " + + test_expect_success UNZIP " validate that binary files are unchanged" " + test_cmp_bin $original/binary.cr $extracted/binary.cr && + test_cmp_bin $original/binary.crlf $extracted/binary.crlf && + test_cmp_bin $original/binary.lf $extracted/binary.lf + " + + test_expect_success UNZIP " validate that diff files are converted" " + test_cmp_bin $extracted/diff.cr $extracted/diff.crlf && + test_cmp_bin $extracted/diff.cr $extracted/diff.lf + " + + test_expect_success UNZIP " validate that -diff files are unchanged" " + test_cmp_bin $original/nodiff.cr $extracted/nodiff.cr && + test_cmp_bin $original/nodiff.crlf $extracted/nodiff.crlf && + test_cmp_bin $original/nodiff.lf $extracted/nodiff.lf + " } test_expect_success \ @@ -41,6 +72,18 @@ test_expect_success \ echo simple textfile >a/a && mkdir a/bin && cp /bin/sh a/bin && + printf "text\r" >a/text.cr && + printf "text\r\n" >a/text.crlf && + printf "text\n" >a/text.lf && + printf "text\r" >a/nodiff.cr && + printf "text\r\n" >a/nodiff.crlf && + printf "text\n" >a/nodiff.lf && + printf "\0\r" >a/binary.cr && + printf "\0\r\n" >a/binary.crlf && + printf "\0\n" >a/binary.lf && + printf "\0\r" >a/diff.cr && + printf "\0\r\n" >a/diff.crlf && + printf "\0\n" >a/diff.lf && printf "A\$Format:%s\$O" "$SUBSTFORMAT" >a/substfile1 && printf "A not substituted O" >a/substfile2 && (p=long_path_to_a_file && cd a && @@ -66,7 +109,9 @@ test_expect_success 'add files to repository' ' GIT_COMMITTER_DATE="2005-05-27 22:00" git commit -m initial ' -test_expect_success 'setup export-subst' ' +test_expect_success 'setup export-subst and diff attributes' ' + echo "a/nodiff.* -diff" >>.git/info/attributes && + echo "a/diff.* diff" >>.git/info/attributes && echo "substfile?" export-subst >>.git/info/attributes && git log --max-count=1 "--pretty=format:A${SUBSTFORMAT}O" HEAD \ >a/substfile1 diff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh index 305bcac6b7..654addaae3 100755 --- a/t/t5004-archive-corner-cases.sh +++ b/t/t5004-archive-corner-cases.sh @@ -66,8 +66,10 @@ test_expect_success UNZIP 'zip archive of empty tree is empty' ' # handle the empty repo at all, making our later check of its exit code # a no-op). But we cannot do anything reasonable except skip the test # on such platforms anyway, and this is the moral equivalent. - "$GIT_UNZIP" "$TEST_DIRECTORY"/t5004/empty.zip - expect_code=$? + { + "$GIT_UNZIP" "$TEST_DIRECTORY"/t5004/empty.zip + expect_code=$? + } && git archive --format=zip HEAD >empty.zip && make_dir extract && diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh index 60df10f46a..e97cfb2ab8 100755 --- a/t/t5100-mailinfo.sh +++ b/t/t5100-mailinfo.sh @@ -34,7 +34,7 @@ do if test -f "$TEST_DIRECTORY"/t5100/msg$mail--no-inbody-headers then check_mailinfo $mail --no-inbody-headers - fi + fi && if test -f "$TEST_DIRECTORY"/t5100/msg$mail--message-id then check_mailinfo $mail --message-id diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index ed40407309..3a9b77576f 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -414,7 +414,7 @@ test_expect_success 'setup tests for the --stdin parameter' ' do git tag $head $head done && - cat >input <<-\EOF + cat >input <<-\EOF && refs/heads/C refs/heads/A refs/heads/D diff --git a/t/t5503-tagfollow.sh b/t/t5503-tagfollow.sh index f30c03885c..4ca48f0276 100755 --- a/t/t5503-tagfollow.sh +++ b/t/t5503-tagfollow.sh @@ -139,8 +139,8 @@ EOF ' test_expect_success 'new clone fetch master and tags' ' - git branch -D cat - rm -f $U + test_might_fail git branch -D cat && + rm -f $U && ( mkdir clone2 && cd clone2 && diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index 17c6330f98..7a8499ce66 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -579,7 +579,7 @@ test_expect_success 'update with arguments' ' cd one && for b in $(git branch -r) do - git branch -r -d $b || break + git branch -r -d $b || exit 1 done && git remote add manduca ../mirror && git remote add megaloprepus ../mirror && @@ -622,7 +622,7 @@ test_expect_success 'update default' ' cd one && for b in $(git branch -r) do - git branch -r -d $b || break + git branch -r -d $b || exit 1 done && git config remote.drosophila.skipDefaultUpdate true && git remote update default && @@ -642,7 +642,7 @@ test_expect_success 'update default (overridden, with funny whitespace)' ' cd one && for b in $(git branch -r) do - git branch -r -d $b || break + git branch -r -d $b || exit 1 done && git config remotes.default "$(printf "\t drosophila \n")" && git remote update default && @@ -656,7 +656,7 @@ test_expect_success 'update (with remotes.default defined)' ' cd one && for b in $(git branch -r) do - git branch -r -d $b || break + git branch -r -d $b || exit 1 done && git config remotes.default "drosophila" && git remote update && diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index d78f3201f4..0ba9db0884 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -124,7 +124,7 @@ test_expect_success 'fetch --prune handles overlapping refspecs' ' git rev-parse origin/master && git rev-parse origin/pr/42 && - git config --unset-all remote.origin.fetch + git config --unset-all remote.origin.fetch && git config remote.origin.fetch refs/pull/*/head:refs/remotes/origin/pr/* && git config --add remote.origin.fetch refs/heads/*:refs/remotes/origin/* && @@ -596,7 +596,7 @@ test_configured_prune () { test_unconfig remote.origin.prune && git fetch && git rev-parse --verify refs/remotes/origin/newbranch - ) + ) && # now remove it git branch -d newbranch && diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh index 321c3e5234..3bd9759e0f 100755 --- a/t/t5512-ls-remote.sh +++ b/t/t5512-ls-remote.sh @@ -103,8 +103,10 @@ test_expect_success 'confuses pattern as remote when no remote specified' ' ' test_expect_success 'die with non-2 for wrong repository even with --exit-code' ' - git ls-remote --exit-code ./no-such-repository ;# not && - status=$? && + { + git ls-remote --exit-code ./no-such-repository + status=$? + } && test $status != 2 && test $status != 0 ' diff --git a/t/t5514-fetch-multiple.sh b/t/t5514-fetch-multiple.sh index 0f8140957f..4b4b6673b8 100755 --- a/t/t5514-fetch-multiple.sh +++ b/t/t5514-fetch-multiple.sh @@ -120,7 +120,7 @@ test_expect_success 'git fetch --all (skipFetchAll)' ' (cd test4 && for b in $(git branch -r) do - git branch -r -d $b || break + git branch -r -d $b || exit 1 done && git remote add three ../three && git config remote.three.skipFetchAll true && @@ -144,7 +144,7 @@ test_expect_success 'git fetch --multiple (ignoring skipFetchAll)' ' (cd test4 && for b in $(git branch -r) do - git branch -r -d $b || break + git branch -r -d $b || exit 1 done && git fetch --multiple one two three && git branch -r > output && diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index 050877f181..8a5f2363a9 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -1437,8 +1437,124 @@ test_expect_success 'receive.denyCurrentBranch = updateInstead' ' test $(git -C .. rev-parse HEAD^^) = $(git rev-parse HEAD) && git diff --quiet && test fifth = "$(cat path3)" + ) && + + # (5) push into void + rm -fr void && + git init void && + ( + cd void && + git config receive.denyCurrentBranch updateInstead + ) && + git push void master && + ( + cd void && + test $(git -C .. rev-parse master) = $(git rev-parse HEAD) && + git diff --quiet && + git diff --cached --quiet ) +' + +test_expect_success 'updateInstead with push-to-checkout hook' ' + rm -fr testrepo && + git init testrepo && + ( + cd testrepo && + git pull .. master && + git reset --hard HEAD^^ && + git tag initial && + git config receive.denyCurrentBranch updateInstead && + write_script .git/hooks/push-to-checkout <<-\EOF + echo >&2 updating from $(git rev-parse HEAD) + echo >&2 updating to "$1" + git update-index -q --refresh && + git read-tree -u -m HEAD "$1" || { + status=$? + echo >&2 read-tree failed + exit $status + } + EOF + ) && + + # Try pushing into a pristine + git push testrepo master && + ( + cd testrepo && + git diff --quiet && + git diff HEAD --quiet && + test $(git -C .. rev-parse HEAD) = $(git rev-parse HEAD) + ) && + + # Try pushing into a repository with conflicting change + ( + cd testrepo && + git reset --hard initial && + echo conflicting >path2 + ) && + test_must_fail git push testrepo master && + ( + cd testrepo && + test $(git rev-parse initial) = $(git rev-parse HEAD) && + test conflicting = "$(cat path2)" && + git diff-index --quiet --cached HEAD + ) && + + # Try pushing into a repository with unrelated change + ( + cd testrepo && + git reset --hard initial && + echo unrelated >path1 && + echo irrelevant >path5 && + git add path5 + ) && + git push testrepo master && + ( + cd testrepo && + test "$(cat path1)" = unrelated && + test "$(cat path5)" = irrelevant && + test "$(git diff --name-only --cached HEAD)" = path5 && + test $(git -C .. rev-parse HEAD) = $(git rev-parse HEAD) + ) && + + # push into void + rm -fr void && + git init void && + ( + cd void && + git config receive.denyCurrentBranch updateInstead && + write_script .git/hooks/push-to-checkout <<-\EOF + if git rev-parse --quiet --verify HEAD + then + has_head=yes + echo >&2 updating from $(git rev-parse HEAD) + else + has_head=no + echo >&2 pushing into void + fi + echo >&2 updating to "$1" + + git update-index -q --refresh && + case "$has_head" in + yes) + git read-tree -u -m HEAD "$1" ;; + no) + git read-tree -u -m "$1" ;; + esac || { + status=$? + echo >&2 read-tree failed + exit $status + } + EOF + ) && + + git push void master && + ( + cd void && + git diff --quiet && + git diff --cached --quiet && + test $(git -C .. rev-parse HEAD) = $(git rev-parse HEAD) + ) ' test_done diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index 227d293350..7efd45bc27 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -9,36 +9,27 @@ modify () { mv "$2.x" "$2" } -D=`pwd` - test_expect_success setup ' - echo file >file && git add file && git commit -a -m original - ' test_expect_success 'pulling into void' ' - mkdir cloned && - cd cloned && - git init && - git pull .. -' - -cd "$D" - -test_expect_success 'checking the results' ' + git init cloned && + ( + cd cloned && + git pull .. + ) && test -f file && test -f cloned/file && test_cmp file cloned/file ' test_expect_success 'pulling into void using master:master' ' - mkdir cloned-uho && + git init cloned-uho && ( cd cloned-uho && - git init && git pull .. master:master ) && test -f file && @@ -71,7 +62,6 @@ test_expect_success 'pulling into void does not overwrite staged files' ' ) ' - test_expect_success 'pulling into void does not remove new staged files' ' git init cloned-staged-new && ( @@ -86,6 +76,15 @@ test_expect_success 'pulling into void does not remove new staged files' ' ) ' +test_expect_success 'pulling into void must not create an octopus' ' + git init cloned-octopus && + ( + cd cloned-octopus && + test_must_fail git pull .. master master && + ! test -f file + ) +' + test_expect_success 'test . as a remote' ' git branch copy master && diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh index ca5b027c55..a4532b00d6 100755 --- a/t/t5526-fetch-submodules.sh +++ b/t/t5526-fetch-submodules.sh @@ -216,7 +216,7 @@ test_expect_success "Recursion stops when no new submodule commits are fetched" head2=$(git rev-parse --short HEAD) && echo "Fetching submodule submodule" > expect.out.sub && echo "From $pwd/." > expect.err.sub && - echo " $head1..$head2 master -> origin/master" >> expect.err.sub + echo " $head1..$head2 master -> origin/master" >>expect.err.sub && head -2 expect.err >> expect.err.sub && ( cd downstream && @@ -315,7 +315,7 @@ test_expect_success "'--recurse-submodules=on-demand' doesn't recurse when no ne ) && head1=$(git rev-parse --short HEAD^) && git add subdir/deepsubmodule && - git commit -m "new deepsubmodule" + git commit -m "new deepsubmodule" && head2=$(git rev-parse --short HEAD) && echo "From $pwd/submodule" > ../expect.err.sub && echo " $head1..$head2 master -> origin/master" >> ../expect.err.sub @@ -337,7 +337,7 @@ test_expect_success "'--recurse-submodules=on-demand' recurses as deep as necess head2=$(git rev-parse --short HEAD) && tail -2 expect.err > expect.err.deepsub && echo "From $pwd/." > expect.err && - echo " $head1..$head2 master -> origin/master" >> expect.err + echo " $head1..$head2 master -> origin/master" >>expect.err && cat expect.err.sub >> expect.err && cat expect.err.deepsub >> expect.err && ( @@ -387,7 +387,7 @@ test_expect_success "'fetch.recurseSubmodules=on-demand' overrides global config git commit -m "new submodule" && head2=$(git rev-parse --short HEAD) && echo "From $pwd/." > expect.err.2 && - echo " $head1..$head2 master -> origin/master" >> expect.err.2 + echo " $head1..$head2 master -> origin/master" >>expect.err.2 && head -2 expect.err >> expect.err.2 && ( cd downstream && @@ -415,7 +415,7 @@ test_expect_success "'submodule.<sub>.fetchRecurseSubmodules=on-demand' override git commit -m "new submodule" && head2=$(git rev-parse --short HEAD) && echo "From $pwd/." > expect.err.2 && - echo " $head1..$head2 master -> origin/master" >> expect.err.2 + echo " $head1..$head2 master -> origin/master" >>expect.err.2 && head -2 expect.err >> expect.err.2 && ( cd downstream && diff --git a/t/t5528-push-default.sh b/t/t5528-push-default.sh index cc7451908b..73f4bb6346 100755 --- a/t/t5528-push-default.sh +++ b/t/t5528-push-default.sh @@ -26,7 +26,7 @@ check_pushed_commit () { # $2 = expected target branch for the push # $3 = [optional] repo to check for actual output (repo1 by default) test_push_success () { - git ${1:+-c push.default="$1"} push && + git ${1:+-c} ${1:+push.default="$1"} push && check_pushed_commit HEAD "$2" "$3" } @@ -34,7 +34,7 @@ test_push_success () { # check that push fails and does not modify any remote branch test_push_failure () { git --git-dir=repo1 log --no-walk --format='%h %s' --all >expect && - test_must_fail git ${1:+-c push.default="$1"} push && + test_must_fail git ${1:+-c} ${1:+push.default="$1"} push && git --git-dir=repo1 log --no-walk --format='%h %s' --all >actual && test_cmp expect actual } diff --git a/t/t5531-deep-submodule-push.sh b/t/t5531-deep-submodule-push.sh index 445bb5fe26..6507487c1a 100755 --- a/t/t5531-deep-submodule-push.sh +++ b/t/t5531-deep-submodule-push.sh @@ -104,7 +104,7 @@ test_expect_success 'push fails when commit on multiple branches if one branch h ' test_expect_success 'push succeeds if submodule has no remote and is on the first superproject commit' ' - git init --bare a + git init --bare a && git clone a a1 && ( cd a1 && diff --git a/t/t5533-push-cas.sh b/t/t5533-push-cas.sh index ba20d83333..c402d8d3d7 100755 --- a/t/t5533-push-cas.sh +++ b/t/t5533-push-cas.sh @@ -14,7 +14,7 @@ setup_srcdst_basic () { } test_expect_success setup ' - : create template repository + # create template repository test_commit A && test_commit B && test_commit C @@ -159,7 +159,7 @@ test_expect_success 'cover everything with default force-with-lease (protected)' ( cd src && git branch naster master^ - ) + ) && git ls-remote src refs/heads/\* >expect && ( cd dst && @@ -174,7 +174,7 @@ test_expect_success 'cover everything with default force-with-lease (allowed)' ' ( cd src && git branch naster master^ - ) + ) && ( cd dst && git fetch && diff --git a/t/t5539-fetch-http-shallow.sh b/t/t5539-fetch-http-shallow.sh index b46118846c..37a433504e 100755 --- a/t/t5539-fetch-http-shallow.sh +++ b/t/t5539-fetch-http-shallow.sh @@ -3,12 +3,6 @@ test_description='fetch/clone from a shallow clone over http' . ./test-lib.sh - -if test -n "$NO_CURL"; then - skip_all='skipping test, git built without http support' - test_done -fi - . "$TEST_DIRECTORY"/lib-httpd.sh start_httpd diff --git a/t/t5540-http-push-webdav.sh b/t/t5540-http-push-webdav.sh index 8d7b3c57e3..88ff5a49e4 100755 --- a/t/t5540-http-push-webdav.sh +++ b/t/t5540-http-push-webdav.sh @@ -169,7 +169,7 @@ test_expect_failure 'push to password-protected repository (no user in URL)' ' test_commit pw-nouser && set_askpass user@host pass@host && git push "$HTTPD_URL/auth/dumb/test_repo.git" HEAD && - expect_askpass both user@host + expect_askpass both user@host && git rev-parse --verify HEAD >expect && git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git" \ rev-parse --verify HEAD >actual && diff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh index 1ecb5881ac..fd7d06b9a2 100755 --- a/t/t5541-http-push-smart.sh +++ b/t/t5541-http-push-smart.sh @@ -6,11 +6,6 @@ test_description='test smart pushing over http via http-backend' . ./test-lib.sh -if test -n "$NO_CURL"; then - skip_all='skipping test, git built without http support' - test_done -fi - ROOT_PATH="$PWD" . "$TEST_DIRECTORY"/lib-gpg.sh . "$TEST_DIRECTORY"/lib-httpd.sh @@ -158,7 +153,7 @@ test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \ test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper' ' # create a dissimilarly-named remote ref so that git is unable to match the # two refs (viz. local, remote) unless an explicit refspec is provided. - git push origin master:retsam + git push origin master:retsam && echo "change changed" > path2 && git commit -a -m path2 --amend && diff --git a/t/t5542-push-http-shallow.sh b/t/t5542-push-http-shallow.sh index 2a691e09eb..5165833157 100755 --- a/t/t5542-push-http-shallow.sh +++ b/t/t5542-push-http-shallow.sh @@ -3,12 +3,6 @@ test_description='push from/to a shallow clone over http' . ./test-lib.sh - -if test -n "$NO_CURL"; then - say 'skipping test, git built without http support' - test_done -fi - . "$TEST_DIRECTORY"/lib-httpd.sh start_httpd diff --git a/t/t5543-atomic-push.sh b/t/t5543-atomic-push.sh new file mode 100755 index 0000000000..3480b33007 --- /dev/null +++ b/t/t5543-atomic-push.sh @@ -0,0 +1,194 @@ +#!/bin/sh + +test_description='pushing to a repository using the atomic push option' + +. ./test-lib.sh + +mk_repo_pair () { + rm -rf workbench upstream && + test_create_repo upstream && + test_create_repo workbench && + ( + cd upstream && + git config receive.denyCurrentBranch warn + ) && + ( + cd workbench && + git remote add up ../upstream + ) +} + +# Compare the ref ($1) in upstream with a ref value from workbench ($2) +# i.e. test_refs second HEAD@{2} +test_refs () { + test $# = 2 && + git -C upstream rev-parse --verify "$1" >expect && + git -C workbench rev-parse --verify "$2" >actual && + test_cmp expect actual +} + +test_expect_success 'atomic push works for a single branch' ' + mk_repo_pair && + ( + cd workbench && + test_commit one && + git push --mirror up && + test_commit two && + git push --atomic up master + ) && + test_refs master master +' + +test_expect_success 'atomic push works for two branches' ' + mk_repo_pair && + ( + cd workbench && + test_commit one && + git branch second && + git push --mirror up && + test_commit two && + git checkout second && + test_commit three && + git push --atomic up master second + ) && + test_refs master master && + test_refs second second +' + +test_expect_success 'atomic push works in combination with --mirror' ' + mk_repo_pair && + ( + cd workbench && + test_commit one && + git checkout -b second && + test_commit two && + git push --atomic --mirror up + ) && + test_refs master master && + test_refs second second +' + +test_expect_success 'atomic push works in combination with --force' ' + mk_repo_pair && + ( + cd workbench && + test_commit one && + git branch second master && + test_commit two_a && + git checkout second && + test_commit two_b && + test_commit three_b && + test_commit four && + git push --mirror up && + # The actual test is below + git checkout master && + test_commit three_a && + git checkout second && + git reset --hard HEAD^ && + git push --force --atomic up master second + ) && + test_refs master master && + test_refs second second +' + +# set up two branches where master can be pushed but second can not +# (non-fast-forward). Since second can not be pushed the whole operation +# will fail and leave master untouched. +test_expect_success 'atomic push fails if one branch fails' ' + mk_repo_pair && + ( + cd workbench && + test_commit one && + git checkout -b second master && + test_commit two && + test_commit three && + test_commit four && + git push --mirror up && + git reset --hard HEAD~2 && + test_commit five && + git checkout master && + test_commit six && + test_must_fail git push --atomic --all up + ) && + test_refs master HEAD@{7} && + test_refs second HEAD@{4} +' + +test_expect_success 'atomic push fails if one tag fails remotely' ' + # prepare the repo + mk_repo_pair && + ( + cd workbench && + test_commit one && + git checkout -b second master && + test_commit two && + git push --mirror up + ) && + # a third party modifies the server side: + ( + cd upstream && + git checkout second && + git tag test_tag second + ) && + # see if we can now push both branches. + ( + cd workbench && + git checkout master && + test_commit three && + git checkout second && + test_commit four && + git tag test_tag && + test_must_fail git push --tags --atomic up master second + ) && + test_refs master HEAD@{3} && + test_refs second HEAD@{1} +' + +test_expect_success 'atomic push obeys update hook preventing a branch to be pushed' ' + mk_repo_pair && + ( + cd workbench && + test_commit one && + git checkout -b second master && + test_commit two && + git push --mirror up + ) && + ( + cd upstream && + HOOKDIR="$(git rev-parse --git-dir)/hooks" && + HOOK="$HOOKDIR/update" && + mkdir -p "$HOOKDIR" && + write_script "$HOOK" <<-\EOF + # only allow update to master from now on + test "$1" = "refs/heads/master" + EOF + ) && + ( + cd workbench && + git checkout master && + test_commit three && + git checkout second && + test_commit four && + test_must_fail git push --atomic up master second + ) && + test_refs master HEAD@{3} && + test_refs second HEAD@{1} +' + +test_expect_success 'atomic push is not advertised if configured' ' + mk_repo_pair && + ( + cd upstream + git config receive.advertiseatomic 0 + ) && + ( + cd workbench && + test_commit one && + git push --mirror up && + test_commit two && + test_must_fail git push --atomic up master + ) && + test_refs master HEAD@{1} +' + +test_done diff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh index 6da9422431..87a7aa04ae 100755 --- a/t/t5550-http-fetch-dumb.sh +++ b/t/t5550-http-fetch-dumb.sh @@ -2,12 +2,6 @@ test_description='test dumb fetching over http via static file' . ./test-lib.sh - -if test -n "$NO_CURL"; then - skip_all='skipping test, git built without http support' - test_done -fi - . "$TEST_DIRECTORY"/lib-httpd.sh start_httpd @@ -15,7 +9,7 @@ test_expect_success 'setup repository' ' git config push.default matching && echo content1 >file && git add file && - git commit -m one + git commit -m one && echo content2 >file && git add file && git commit -m two @@ -184,8 +178,8 @@ test_expect_success 'fetch can handle previously-fetched .idx files' ' ' test_expect_success 'did not use upload-pack service' ' - grep '/git-upload-pack' <"$HTTPD_ROOT_PATH"/access.log >act - : >exp + test_might_fail grep '/git-upload-pack' <"$HTTPD_ROOT_PATH"/access.log >act && + : >exp && test_cmp exp act ' @@ -214,5 +208,47 @@ test_expect_success 'reencoding is robust to whitespace oddities' ' grep "this is the error message" stderr ' +check_language () { + case "$2" in + '') + >expect + ;; + ?*) + echo "Accept-Language: $1" >expect + ;; + esac && + GIT_CURL_VERBOSE=1 \ + LANGUAGE=$2 \ + git ls-remote "$HTTPD_URL/dumb/repo.git" >output 2>&1 && + tr -d '\015' <output | + sort -u | + sed -ne '/^Accept-Language:/ p' >actual && + test_cmp expect actual +} + +test_expect_success 'git client sends Accept-Language based on LANGUAGE' ' + check_language "ko-KR, *;q=0.9" ko_KR.UTF-8' + +test_expect_success 'git client sends Accept-Language correctly with unordinary LANGUAGE' ' + check_language "ko-KR, *;q=0.9" "ko_KR:" && + check_language "ko-KR, en-US;q=0.9, *;q=0.8" "ko_KR::en_US" && + check_language "ko-KR, *;q=0.9" ":::ko_KR" && + check_language "ko-KR, en-US;q=0.9, *;q=0.8" "ko_KR!!:en_US" && + check_language "ko-KR, ja-JP;q=0.9, *;q=0.8" "ko_KR en_US:ja_JP"' + +test_expect_success 'git client sends Accept-Language with many preferred languages' ' + check_language "ko-KR, en-US;q=0.9, fr-CA;q=0.8, de;q=0.7, sr;q=0.6, \ +ja;q=0.5, zh;q=0.4, sv;q=0.3, pt;q=0.2, *;q=0.1" \ + ko_KR.EUC-KR:en_US.UTF-8:fr_CA:de.UTF-8@euro:sr@latin:ja:zh:sv:pt && + check_language "ko-KR, en-US;q=0.99, fr-CA;q=0.98, de;q=0.97, sr;q=0.96, \ +ja;q=0.95, zh;q=0.94, sv;q=0.93, pt;q=0.92, nb;q=0.91, *;q=0.90" \ + ko_KR.EUC-KR:en_US.UTF-8:fr_CA:de.UTF-8@euro:sr@latin:ja:zh:sv:pt:nb +' + +test_expect_success 'git client does not send an empty Accept-Language' ' + GIT_CURL_VERBOSE=1 LANGUAGE= git ls-remote "$HTTPD_URL/dumb/repo.git" 2>stderr && + ! grep "^Accept-Language:" stderr +' + stop_httpd test_done diff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh index df47851752..2b29311901 100755 --- a/t/t5551-http-fetch-smart.sh +++ b/t/t5551-http-fetch-smart.sh @@ -2,12 +2,6 @@ test_description='test smart fetching over http via http-backend' . ./test-lib.sh - -if test -n "$NO_CURL"; then - skip_all='skipping test, git built without http support' - test_done -fi - . "$TEST_DIRECTORY"/lib-httpd.sh start_httpd @@ -83,7 +77,7 @@ test_expect_success 'clone http repository' ' test_expect_success 'fetch changes via http' ' echo content >>file && git commit -a -m two && - git push public + git push public && (cd clone && git pull) && test_cmp file clone/file ' @@ -169,7 +163,7 @@ test_expect_success 'GIT_SMART_HTTP can disable smart http' ' ' test_expect_success 'invalid Content-Type rejected' ' - test_must_fail git clone $HTTPD_URL/broken_smart/repo.git 2>actual + test_must_fail git clone $HTTPD_URL/broken_smart/repo.git 2>actual && grep "not valid:" actual ' @@ -209,7 +203,7 @@ test_expect_success 'cookies stored in http.cookiefile when http.savecookies set git config http.cookiefile cookies.txt && git config http.savecookies true && git ls-remote $HTTPD_URL/smart_cookies/repo.git master && - tail -3 cookies.txt > cookies_tail.txt + tail -3 cookies.txt >cookies_tail.txt && test_cmp expect_cookies.txt cookies_tail.txt ' diff --git a/t/t5561-http-backend.sh b/t/t5561-http-backend.sh index d23fb02384..19afe96698 100755 --- a/t/t5561-http-backend.sh +++ b/t/t5561-http-backend.sh @@ -2,12 +2,6 @@ test_description='test git-http-backend' . ./test-lib.sh - -if test -n "$NO_CURL"; then - skip_all='skipping test, git built without http support' - test_done -fi - . "$TEST_DIRECTORY"/lib-httpd.sh start_httpd diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh index 1befc453a3..bfdaf75966 100755 --- a/t/t5601-clone.sh +++ b/t/t5601-clone.sh @@ -296,6 +296,12 @@ setup_ssh_wrapper () { ' } +copy_ssh_wrapper_as () { + cp "$TRASH_DIRECTORY/ssh-wrapper" "$1" && + GIT_SSH="$1" && + export GIT_SSH +} + expect_ssh () { test_when_finished ' (cd "$TRASH_DIRECTORY" && rm -f ssh-expect && >ssh-output) @@ -332,9 +338,36 @@ test_expect_success !MINGW,!CYGWIN 'clone local path foo:bar' ' test_expect_success 'bracketed hostnames are still ssh' ' git clone "[myhost:123]:src" ssh-bracket-clone && - expect_ssh myhost '-p 123' src + expect_ssh "-p 123" myhost src +' + +test_expect_success 'uplink is not treated as putty' ' + copy_ssh_wrapper_as "$TRASH_DIRECTORY/uplink" && + git clone "[myhost:123]:src" ssh-bracket-clone-uplink && + expect_ssh "-p 123" myhost src +' + +test_expect_success 'plink is treated specially (as putty)' ' + copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink" && + git clone "[myhost:123]:src" ssh-bracket-clone-plink-0 && + expect_ssh "-P 123" myhost src ' +test_expect_success 'plink.exe is treated specially (as putty)' ' + copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink.exe" && + git clone "[myhost:123]:src" ssh-bracket-clone-plink-1 && + expect_ssh "-P 123" myhost src +' + +test_expect_success 'tortoiseplink is like putty, with extra arguments' ' + copy_ssh_wrapper_as "$TRASH_DIRECTORY/tortoiseplink" && + git clone "[myhost:123]:src" ssh-bracket-clone-plink-2 && + expect_ssh "-batch -P 123" myhost src +' + +# Reset the GIT_SSH environment variable for clone tests. +setup_ssh_wrapper + counter=0 # $1 url # $2 none|host diff --git a/t/t5709-clone-refspec.sh b/t/t5709-clone-refspec.sh index 6f1ea984d4..7ace2535c8 100755 --- a/t/t5709-clone-refspec.sh +++ b/t/t5709-clone-refspec.sh @@ -147,7 +147,7 @@ test_expect_success '--single-branch with detached' ' git for-each-ref refs/remotes/origin | sed -e "/HEAD$/d" \ -e "s|/remotes/origin/|/heads/|" >../actual - ) + ) && # nothing >expect && test_cmp expect actual diff --git a/t/t6000-rev-list-misc.sh b/t/t6000-rev-list-misc.sh index 2602086303..3e752ce032 100755 --- a/t/t6000-rev-list-misc.sh +++ b/t/t6000-rev-list-misc.sh @@ -42,7 +42,7 @@ test_expect_success 'rev-list --objects with pathspecs and copied files' ' test_tick && git commit -m that && - ONE=$(git rev-parse HEAD:one) + ONE=$(git rev-parse HEAD:one) && git rev-list --objects HEAD two >output && grep "$ONE two/three" output && ! grep one output @@ -85,7 +85,7 @@ test_expect_success 'rev-list can show index objects' ' # - we do not show the root tree; since we updated the index, it # does not have a valid cache tree # - cat >expect <<-\EOF + cat >expect <<-\EOF && 8e4020bb5a8d8c873b25de15933e75cc0fc275df one d9d3a7417b9605cfd88ee6306b28dadc29e6ab08 only-in-index 9200b628cf9dc883a85a7abc8d6e6730baee589c two @@ -96,4 +96,8 @@ test_expect_success 'rev-list can show index objects' ' test_cmp expect actual ' +test_expect_success '--bisect and --first-parent can not be combined' ' + test_must_fail git rev-list --bisect --first-parent HEAD +' + test_done diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh index a02a45afd2..b77d4c97c1 100755 --- a/t/t6006-rev-list-format.sh +++ b/t/t6006-rev-list-format.sh @@ -45,7 +45,7 @@ test_expect_success 'setup' ' head2=$(git rev-parse --verify HEAD) && head2_short=$(git rev-parse --verify --short $head2) && tree2=$(git rev-parse --verify HEAD:) && - tree2_short=$(git rev-parse --verify --short $tree2) + tree2_short=$(git rev-parse --verify --short $tree2) && git config --unset i18n.commitEncoding ' @@ -358,10 +358,7 @@ test_expect_success 'empty email' ' test_tick && C=$(GIT_AUTHOR_EMAIL= git commit-tree HEAD^{tree} </dev/null) && A=$(git show --pretty=format:%an,%ae,%ad%n -s $C) && - test "$A" = "A U Thor,,Thu Apr 7 15:14:13 2005 -0700" || { - echo "Eh? $A" >failure - false - } + verbose test "$A" = "A U Thor,,Thu Apr 7 15:14:13 2005 -0700" ' test_expect_success 'del LF before empty (1)' ' diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh index fde5e712eb..b89cd6b07a 100755 --- a/t/t6012-rev-list-simplify.sh +++ b/t/t6012-rev-list-simplify.sh @@ -95,10 +95,7 @@ check_outcome () { git log --pretty="$FMT" --parents $param | unnote >actual && sed -e "s/^.* \([^ ]*\) .*/\1/" >check <actual && - test_cmp expect check || { - cat actual - false - } + test_cmp expect check ' } @@ -121,10 +118,7 @@ test_expect_success 'full history simplification without parent' ' git log --pretty="$FMT" --full-history E -- lost | unnote >actual && sed -e "s/^.* \([^ ]*\) .*/\1/" >check <actual && - test_cmp expect check || { - cat actual - false - } + test_cmp expect check ' test_expect_success '--full-diff is not affected by --parents' ' diff --git a/t/t6014-rev-list-all.sh b/t/t6014-rev-list-all.sh index 991ab4a65b..c9bedd29cb 100755 --- a/t/t6014-rev-list-all.sh +++ b/t/t6014-rev-list-all.sh @@ -35,4 +35,8 @@ test_expect_success 'repack does not lose detached HEAD' ' ' +test_expect_success 'rev-list --graph --no-walk is forbidden' ' + test_must_fail git rev-list --graph --no-walk HEAD +' + test_done diff --git a/t/t6020-merge-df.sh b/t/t6020-merge-df.sh index 27c3d73961..2af1beec5f 100755 --- a/t/t6020-merge-df.sh +++ b/t/t6020-merge-df.sh @@ -24,7 +24,7 @@ test_expect_success 'prepare repository' ' ' test_expect_success 'Merge with d/f conflicts' ' - test_expect_code 1 git merge "merge msg" B master + test_expect_code 1 git merge -m "merge msg" master ' test_expect_success 'F/D conflict' ' diff --git a/t/t6021-merge-criss-cross.sh b/t/t6021-merge-criss-cross.sh index d15b313d4b..213deecab1 100755 --- a/t/t6021-merge-criss-cross.sh +++ b/t/t6021-merge-criss-cross.sh @@ -48,7 +48,7 @@ echo "1 " > file && git commit -m "C3" file && git branch C3 && -git merge "pre E3 merge" B A && +git merge -m "pre E3 merge" A && echo "1 2 3 changed in E3, branch B. New file size @@ -61,7 +61,7 @@ echo "1 " > file && git commit -m "E3" file && git checkout A && -git merge "pre D8 merge" A C3 && +git merge -m "pre D8 merge" C3 && echo "1 2 3 changed in C3, branch B @@ -73,7 +73,7 @@ echo "1 9" > file && git commit -m D8 file' -test_expect_success 'Criss-cross merge' 'git merge "final merge" A B' +test_expect_success 'Criss-cross merge' 'git merge -m "final merge" B' cat > file-expect <<EOF 1 diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh index a89dfbef08..05ebba7afa 100755 --- a/t/t6022-merge-rename.sh +++ b/t/t6022-merge-rename.sh @@ -685,7 +685,7 @@ test_expect_success 'setup avoid unnecessary update, dir->(file,nothing)' ' git add -A && git commit -mA && - git checkout -b side + git checkout -b side && git rm -rf df && git commit -mB && @@ -716,7 +716,7 @@ test_expect_success 'setup avoid unnecessary update, modify/delete' ' git add -A && git commit -mA && - git checkout -b side + git checkout -b side && git rm -f file && git commit -m "Delete file" && @@ -745,7 +745,7 @@ test_expect_success 'setup avoid unnecessary update, rename/add-dest' ' git add -A && git commit -mA && - git checkout -b side + git checkout -b side && cp file newfile && git add -A && git commit -m "Add file copy" && diff --git a/t/t6026-merge-attr.sh b/t/t6026-merge-attr.sh index 5e439972be..3c21938a68 100755 --- a/t/t6026-merge-attr.sh +++ b/t/t6026-merge-attr.sh @@ -11,7 +11,7 @@ test_expect_success setup ' for f in text binary union do - echo Initial >$f && git add $f || break + echo Initial >$f && git add $f || return 1 done && test_tick && git commit -m Initial && @@ -19,7 +19,7 @@ test_expect_success setup ' git branch side && for f in text binary union do - echo Master >>$f && git add $f || break + echo Master >>$f && git add $f || return 1 done && test_tick && git commit -m Master && @@ -27,7 +27,7 @@ test_expect_success setup ' git checkout side && for f in text binary union do - echo Side >>$f && git add $f || break + echo Side >>$f && git add $f || return 1 done && test_tick && git commit -m Side && diff --git a/t/t6028-merge-up-to-date.sh b/t/t6028-merge-up-to-date.sh index c518e9c30c..7763c1ba98 100755 --- a/t/t6028-merge-up-to-date.sh +++ b/t/t6028-merge-up-to-date.sh @@ -83,7 +83,7 @@ test_expect_success 'merge fast-forward octopus' ' git reset --hard c0 && test_tick && - git merge c1 c2 + git merge c1 c2 && expect=$(git rev-parse c2) && current=$(git rev-parse HEAD) && test "$expect" = "$current" diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh index e6abe65d5c..06b4868109 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -52,15 +52,8 @@ test_expect_success 'bisect starts with only one bad' ' test_expect_success 'bisect does not start with only one good' ' git bisect reset && git bisect start && - git bisect good $HASH1 || return 1 - - if git bisect next - then - echo Oops, should have failed. - false - else - : - fi + git bisect good $HASH1 && + test_must_fail git bisect next ' test_expect_success 'bisect start with one bad and good' ' @@ -191,34 +184,27 @@ test_expect_success 'bisect start: no ".git/BISECT_START" if checkout error' ' # but $HASH2 is bad, # so we should find $HASH2 as the first bad commit test_expect_success 'bisect skip: successful result' ' + test_when_finished git bisect reset && git bisect reset && git bisect start $HASH4 $HASH1 && git bisect skip && git bisect bad > my_bisect_log.txt && - grep "$HASH2 is the first bad commit" my_bisect_log.txt && - git bisect reset + grep "$HASH2 is the first bad commit" my_bisect_log.txt ' # $HASH1 is good, $HASH4 is bad, we skip $HASH3 and $HASH2 # so we should not be able to tell the first bad commit # among $HASH2, $HASH3 and $HASH4 test_expect_success 'bisect skip: cannot tell between 3 commits' ' + test_when_finished git bisect reset && git bisect start $HASH4 $HASH1 && - git bisect skip || return 1 - - if git bisect skip > my_bisect_log.txt - then - echo Oops, should have failed. - false - else - test $? -eq 2 && - grep "first bad commit could be any of" my_bisect_log.txt && - ! grep $HASH1 my_bisect_log.txt && - grep $HASH2 my_bisect_log.txt && - grep $HASH3 my_bisect_log.txt && - grep $HASH4 my_bisect_log.txt && - git bisect reset - fi + git bisect skip && + test_expect_code 2 git bisect skip >my_bisect_log.txt && + grep "first bad commit could be any of" my_bisect_log.txt && + ! grep $HASH1 my_bisect_log.txt && + grep $HASH2 my_bisect_log.txt && + grep $HASH3 my_bisect_log.txt && + grep $HASH4 my_bisect_log.txt ' # $HASH1 is good, $HASH4 is bad, we skip $HASH3 @@ -226,22 +212,15 @@ test_expect_success 'bisect skip: cannot tell between 3 commits' ' # so we should not be able to tell the first bad commit # among $HASH3 and $HASH4 test_expect_success 'bisect skip: cannot tell between 2 commits' ' + test_when_finished git bisect reset && git bisect start $HASH4 $HASH1 && - git bisect skip || return 1 - - if git bisect good > my_bisect_log.txt - then - echo Oops, should have failed. - false - else - test $? -eq 2 && - grep "first bad commit could be any of" my_bisect_log.txt && - ! grep $HASH1 my_bisect_log.txt && - ! grep $HASH2 my_bisect_log.txt && - grep $HASH3 my_bisect_log.txt && - grep $HASH4 my_bisect_log.txt && - git bisect reset - fi + git bisect skip && + test_expect_code 2 git bisect good >my_bisect_log.txt && + grep "first bad commit could be any of" my_bisect_log.txt && + ! grep $HASH1 my_bisect_log.txt && + ! grep $HASH2 my_bisect_log.txt && + grep $HASH3 my_bisect_log.txt && + grep $HASH4 my_bisect_log.txt ' # $HASH1 is good, $HASH4 is both skipped and bad, we skip $HASH3 @@ -249,24 +228,18 @@ test_expect_success 'bisect skip: cannot tell between 2 commits' ' # so we should not be able to tell the first bad commit # among $HASH3 and $HASH4 test_expect_success 'bisect skip: with commit both bad and skipped' ' + test_when_finished git bisect reset && git bisect start && git bisect skip && git bisect bad && git bisect good $HASH1 && git bisect skip && - if git bisect good > my_bisect_log.txt - then - echo Oops, should have failed. - false - else - test $? -eq 2 && - grep "first bad commit could be any of" my_bisect_log.txt && - ! grep $HASH1 my_bisect_log.txt && - ! grep $HASH2 my_bisect_log.txt && - grep $HASH3 my_bisect_log.txt && - grep $HASH4 my_bisect_log.txt && - git bisect reset - fi + test_expect_code 2 git bisect good >my_bisect_log.txt && + grep "first bad commit could be any of" my_bisect_log.txt && + ! grep $HASH1 my_bisect_log.txt && + ! grep $HASH2 my_bisect_log.txt && + grep $HASH3 my_bisect_log.txt && + grep $HASH4 my_bisect_log.txt ' # We want to automatically find the commit that @@ -601,8 +574,7 @@ test_expect_success 'test bisection on bare repo - --no-checkout specified' ' git bisect bad $HASH4 && git bisect run eval \ "test \$(git rev-list BISECT_HEAD ^$HASH2 --max-count=1 | wc -l) = 0" \ - >../nocheckout.log && - git bisect reset + >../nocheckout.log ) && grep "$HASH3 is the first bad commit" nocheckout.log ' @@ -617,8 +589,7 @@ test_expect_success 'test bisection on bare repo - --no-checkout defaulted' ' git bisect bad $HASH4 && git bisect run eval \ "test \$(git rev-list BISECT_HEAD ^$HASH2 --max-count=1 | wc -l) = 0" \ - >../defaulted.log && - git bisect reset + >../defaulted.log ) && grep "$HASH3 is the first bad commit" defaulted.log ' @@ -642,14 +613,14 @@ test_expect_success 'broken branch creation' ' mkdir missing && :> missing/MISSING && git add missing/MISSING && - git commit -m "6(broken): Added file that will be deleted" + git commit -m "6(broken): Added file that will be deleted" && git tag BROKEN_HASH6 && add_line_into_file "7(broken): second line on a broken branch" hello2 && git tag BROKEN_HASH7 && add_line_into_file "8(broken): third line on a broken branch" hello2 && git tag BROKEN_HASH8 && git rm missing/MISSING && - git commit -m "9(broken): Remove missing file" + git commit -m "9(broken): Remove missing file" && git tag BROKEN_HASH9 && rm .git/objects/39/f7e61a724187ab767d2e08442d9b6b9dab587d ' diff --git a/t/t6032-merge-large-rename.sh b/t/t6032-merge-large-rename.sh index 15beecc3c6..0f79268917 100755 --- a/t/t6032-merge-large-rename.sh +++ b/t/t6032-merge-large-rename.sh @@ -28,10 +28,10 @@ make_text() { test_rename() { test_expect_success "rename ($1, $2)" ' - n='$1' - expect='$2' + n='$1' && + expect='$2' && git checkout -f master && - git branch -D test$n || true && + test_might_fail git branch -D test$n && git reset --hard initial && for i in $(count $n); do make_text $i initial initial >$i diff --git a/t/t6034-merge-rename-nocruft.sh b/t/t6034-merge-rename-nocruft.sh index 65be95fbaa..89871aa5b0 100755 --- a/t/t6034-merge-rename-nocruft.sh +++ b/t/t6034-merge-rename-nocruft.sh @@ -73,33 +73,12 @@ test_expect_success 'merge white into red (A->B,M->N)' \ ' git checkout -b red-white red && git merge white && - git write-tree >/dev/null || { - echo "BAD: merge did not complete" - return 1 - } - - test -f B || { - echo "BAD: B does not exist in working directory" - return 1 - } - test -f N || { - echo "BAD: N does not exist in working directory" - return 1 - } - test -f R || { - echo "BAD: R does not exist in working directory" - return 1 - } - - test -f A && { - echo "BAD: A still exists in working directory" - return 1 - } - test -f M && { - echo "BAD: M still exists in working directory" - return 1 - } - return 0 + git write-tree && + test_path_is_file B && + test_path_is_file N && + test_path_is_file R && + test_path_is_missing A && + test_path_is_missing M ' # This test broke in 8371234ecaaf6e14fe3f2082a855eff1bbd79ae9 @@ -108,32 +87,13 @@ test_expect_success 'merge blue into white (A->B, mod A, A untracked)' \ git checkout -b white-blue white && echo dirty >A && git merge blue && - git write-tree >/dev/null || { - echo "BAD: merge did not complete" - return 1 - } - - test -f A || { - echo "BAD: A does not exist in working directory" - return 1 - } - test `cat A` = dirty || { - echo "BAD: A content is wrong" - return 1 - } - test -f B || { - echo "BAD: B does not exist in working directory" - return 1 - } - test -f N || { - echo "BAD: N does not exist in working directory" - return 1 - } - test -f M && { - echo "BAD: M still exists in working directory" - return 1 - } - return 0 + git write-tree && + test_path_is_file A && + echo dirty >expect && + test_cmp expect A && + test_path_is_file B && + test_path_is_file N && + test_path_is_missing M ' test_done diff --git a/t/t6036-recursive-corner-cases.sh b/t/t6036-recursive-corner-cases.sh index a86087be95..9d6621c056 100755 --- a/t/t6036-recursive-corner-cases.sh +++ b/t/t6036-recursive-corner-cases.sh @@ -86,7 +86,7 @@ test_expect_success 'setup criss-cross + rename merges with basic modification' rm -rf .git && git init && - ten="0 1 2 3 4 5 6 7 8 9" + ten="0 1 2 3 4 5 6 7 8 9" && for i in $ten do echo line $i in a sample file @@ -195,12 +195,7 @@ test_expect_success 'git detects differently handled merges conflict' ' git reset --hard && git checkout D^0 && - git merge -s recursive E^0 && { - echo "BAD: should have conflicted" - test "Incorrectly merged content" = "$(cat new_a)" && - echo "BAD: Silently accepted wrong content" - return 1 - } + test_must_fail git merge -s recursive E^0 && test 3 = $(git ls-files -s | wc -l) && test 3 = $(git ls-files -u | wc -l) && @@ -533,7 +528,7 @@ test_expect_success 'merge of E2 & D fails but has appropriate contents' ' test $(git rev-parse :3:a) = $(git rev-parse B:a) && test $(git rev-parse :2:a/file) = $(git rev-parse E2:a/file) && - test $(git rev-parse :1:a/file) = $(git rev-parse C:a/file) + test $(git rev-parse :1:a/file) = $(git rev-parse C:a/file) && test $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) && test -f a~D^0 diff --git a/t/t6039-merge-ignorecase.sh b/t/t6039-merge-ignorecase.sh index a977653147..531850d834 100755 --- a/t/t6039-merge-ignorecase.sh +++ b/t/t6039-merge-ignorecase.sh @@ -15,7 +15,7 @@ test_expect_success 'merge with case-changing rename' ' >TestCase && git add TestCase && git commit -m "add TestCase" && - git tag baseline + git tag baseline && git checkout -b with-camel && >foo && git add foo && diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh index 7ac8fd06c3..3d5c238c81 100755 --- a/t/t6040-tracking-info.sh +++ b/t/t6040-tracking-info.sh @@ -12,10 +12,9 @@ advance () { } test_expect_success setup ' - for i in a b c; - do - advance $i || break - done && + advance a && + advance b && + advance c && git clone . test && ( cd test && diff --git a/t/t6111-rev-list-treesame.sh b/t/t6111-rev-list-treesame.sh index 88b84dfa73..32474c23d3 100755 --- a/t/t6111-rev-list-treesame.sh +++ b/t/t6111-rev-list-treesame.sh @@ -58,7 +58,7 @@ test_expect_success setup ' git checkout master && test_tick && git merge --no-ff fiddler-branch && - note K + note K && test_commit "file=Part 1" file "Part 1" L && @@ -92,10 +92,7 @@ check_outcome () { git log --format="$FMT" $param | unnote >actual && sed -e "$munge_actual" <actual >check && - test_cmp expect check || { - cat actual - false - } + test_cmp expect check ' } diff --git a/t/t6132-pathspec-exclude.sh b/t/t6132-pathspec-exclude.sh index 62049be0c7..e1e1b1fa38 100755 --- a/t/t6132-pathspec-exclude.sh +++ b/t/t6132-pathspec-exclude.sh @@ -30,7 +30,7 @@ test_expect_success 'exclude only should error out' ' ' test_expect_success 't_e_i() exclude sub' ' - git log --oneline --format=%s -- . ":(exclude)sub" >actual + git log --oneline --format=%s -- . ":(exclude)sub" >actual && cat <<EOF >expect && sub2/file file @@ -39,7 +39,7 @@ EOF ' test_expect_success 't_e_i() exclude sub/sub/file' ' - git log --oneline --format=%s -- . ":(exclude)sub/sub/file" >actual + git log --oneline --format=%s -- . ":(exclude)sub/sub/file" >actual && cat <<EOF >expect && sub2/file sub/sub/sub/file @@ -51,7 +51,7 @@ EOF ' test_expect_success 't_e_i() exclude sub using mnemonic' ' - git log --oneline --format=%s -- . ":!sub" >actual + git log --oneline --format=%s -- . ":!sub" >actual && cat <<EOF >expect && sub2/file file @@ -60,7 +60,7 @@ EOF ' test_expect_success 't_e_i() exclude :(icase)SUB' ' - git log --oneline --format=%s -- . ":(exclude,icase)SUB" >actual + git log --oneline --format=%s -- . ":(exclude,icase)SUB" >actual && cat <<EOF >expect && sub2/file file @@ -71,7 +71,7 @@ EOF test_expect_success 't_e_i() exclude sub2 from sub' ' ( cd sub && - git log --oneline --format=%s -- :/ ":/!sub2" >actual + git log --oneline --format=%s -- :/ ":/!sub2" >actual && cat <<EOF >expect && sub/sub/sub/file sub/file2 @@ -84,7 +84,7 @@ EOF ' test_expect_success 't_e_i() exclude sub/*file' ' - git log --oneline --format=%s -- . ":(exclude)sub/*file" >actual + git log --oneline --format=%s -- . ":(exclude)sub/*file" >actual && cat <<EOF >expect && sub2/file sub/file2 @@ -94,7 +94,7 @@ EOF ' test_expect_success 't_e_i() exclude :(glob)sub/*/file' ' - git log --oneline --format=%s -- . ":(exclude,glob)sub/*/file" >actual + git log --oneline --format=%s -- . ":(exclude,glob)sub/*/file" >actual && cat <<EOF >expect && sub2/file sub/sub/sub/file @@ -106,7 +106,7 @@ EOF ' test_expect_success 'm_p_d() exclude sub' ' - git ls-files -- . ":(exclude)sub" >actual + git ls-files -- . ":(exclude)sub" >actual && cat <<EOF >expect && file sub2/file @@ -115,7 +115,7 @@ EOF ' test_expect_success 'm_p_d() exclude sub/sub/file' ' - git ls-files -- . ":(exclude)sub/sub/file" >actual + git ls-files -- . ":(exclude)sub/sub/file" >actual && cat <<EOF >expect && file sub/file @@ -127,7 +127,7 @@ EOF ' test_expect_success 'm_p_d() exclude sub using mnemonic' ' - git ls-files -- . ":!sub" >actual + git ls-files -- . ":!sub" >actual && cat <<EOF >expect && file sub2/file @@ -136,7 +136,7 @@ EOF ' test_expect_success 'm_p_d() exclude :(icase)SUB' ' - git ls-files -- . ":(exclude,icase)SUB" >actual + git ls-files -- . ":(exclude,icase)SUB" >actual && cat <<EOF >expect && file sub2/file @@ -147,7 +147,7 @@ EOF test_expect_success 'm_p_d() exclude sub2 from sub' ' ( cd sub && - git ls-files -- :/ ":/!sub2" >actual + git ls-files -- :/ ":/!sub2" >actual && cat <<EOF >expect && ../file file @@ -160,7 +160,7 @@ EOF ' test_expect_success 'm_p_d() exclude sub/*file' ' - git ls-files -- . ":(exclude)sub/*file" >actual + git ls-files -- . ":(exclude)sub/*file" >actual && cat <<EOF >expect && file sub/file2 @@ -170,7 +170,7 @@ EOF ' test_expect_success 'm_p_d() exclude :(glob)sub/*/file' ' - git ls-files -- . ":(exclude,glob)sub/*/file" >actual + git ls-files -- . ":(exclude,glob)sub/*/file" >actual && cat <<EOF >expect && file sub/file diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh index 54b5744cc5..2e2fb0e957 100755 --- a/t/t6200-fmt-merge-msg.sh +++ b/t/t6200-fmt-merge-msg.sh @@ -194,7 +194,7 @@ test_expect_success '--log=5 with custom comment character' ' ' test_expect_success 'merge.log=0 disables shortlog' ' - echo "Merge branch ${apos}left${apos}" >expected + echo "Merge branch ${apos}left${apos}" >expected && git -c merge.log=0 fmt-merge-msg <.git/FETCH_HEAD >actual && test_cmp expected actual ' diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh index 69f11bd40d..7b56081137 100755 --- a/t/t7001-mv.sh +++ b/t/t7001-mv.sh @@ -161,10 +161,7 @@ test_expect_success "Michael Cassar's test case" ' git mv papers/unsorted/Thesis.pdf papers/all-papers/moo-blah.pdf && T=`git write-tree` && - git ls-tree -r $T | grep partA/outline.txt || { - git ls-tree -r $T - (exit 1) - } + git ls-tree -r $T | verbose grep partA/outline.txt ' rm -fr papers partA path? diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh index 66643e4bd7..855afda80a 100755 --- a/t/t7003-filter-branch.sh +++ b/t/t7003-filter-branch.sh @@ -394,4 +394,14 @@ test_expect_success 'replace submodule revision' ' test $orig_head != `git show-ref --hash --head HEAD` ' +test_expect_success 'filter commit message without trailing newline' ' + git reset --hard original && + commit=$(printf "no newline" | git commit-tree HEAD^{tree}) && + git update-ref refs/heads/no-newline $commit && + git filter-branch -f refs/heads/no-newline && + echo $commit >expect && + git rev-parse refs/heads/no-newline >actual && + test_cmp expect actual +' + test_done diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh index 35c805a44e..fa207f3b8c 100755 --- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh @@ -1180,8 +1180,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 && + >rest.expect && + sed -e 1d -e "/^#/d" <actual >rest.actual && test_cmp rest.expect rest.actual ' @@ -1459,6 +1459,34 @@ test_expect_success 'invalid sort parameter in configuratoin' ' test_cmp expect actual ' +test_expect_success 'version sort with prerelease reordering' ' + git config --unset tag.sort && + git config versionsort.prereleaseSuffix -rc && + git tag foo1.6-rc1 && + git tag foo1.6-rc2 && + git tag -l --sort=version:refname "foo*" >actual && + cat >expect <<-\EOF && + foo1.3 + foo1.6-rc1 + foo1.6-rc2 + foo1.6 + foo1.10 + EOF + test_cmp expect actual +' + +test_expect_success 'reverse version sort with prerelease reordering' ' + git tag -l --sort=-version:refname "foo*" >actual && + cat >expect <<-\EOF && + foo1.10 + foo1.6 + foo1.6-rc2 + foo1.6-rc1 + foo1.3 + EOF + test_cmp expect actual +' + run_with_limited_stack () { (ulimit -s 128 && "$@") } diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh index da958a8b56..947b690fd7 100755 --- a/t/t7006-pager.sh +++ b/t/t7006-pager.sh @@ -396,7 +396,7 @@ test_expect_success TTY 'command-specific pager overrides core.pager' ' sane_unset PAGER GIT_PAGER && echo "foo:initial" >expect && >actual && - test_config core.pager "exit 1" + test_config core.pager "exit 1" && test_config pager.log "sed s/^/foo:/ >actual" && test_terminal git log --format=%s -1 && test_cmp expect actual diff --git a/t/t7007-show.sh b/t/t7007-show.sh index 1b824fe5ed..42d3db6246 100755 --- a/t/t7007-show.sh +++ b/t/t7007-show.sh @@ -124,4 +124,8 @@ test_expect_success '--quiet suppresses diff' ' test_cmp expect actual ' +test_expect_success 'show --graph is forbidden' ' + test_must_fail git show --graph HEAD +' + test_done diff --git a/t/t7009-filter-branch-null-sha1.sh b/t/t7009-filter-branch-null-sha1.sh index a997f7ac3a..c27f90f285 100755 --- a/t/t7009-filter-branch-null-sha1.sh +++ b/t/t7009-filter-branch-null-sha1.sh @@ -13,7 +13,7 @@ test_expect_success 'setup: a commit with a bogus null sha1 in the tree' ' { git ls-tree HEAD && printf "160000 commit $_z40\\tbroken\\n" - } >broken-tree + } >broken-tree && echo "add broken entry" >msg && tree=$(git mktree <broken-tree) && diff --git a/t/t7061-wtstatus-ignore.sh b/t/t7061-wtstatus-ignore.sh index 460789b4d8..cdc0747bf0 100755 --- a/t/t7061-wtstatus-ignore.sh +++ b/t/t7061-wtstatus-ignore.sh @@ -20,6 +20,15 @@ test_expect_success 'status untracked directory with --ignored' ' test_cmp expected actual ' +test_expect_success 'same with gitignore starting with BOM' ' + printf "\357\273\277ignored\n" >.gitignore && + mkdir -p untracked && + : >untracked/ignored && + : >untracked/uncommitted && + git status --porcelain --ignored >actual && + test_cmp expected actual +' + cat >expected <<\EOF ?? .gitignore ?? actual diff --git a/t/t7201-co.sh b/t/t7201-co.sh index eae9e5a937..885923610a 100755 --- a/t/t7201-co.sh +++ b/t/t7201-co.sh @@ -88,14 +88,10 @@ test_expect_success "checkout with unrelated dirty tree without -m" ' git checkout -f master && fill 0 1 2 3 4 5 6 7 8 >same && - cp same kept + cp same kept && git checkout side >messages && - test_cmp same kept - (cat > messages.expect <<EOF -M same -EOF -) && - touch messages.expect && + test_cmp same kept && + printf "M\t%s\n" same >messages.expect && test_cmp messages.expect messages ' @@ -109,10 +105,7 @@ test_expect_success "checkout -m with dirty tree" ' test "$(git symbolic-ref HEAD)" = "refs/heads/side" && - (cat >expect.messages <<EOF -M one -EOF -) && + printf "M\t%s\n" one >expect.messages && test_cmp expect.messages messages && fill "M one" "A three" "D two" >expect.master && @@ -409,12 +402,12 @@ test_expect_success \ test_expect_success \ 'checkout w/autosetupmerge=always sets up tracking' ' + test_when_finished git config branch.autosetupmerge false && git config branch.autosetupmerge always && git checkout master && git checkout -b track2 && test "$(git config branch.track2.remote)" && - test "$(git config branch.track2.merge)" - git config branch.autosetupmerge false' + test "$(git config branch.track2.merge)"' test_expect_success 'checkout w/--track from non-branch HEAD fails' ' git checkout master^0 && @@ -591,7 +584,7 @@ test_expect_success 'checkout --conflict=merge, overriding config' ' ' test_expect_success 'checkout --conflict=diff3' ' - git config --unset merge.conflictstyle + test_unconfig merge.conflictstyle && setup_conflicting_index && echo "none of the above" >sample && echo ourside >expect && diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh index 04118ad75b..99be5d95d0 100755 --- a/t/t7300-clean.sh +++ b/t/t7300-clean.sh @@ -119,10 +119,7 @@ test_expect_success C_LOCALE_OUTPUT 'git clean with relative prefix' ' git clean -n ../src | sed -n -e "s|^Would remove ||p" ) && - test "$would_clean" = ../src/part3.c || { - echo "OOps <$would_clean>" - false - } + verbose test "$would_clean" = ../src/part3.c ' test_expect_success C_LOCALE_OUTPUT 'git clean with absolute path' ' @@ -134,10 +131,7 @@ test_expect_success C_LOCALE_OUTPUT 'git clean with absolute path' ' git clean -n "$(pwd)/../src" | sed -n -e "s|^Would remove ||p" ) && - test "$would_clean" = ../src/part3.c || { - echo "OOps <$would_clean>" - false - } + verbose test "$would_clean" = ../src/part3.c ' test_expect_success 'git clean with out of work tree relative path' ' diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index 5811a982f4..540771ca41 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -766,7 +766,7 @@ test_expect_success 'moving the superproject does not break submodules' ' ( cd addtest && git submodule status >expect - ) + ) && mv addtest addtest2 && ( cd addtest2 && @@ -987,7 +987,7 @@ test_expect_success 'submodule with UTF-8 name' ' test_expect_success 'submodule add clone shallow submodule' ' mkdir super && - pwd=$(pwd) + pwd=$(pwd) && ( cd super && git init && diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh index 29d3d2cca0..dda3929d99 100755 --- a/t/t7406-submodule-update.sh +++ b/t/t7406-submodule-update.sh @@ -754,7 +754,7 @@ test_expect_success SYMLINKS 'submodule update can handle symbolic links in pwd' test_expect_success 'submodule update clone shallow submodule' ' git clone cloned super3 && - pwd=$(pwd) + pwd=$(pwd) && (cd super3 && sed -e "s#url = ../#url = file://$pwd/#" <.gitmodules >.gitmodules.tmp && mv -f .gitmodules.tmp .gitmodules && diff --git a/t/t7410-submodule-checkout-to.sh b/t/t7410-submodule-checkout-to.sh new file mode 100755 index 0000000000..8f30aed6cc --- /dev/null +++ b/t/t7410-submodule-checkout-to.sh @@ -0,0 +1,50 @@ +#!/bin/sh + +test_description='Combination of submodules and multiple workdirs' + +. ./test-lib.sh + +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")' + +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 checkout --to "$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_success 'checkout main and initialize independed clones' \ + 'mkdir fully_cloned_submodule && + (cd clone/main && + git checkout --to "$base_path/fully_cloned_submodule/main" "$rev1_hash_main") && + (cd fully_cloned_submodule/main && git 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_done diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh index 051489ea33..2e0d557243 100755 --- a/t/t7502-commit.sh +++ b/t/t7502-commit.sh @@ -370,7 +370,7 @@ exit 0 EOF test_expect_success !AUTOIDENT 'do not fire editor when committer is bogus' ' - >.git/result + >.git/result && >expect && echo >>negative && diff --git a/t/t7508-status.sh b/t/t7508-status.sh index 8ed5788808..c3ed7cb51c 100755 --- a/t/t7508-status.sh +++ b/t/t7508-status.sh @@ -66,6 +66,12 @@ strip_comments () { rm "$1" && mv "$1".tmp "$1" } +cat >.gitignore <<\EOF +.gitignore +expect* +output* +EOF + test_expect_success 'status --column' ' cat >expect <<\EOF && # On branch master @@ -83,8 +89,8 @@ test_expect_success 'status --column' ' # Untracked files: # (use "git add <file>..." to include in what will be committed) # -# dir1/untracked dir2/untracked output -# dir2/modified expect untracked +# dir1/untracked dir2/untracked +# dir2/modified untracked # EOF COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output && @@ -116,8 +122,6 @@ cat >expect <<\EOF # dir1/untracked # dir2/modified # dir2/untracked -# expect -# output # untracked # EOF @@ -133,6 +137,23 @@ test_expect_success 'status with status.displayCommentPrefix=false' ' test_i18ncmp expect output ' +test_expect_success 'status -v' ' + (cat expect && git diff --cached) >expect-with-v && + git status -v >output && + test_i18ncmp expect-with-v output +' + +test_expect_success 'status -v -v' ' + (cat expect && + echo "Changes to be committed:" && + git -c diff.mnemonicprefix=true diff --cached && + echo "--------------------------------------------------" && + echo "Changes not staged for commit:" && + git -c diff.mnemonicprefix=true diff) >expect-with-v && + git status -v -v >output && + test_i18ncmp expect-with-v output +' + test_expect_success 'setup fake editor' ' cat >.git/editor <<-\EOF && #! /bin/sh @@ -167,8 +188,6 @@ Untracked files: dir1/untracked dir2/modified dir2/untracked - expect - output untracked EOF @@ -186,8 +205,6 @@ A dir2/added ?? dir1/untracked ?? dir2/modified ?? dir2/untracked -?? expect -?? output ?? untracked EOF @@ -201,7 +218,7 @@ test_expect_success 'status -s' ' test_expect_success 'status with gitignore' ' { echo ".gitignore" && - echo "expect" && + echo "expect*" && echo "output" && echo "untracked" } >.gitignore && @@ -222,6 +239,7 @@ test_expect_success 'status with gitignore' ' !! dir1/untracked !! dir2/untracked !! expect + !! expect-with-v !! output !! untracked EOF @@ -253,6 +271,7 @@ Ignored files: dir1/untracked dir2/untracked expect + expect-with-v output untracked @@ -264,7 +283,7 @@ EOF test_expect_success 'status with gitignore (nothing untracked)' ' { echo ".gitignore" && - echo "expect" && + echo "expect*" && echo "dir2/modified" && echo "output" && echo "untracked" @@ -285,6 +304,7 @@ test_expect_success 'status with gitignore (nothing untracked)' ' !! dir2/modified !! dir2/untracked !! expect + !! expect-with-v !! output !! untracked EOF @@ -312,6 +332,7 @@ Ignored files: dir2/modified dir2/untracked expect + expect-with-v output untracked @@ -320,7 +341,11 @@ EOF test_i18ncmp expect output ' -rm -f .gitignore +cat >.gitignore <<\EOF +.gitignore +expect* +output* +EOF cat >expect <<\EOF ## master @@ -329,8 +354,6 @@ A dir2/added ?? dir1/untracked ?? dir2/modified ?? dir2/untracked -?? expect -?? output ?? untracked EOF @@ -408,7 +431,7 @@ test_expect_success 'status -s -uno' ' ' test_expect_success 'status -s (status.showUntrackedFiles no)' ' - git config status.showuntrackedfiles no + git config status.showuntrackedfiles no && git status -s >output && test_cmp expect output ' @@ -434,8 +457,6 @@ Untracked files: dir2/modified dir2/untracked dir3/ - expect - output untracked EOF @@ -444,7 +465,7 @@ EOF ' test_expect_success 'status (status.showUntrackedFiles normal)' ' - test_config status.showuntrackedfiles normal + test_config status.showuntrackedfiles normal && git status >output && test_i18ncmp expect output ' @@ -456,8 +477,6 @@ A dir2/added ?? dir2/modified ?? dir2/untracked ?? dir3/ -?? expect -?? output ?? untracked EOF test_expect_success 'status -s -unormal' ' @@ -466,7 +485,7 @@ test_expect_success 'status -s -unormal' ' ' test_expect_success 'status -s (status.showUntrackedFiles normal)' ' - git config status.showuntrackedfiles normal + git config status.showuntrackedfiles normal && git status -s >output && test_cmp expect output ' @@ -493,8 +512,6 @@ Untracked files: dir2/untracked dir3/untracked1 dir3/untracked2 - expect - output untracked EOF @@ -503,7 +520,7 @@ EOF ' test_expect_success 'status (status.showUntrackedFiles all)' ' - test_config status.showuntrackedfiles all + test_config status.showuntrackedfiles all && git status >output && test_i18ncmp expect output ' @@ -518,12 +535,10 @@ A dir2/added ?? dir1/untracked ?? dir2/modified ?? dir2/untracked -?? expect -?? output ?? untracked EOF test_expect_success 'status -s -uall' ' - git config --unset status.showuntrackedfiles + test_unconfig status.showuntrackedfiles && git status -s -uall >output && test_cmp expect output ' @@ -554,8 +569,6 @@ Untracked files: untracked ../dir2/modified ../dir2/untracked - ../expect - ../output ../untracked EOF @@ -569,8 +582,6 @@ A ../dir2/added ?? untracked ?? ../dir2/modified ?? ../dir2/untracked -?? ../expect -?? ../output ?? ../untracked EOF test_expect_success 'status -s with relative paths' ' @@ -586,8 +597,6 @@ A dir2/added ?? dir1/untracked ?? dir2/modified ?? dir2/untracked -?? expect -?? output ?? untracked EOF @@ -625,8 +634,6 @@ Untracked files: <BLUE>dir1/untracked<RESET> <BLUE>dir2/modified<RESET> <BLUE>dir2/untracked<RESET> - <BLUE>expect<RESET> - <BLUE>output<RESET> <BLUE>untracked<RESET> EOF @@ -647,8 +654,6 @@ cat >expect <<\EOF <BLUE>??<RESET> dir1/untracked <BLUE>??<RESET> dir2/modified <BLUE>??<RESET> dir2/untracked -<BLUE>??<RESET> expect -<BLUE>??<RESET> output <BLUE>??<RESET> untracked EOF @@ -676,8 +681,6 @@ cat >expect <<\EOF <BLUE>??<RESET> dir1/untracked <BLUE>??<RESET> dir2/modified <BLUE>??<RESET> dir2/untracked -<BLUE>??<RESET> expect -<BLUE>??<RESET> output <BLUE>??<RESET> untracked EOF @@ -694,8 +697,6 @@ A dir2/added ?? dir1/untracked ?? dir2/modified ?? dir2/untracked -?? expect -?? output ?? untracked EOF @@ -755,8 +756,6 @@ Untracked files: dir1/untracked dir2/modified dir2/untracked - expect - output untracked EOF @@ -772,8 +771,6 @@ A dir2/added ?? dir1/untracked ?? dir2/modified ?? dir2/untracked -?? expect -?? output ?? untracked EOF @@ -798,8 +795,6 @@ Untracked files: dir1/untracked dir2/ - expect - output untracked EOF @@ -848,8 +843,6 @@ Untracked files: dir1/untracked dir2/modified dir2/untracked - expect - output untracked EOF @@ -870,8 +863,6 @@ A sm ?? dir1/untracked ?? dir2/modified ?? dir2/untracked -?? expect -?? output ?? untracked EOF test_expect_success 'status -s submodule summary is disabled by default' ' @@ -913,8 +904,6 @@ Untracked files: dir1/untracked dir2/modified dir2/untracked - expect - output untracked EOF @@ -940,8 +929,6 @@ A sm ?? dir1/untracked ?? dir2/modified ?? dir2/untracked -?? expect -?? output ?? untracked EOF test_expect_success 'status -s submodule summary' ' @@ -964,8 +951,6 @@ Untracked files: dir1/untracked dir2/modified dir2/untracked - expect - output untracked no changes added to commit (use "git add" and/or "git commit -a") @@ -983,8 +968,6 @@ cat >expect <<EOF ?? dir1/untracked ?? dir2/modified ?? dir2/untracked -?? expect -?? output ?? untracked EOF test_expect_success 'status -s submodule summary (clean submodule)' ' @@ -1025,8 +1008,6 @@ Untracked files: dir1/untracked dir2/modified dir2/untracked - expect - output untracked EOF @@ -1080,8 +1061,6 @@ Untracked files: dir1/untracked dir2/modified dir2/untracked - expect - output untracked EOF @@ -1192,8 +1171,6 @@ Untracked files: dir1/untracked dir2/modified dir2/untracked - expect - output untracked EOF @@ -1254,8 +1231,6 @@ Untracked files: dir1/untracked dir2/modified dir2/untracked - expect - output untracked EOF @@ -1336,8 +1311,6 @@ cat > expect << EOF ; dir1/untracked ; dir2/modified ; dir2/untracked -; expect -; output ; untracked ; EOF @@ -1369,8 +1342,6 @@ Untracked files: dir1/untracked dir2/modified dir2/untracked - expect - output untracked no changes added to commit (use "git add" and/or "git commit -a") @@ -1400,8 +1371,6 @@ Untracked files: dir1/untracked dir2/modified dir2/untracked - expect - output untracked EOF diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh index 3cef18cfda..13331e533b 100755 --- a/t/t7510-signed-commit.sh +++ b/t/t7510-signed-commit.sh @@ -42,7 +42,7 @@ test_expect_success GPG 'create signed commits' ' git tag seventh-unsigned && test_tick && git rebase -f HEAD^^ && git tag sixth-signed HEAD^ && - git tag seventh-signed + git tag seventh-signed && echo 8 >file && test_tick && git commit -a -m eighth -SB7227189 && git tag eighth-signed-alt diff --git a/t/t7516-commit-races.sh b/t/t7516-commit-races.sh new file mode 100755 index 0000000000..f2ce14e907 --- /dev/null +++ b/t/t7516-commit-races.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +test_description='git commit races' +. ./test-lib.sh + +test_expect_success 'race to create orphan commit' ' + write_script hare-editor <<-\EOF && + git commit --allow-empty -m hare + EOF + test_must_fail env EDITOR=./hare-editor git commit --allow-empty -m tortoise -e && + git show -s --pretty=format:%s >subject && + grep hare subject && + test -z "$(git show -s --pretty=format:%P)" +' + +test_expect_success 'race to create non-orphan commit' ' + write_script airplane-editor <<-\EOF && + git commit --allow-empty -m airplane + EOF + git checkout --orphan branch && + git commit --allow-empty -m base && + git rev-parse HEAD >base && + test_must_fail env EDITOR=./airplane-editor git commit --allow-empty -m ship -e && + git show -s --pretty=format:%s >subject && + grep airplane subject && + git rev-parse HEAD^ >parent && + test_cmp base parent +' + +test_done diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh index b16462132f..75c50eea15 100755 --- a/t/t7600-merge.sh +++ b/t/t7600-merge.sh @@ -133,7 +133,7 @@ test_expect_success 'setup' ' test_tick && git commit -m "commit 3" && git tag c3 && - c3=$(git rev-parse HEAD) + c3=$(git rev-parse HEAD) && git reset --hard "$c0" && create_merge_msgs ' diff --git a/t/t7612-merge-verify-signatures.sh b/t/t7612-merge-verify-signatures.sh index 21a0bf8fb8..8ae69a61c3 100755 --- a/t/t7612-merge-verify-signatures.sh +++ b/t/t7612-merge-verify-signatures.sh @@ -29,7 +29,7 @@ test_expect_success GPG 'create signed commits' ' git checkout -b side-untrusted && echo 3 >baz && git add baz && - test_tick && git commit -SB7227189 -m "untrusted on side" + test_tick && git commit -SB7227189 -m "untrusted on side" && git checkout master ' diff --git a/t/t7701-repack-unpack-unreachable.sh b/t/t7701-repack-unpack-unreachable.sh index aad8a9c64d..b66e383866 100755 --- a/t/t7701-repack-unpack-unreachable.sh +++ b/t/t7701-repack-unpack-unreachable.sh @@ -57,7 +57,7 @@ compare_mtimes () { read tref rest && while read t rest; do - test "$tref" = "$t" || break + test "$tref" = "$t" || return 1 done } diff --git a/t/t8003-blame-corner-cases.sh b/t/t8003-blame-corner-cases.sh index 2a3469bcbe..16f1442c1e 100755 --- a/t/t8003-blame-corner-cases.sh +++ b/t/t8003-blame-corner-cases.sh @@ -26,7 +26,7 @@ test_expect_success setup ' cat one >uno && mv two dos && cat one >>tres && - echo DEF >>mouse + echo DEF >>mouse && git add uno dos tres mouse && test_tick && GIT_AUTHOR_NAME=Second git commit -a -m Second && @@ -153,15 +153,15 @@ test_expect_success 'blame path that used to be a directory' ' ' test_expect_success 'blame to a commit with no author name' ' - TREE=`git rev-parse HEAD:` - cat >badcommit <<EOF + TREE=`git rev-parse HEAD:` && + cat >badcommit <<EOF && tree $TREE author <noname> 1234567890 +0000 committer David Reiss <dreiss@facebook.com> 1234567890 +0000 some message EOF - COMMIT=`git hash-object -t commit -w badcommit` + COMMIT=`git hash-object -t commit -w badcommit` && git --no-pager blame $COMMIT -- uno >/dev/null ' @@ -191,12 +191,24 @@ test_expect_success 'indent of line numbers, ten lines' ' test $(grep -c " " actual) = 9 ' -test_expect_success 'blaming files with CRLF newlines' ' +test_expect_success 'setup file with CRLF newlines' ' git config core.autocrlf false && - printf "testcase\r\n" >crlffile && + printf "testcase\n" >crlffile && git add crlffile && git commit -m testcase && - git -c core.autocrlf=input blame crlffile >actual && + printf "testcase\r\n" >crlffile +' + +test_expect_success 'blame file with CRLF core.autocrlf true' ' + git config core.autocrlf true && + git blame crlffile >actual && + grep "A U Thor" actual +' + +test_expect_success 'blame file with CRLF attributes text' ' + git config core.autocrlf false && + echo "crlffile text" >.gitattributes && + git blame crlffile >actual && grep "A U Thor" actual ' diff --git a/t/t8008-blame-formats.sh b/t/t8008-blame-formats.sh index d15f8b3d47..29f84a6dd1 100755 --- a/t/t8008-blame-formats.sh +++ b/t/t8008-blame-formats.sh @@ -5,7 +5,7 @@ test_description='blame output in various formats on a simple case' test_expect_success 'setup' ' echo a >file && - git add file + git add file && test_tick && git commit -m one && echo b >>file && diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 051305545c..7be14a4e37 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -818,25 +818,19 @@ test_expect_success $PREREQ '--confirm=compose' ' ' test_expect_success $PREREQ 'confirm by default (due to cc)' ' - CONFIRM=$(git config --get sendemail.confirm) && + test_when_finished git config sendemail.confirm never && git config --unset sendemail.confirm && test_confirm - ret="$?" - git config sendemail.confirm ${CONFIRM:-never} - test $ret = "0" ' test_expect_success $PREREQ 'confirm by default (due to --compose)' ' - CONFIRM=$(git config --get sendemail.confirm) && + test_when_finished git config sendemail.confirm never && git config --unset sendemail.confirm && test_confirm --suppress-cc=all --compose - ret="$?" - git config sendemail.confirm ${CONFIRM:-never} - test $ret = "0" ' test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' ' - CONFIRM=$(git config --get sendemail.confirm) && + test_when_finished git config sendemail.confirm never && git config --unset sendemail.confirm && rm -fr outdir && git format-patch -2 -o outdir && @@ -846,13 +840,10 @@ test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' ' --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ outdir/*.patch </dev/null - ret="$?" - git config sendemail.confirm ${CONFIRM:-never} - test $ret = "0" ' test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' ' - CONFIRM=$(git config --get sendemail.confirm) && + test_when_finished git config sendemail.confirm never && git config sendemail.confirm auto && GIT_SEND_EMAIL_NOTTY=1 && export GIT_SEND_EMAIL_NOTTY && @@ -861,13 +852,10 @@ test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' ' --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ $patches </dev/null - ret="$?" - git config sendemail.confirm ${CONFIRM:-never} - test $ret = "0" ' test_expect_success $PREREQ 'confirm does not loop forever' ' - CONFIRM=$(git config --get sendemail.confirm) && + test_when_finished git config sendemail.confirm never && git config sendemail.confirm auto && GIT_SEND_EMAIL_NOTTY=1 && export GIT_SEND_EMAIL_NOTTY && @@ -876,9 +864,6 @@ test_expect_success $PREREQ 'confirm does not loop forever' ' --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ $patches - ret="$?" - git config sendemail.confirm ${CONFIRM:-never} - test $ret = "0" ' test_expect_success $PREREQ 'utf8 Cc is rfc2047 encoded' ' @@ -1325,7 +1310,7 @@ test_expect_success $PREREQ 'sendemail.transferencoding=7bit fails on 8bit data' test_expect_success $PREREQ '--transfer-encoding overrides sendemail.transferEncoding' ' clean_fake_sendmail && - git config sendemail.transferEncoding 8bit + git config sendemail.transferEncoding 8bit && test_must_fail git send-email \ --transfer-encoding=7bit \ --smtp-server="$(pwd)/fake.sendmail" \ diff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh index 13b179e721..83f17e13e8 100755 --- a/t/t9104-git-svn-follow-parent.sh +++ b/t/t9104-git-svn-follow-parent.sh @@ -72,16 +72,18 @@ test_expect_success 'follow larger parent' ' svn import -m "import a larger parent" import "$svnrepo"/larger-parent && svn cp -m "hi" "$svnrepo"/larger-parent "$svnrepo"/another-larger && git svn init --minimize-url -i larger \ - "$svnrepo"/another-larger/trunk/thunk/bump/thud && + "$svnrepo"/larger-parent/trunk/thunk/bump/thud && git svn fetch -i larger && + git svn init --minimize-url -i larger-parent \ + "$svnrepo"/another-larger/trunk/thunk/bump/thud && + git svn fetch -i larger-parent && git rev-parse --verify refs/remotes/larger && git rev-parse --verify \ - refs/remotes/larger-parent/trunk/thunk/bump/thud && + refs/remotes/larger-parent && test "`git merge-base \ - refs/remotes/larger-parent/trunk/thunk/bump/thud \ + refs/remotes/larger-parent \ refs/remotes/larger`" = \ "`git rev-parse refs/remotes/larger`" - true ' test_expect_success 'follow higher-level parent' ' diff --git a/t/t9158-git-svn-mergeinfo.sh b/t/t9158-git-svn-mergeinfo.sh index 8c9539e1b4..13f78f2682 100755 --- a/t/t9158-git-svn-mergeinfo.sh +++ b/t/t9158-git-svn-mergeinfo.sh @@ -34,7 +34,7 @@ test_expect_success 'change svn:mergeinfo' ' ' test_expect_success 'verify svn:mergeinfo' ' - mergeinfo=$(svn_cmd propget svn:mergeinfo "$svnrepo"/trunk) + mergeinfo=$(svn_cmd propget svn:mergeinfo "$svnrepo"/trunk) && test "$mergeinfo" = "/branches/foo:1-10" ' @@ -46,7 +46,7 @@ test_expect_success 'change svn:mergeinfo multiline' ' ' test_expect_success 'verify svn:mergeinfo multiline' ' - mergeinfo=$(svn_cmd propget svn:mergeinfo "$svnrepo"/trunk) + mergeinfo=$(svn_cmd propget svn:mergeinfo "$svnrepo"/trunk) && test "$mergeinfo" = "/branches/bar:1-10 /branches/other:3-5,8,10-11" ' diff --git a/t/t9161-git-svn-mergeinfo-push.sh b/t/t9161-git-svn-mergeinfo-push.sh index 6cb0909afe..f113acaa6c 100755 --- a/t/t9161-git-svn-mergeinfo-push.sh +++ b/t/t9161-git-svn-mergeinfo-push.sh @@ -24,7 +24,7 @@ test_expect_success 'propagate merge information' ' ' test_expect_success 'check svn:mergeinfo' ' - mergeinfo=$(svn_cmd propget svn:mergeinfo "$svnrepo"/branches/svnb1) + mergeinfo=$(svn_cmd propget svn:mergeinfo "$svnrepo"/branches/svnb1) && test "$mergeinfo" = "/branches/svnb2:3,8" ' @@ -34,7 +34,7 @@ test_expect_success 'merge another branch' ' ' test_expect_success 'check primary parent mergeinfo respected' ' - mergeinfo=$(svn_cmd propget svn:mergeinfo "$svnrepo"/branches/svnb1) + mergeinfo=$(svn_cmd propget svn:mergeinfo "$svnrepo"/branches/svnb1) && test "$mergeinfo" = "/branches/svnb2:3,8 /branches/svnb3:4,9" ' @@ -45,7 +45,7 @@ test_expect_success 'merge existing merge' ' ' test_expect_success "check both parents' mergeinfo respected" ' - mergeinfo=$(svn_cmd propget svn:mergeinfo "$svnrepo"/branches/svnb1) + mergeinfo=$(svn_cmd propget svn:mergeinfo "$svnrepo"/branches/svnb1) && test "$mergeinfo" = "/branches/svnb2:3,8 /branches/svnb3:4,9 /branches/svnb4:5-6,10-12 @@ -70,7 +70,7 @@ test_expect_success 'second forward merge' ' ' test_expect_success 'check new mergeinfo added' ' - mergeinfo=$(svn_cmd propget svn:mergeinfo "$svnrepo"/branches/svnb1) + mergeinfo=$(svn_cmd propget svn:mergeinfo "$svnrepo"/branches/svnb1) && test "$mergeinfo" = "/branches/svnb2:3,8,16-17 /branches/svnb3:4,9 /branches/svnb4:5-6,10-12 @@ -84,7 +84,7 @@ test_expect_success 'reintegration merge' ' ' test_expect_success 'check reintegration mergeinfo' ' - mergeinfo=$(svn_cmd propget svn:mergeinfo "$svnrepo"/branches/svnb4) + mergeinfo=$(svn_cmd propget svn:mergeinfo "$svnrepo"/branches/svnb4) && test "$mergeinfo" = "/branches/svnb1:2-4,7-9,13-18 /branches/svnb2:3,8,16-17 /branches/svnb3:4,9 diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index c538e0a4e9..aac126fd57 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -1132,7 +1132,7 @@ test_expect_success \ compare_diff_raw expect actual' test_expect_success PIPE 'N: read and copy directory' ' - cat >expect <<-\EOF + cat >expect <<-\EOF && :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf EOF @@ -2228,7 +2228,7 @@ test_expect_success 'R: feature import-marks-if-exists' ' >expect && git fast-import --import-marks-if-exists=not_io.marks \ - --export-marks=io.marks <<-\EOF + --export-marks=io.marks <<-\EOF && feature import-marks-if-exists=io.marks EOF test_cmp expect io.marks @@ -2853,8 +2853,8 @@ test_expect_success 'S: notemodify with garbage after mark commit-ish must fail' # from # test_expect_success 'S: from with garbage after mark must fail' ' - # no && - git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err + test_must_fail \ + git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err && commit refs/heads/S2 mark :303 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE @@ -2865,9 +2865,6 @@ test_expect_success 'S: from with garbage after mark must fail' ' M 100644 :403 hello.c EOF - ret=$? && - echo returned $ret && - test $ret -ne 0 && # failed, but it created the commit # go create the commit, need it for merge test git fast-import --import-marks=marks --export-marks=marks <<-EOF && diff --git a/t/t9402-git-cvsserver-refs.sh b/t/t9402-git-cvsserver-refs.sh index 1e266effff..d00df08731 100755 --- a/t/t9402-git-cvsserver-refs.sh +++ b/t/t9402-git-cvsserver-refs.sh @@ -496,7 +496,7 @@ test_expect_success 'check [cvswork3] diff' ' ' test_expect_success 'merge early [cvswork3] b3 with b1' ' - ( cd gitwork3 && git merge "message" HEAD b1 ) && + ( cd gitwork3 && git merge -m "message" b1 ) && git fetch gitwork3 b3:b3 && git tag v3merged b3 && git push --tags gitcvs.git b3:b3 diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh index e74b9ab1e1..e94b2f147a 100755 --- a/t/t9500-gitweb-standalone-no-errors.sh +++ b/t/t9500-gitweb-standalone-no-errors.sh @@ -297,7 +297,7 @@ test_expect_success 'setup incomplete lines' ' echo "Dominus regit me," >file && echo "incomplete line" | tr -d "\\012" >>file && git commit -a -m "Change incomplete line" && - git tag incomplete_lines_chg + git tag incomplete_lines_chg && echo "Dominus regit me," >file && git commit -a -m "Remove incomplete line" && git tag incomplete_lines_rem @@ -779,7 +779,10 @@ test_expect_success \ test_expect_success \ 'unborn HEAD: "summary" page (with "heads" subview)' \ - 'git checkout orphan_branch || git checkout --orphan orphan_branch && + '{ + git checkout orphan_branch || + git checkout --orphan orphan_branch + } && test_when_finished "git checkout master" && gitweb_run "p=.git;a=summary"' diff --git a/t/t9502-gitweb-standalone-parse-output.sh b/t/t9502-gitweb-standalone-parse-output.sh index 86dfee2e4f..0796a438bc 100755 --- a/t/t9502-gitweb-standalone-parse-output.sh +++ b/t/t9502-gitweb-standalone-parse-output.sh @@ -145,9 +145,11 @@ test_expect_success 'forks: not skipped unless "forks" feature enabled' ' grep -q ">fork of .*<" gitweb.body ' -cat >>gitweb_config.perl <<\EOF && -$feature{'forks'}{'default'} = [1]; -EOF +test_expect_success 'enable forks feature' ' + cat >>gitweb_config.perl <<-\EOF + $feature{"forks"}{"default"} = [1]; + EOF +' test_expect_success 'forks: forks skipped if "forks" feature enabled' ' gitweb_run "a=project_list" && @@ -173,7 +175,7 @@ test_expect_success 'forks: can access forked repository' ' ' test_expect_success 'forks: project_index lists all projects (incl. forks)' ' - cat >expected <<-\EOF + cat >expected <<-\EOF && .git foo.bar.git foo.git diff --git a/t/t9801-git-p4-branch.sh b/t/t9801-git-p4-branch.sh index 2bf142d09c..0aafd03334 100755 --- a/t/t9801-git-p4-branch.sh +++ b/t/t9801-git-p4-branch.sh @@ -504,6 +504,112 @@ test_expect_success 'use-client-spec detect-branches skips files in branches' ' ) ' +test_expect_success 'restart p4d' ' + kill_p4d && + start_p4d +' + +# +# 1: //depot/branch1/base/file1 +# //depot/branch1/base/file2 +# //depot/branch1/base/dir/sub_file1 +# 2: integrate //depot/branch1/base/... -> //depot/branch2/base/... +# 3: //depot/branch1/base/file3 +# 4: //depot/branch1/base/file2 (edit) +# 5: integrate //depot/branch1/base/... -> //depot/branch3/base/... +# +# Note: the client view removes the "base" folder from the workspace +# and moves sub_file1 one level up. +test_expect_success 'add simple p4 branches with common base folder on each branch' ' + ( + cd "$cli" && + client_view "//depot/branch1/base/... //client/branch1/..." \ + "//depot/branch1/base/dir/sub_file1 //client/branch1/sub_file1" \ + "//depot/branch2/base/... //client/branch2/..." \ + "//depot/branch3/base/... //client/branch3/..." && + mkdir -p branch1 && + cd branch1 && + echo file1 >file1 && + echo file2 >file2 && + mkdir dir && + echo sub_file1 >sub_file1 && + p4 add file1 file2 sub_file1 && + p4 submit -d "Create branch1" && + p4 integrate //depot/branch1/base/... //depot/branch2/base/... && + p4 submit -d "Integrate branch2 from branch1" && + echo file3 >file3 && + p4 add file3 && + p4 submit -d "add file3 in branch1" && + p4 open file2 && + echo update >>file2 && + p4 submit -d "update file2 in branch1" && + p4 integrate //depot/branch1/base/... //depot/branch3/base/... && + p4 submit -d "Integrate branch3 from branch1" + ) +' + +# Configure branches through git-config and clone them. +# All files are tested to make sure branches were cloned correctly. +# Finally, make an update to branch1 on P4 side to check if it is imported +# correctly by git p4. +# git p4 is expected to use the client view to also not include the common +# "base" folder in the imported directory structure. +test_expect_success 'git p4 clone simple branches with base folder on server side' ' + test_create_repo "$git" && + ( + cd "$git" && + git config git-p4.branchList branch1:branch2 && + git config --add git-p4.branchList branch1:branch3 && + git p4 clone --dest=. --use-client-spec --detect-branches //depot@all && + git log --all --graph --decorate --stat && + git reset --hard p4/depot/branch1 && + test -f file1 && + test -f file2 && + test -f file3 && + test -f sub_file1 && + grep update file2 && + git reset --hard p4/depot/branch2 && + test -f file1 && + test -f file2 && + test ! -f file3 && + test -f sub_file1 && + ! grep update file2 && + git reset --hard p4/depot/branch3 && + test -f file1 && + test -f file2 && + test -f file3 && + test -f sub_file1 && + grep update file2 && + cd "$cli" && + cd branch1 && + p4 edit file2 && + echo file2_ >>file2 && + p4 submit -d "update file2 in branch1" && + cd "$git" && + git reset --hard p4/depot/branch1 && + git p4 rebase && + grep file2_ file2 + ) +' + +# Now update a file in one of the branches in git and submit to P4 +test_expect_success 'Update a file in git side and submit to P4 using client view' ' + test_when_finished cleanup_git && + ( + cd "$git" && + git reset --hard p4/depot/branch1 && + echo "client spec" >> file1 && + git add -u . && + git commit -m "update file1 in branch1" && + git config git-p4.skipSubmitEdit true && + git p4 submit --verbose && + cd "$cli" && + p4 sync ... && + cd branch1 && + grep "client spec" file1 + ) +' + test_expect_success 'kill p4d' ' kill_p4d ' diff --git a/t/t9814-git-p4-rename.sh b/t/t9814-git-p4-rename.sh index 95f4421f71..c89992cf95 100755 --- a/t/t9814-git-p4-rename.sh +++ b/t/t9814-git-p4-rename.sh @@ -132,6 +132,9 @@ test_expect_success 'detect copies' ' cd "$git" && git config git-p4.skipSubmitEdit true && + echo "file8" >>file2 && + git commit -a -m "Differentiate file2" && + git p4 submit && cp file2 file8 && git add file8 && git commit -a -m "Copy file2 to file8" && @@ -140,6 +143,10 @@ test_expect_success 'detect copies' ' p4 filelog //depot/file8 && p4 filelog //depot/file8 | test_must_fail grep -q "branch from" && + echo "file9" >>file2 && + git commit -a -m "Differentiate file2" && + git p4 submit && + cp file2 file9 && git add file9 && git commit -a -m "Copy file2 to file9" && @@ -149,25 +156,39 @@ test_expect_success 'detect copies' ' p4 filelog //depot/file9 && p4 filelog //depot/file9 | test_must_fail grep -q "branch from" && + echo "file10" >>file2 && + git commit -a -m "Differentiate file2" && + git p4 submit && + echo "file2" >>file2 && cp file2 file10 && git add file2 file10 && git commit -a -m "Modify and copy file2 to file10" && git diff-tree -r -C HEAD && + src=$(git diff-tree -r -C HEAD | sed 1d | sed 2d | cut -f2) && + test "$src" = file2 && git p4 submit && p4 filelog //depot/file10 && - p4 filelog //depot/file10 | grep -q "branch from //depot/file" && + p4 filelog //depot/file10 | grep -q "branch from //depot/file2" && + + echo "file11" >>file2 && + git commit -a -m "Differentiate file2" && + git p4 submit && cp file2 file11 && git add file11 && git commit -a -m "Copy file2 to file11" && git diff-tree -r -C --find-copies-harder HEAD && src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) && - test "$src" = file10 && + test "$src" = file2 && git config git-p4.detectCopiesHarder true && git p4 submit && p4 filelog //depot/file11 && - p4 filelog //depot/file11 | grep -q "branch from //depot/file" && + p4 filelog //depot/file11 | grep -q "branch from //depot/file2" && + + echo "file12" >>file2 && + git commit -a -m "Differentiate file2" && + git p4 submit && cp file2 file12 && echo "some text" >>file12 && @@ -177,15 +198,16 @@ test_expect_success 'detect copies' ' level=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/C0*//") && test -n "$level" && test "$level" -gt 0 && test "$level" -lt 98 && src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) && - case "$src" in - file10 | file11) : ;; # happy - *) false ;; # not - && + test "$src" = file2 && git config git-p4.detectCopies $(($level + 2)) && git p4 submit && p4 filelog //depot/file12 && p4 filelog //depot/file12 | test_must_fail grep -q "branch from" && + echo "file13" >>file2 && + git commit -a -m "Differentiate file2" && + git p4 submit && + cp file2 file13 && echo "different text" >>file13 && git add file13 && @@ -194,27 +216,19 @@ test_expect_success 'detect copies' ' level=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/C0*//") && test -n "$level" && test "$level" -gt 2 && test "$level" -lt 100 && src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) && - case "$src" in - file10 | file11 | file12) : ;; # happy - *) false ;; # not - && + test "$src" = file2 && git config git-p4.detectCopies $(($level - 2)) && git p4 submit && p4 filelog //depot/file13 && - p4 filelog //depot/file13 | grep -q "branch from //depot/file" + p4 filelog //depot/file13 | grep -q "branch from //depot/file2" ) ' # See if configurables can be set, and in particular if the run.move.allow # variable exists, which allows admins to disable the "p4 move" command. -test_expect_success 'p4 configure command and run.move.allow are available' ' - p4 configure show run.move.allow >out ; retval=$? && - test $retval = 0 && - { - egrep ^run.move.allow: out && - test_set_prereq P4D_HAVE_CONFIGURABLE_RUN_MOVE_ALLOW || - true - } || true +test_lazy_prereq P4D_HAVE_CONFIGURABLE_RUN_MOVE_ALLOW ' + p4 configure show run.move.allow >out && + egrep ^run.move.allow: out ' # If move can be disabled, turn it off and test p4 move handling diff --git a/t/t9816-git-p4-locked.sh b/t/t9816-git-p4-locked.sh index e71e543343..d048bd33fa 100755 --- a/t/t9816-git-p4-locked.sh +++ b/t/t9816-git-p4-locked.sh @@ -35,13 +35,13 @@ test_expect_success 'edit with lock not taken' ' ) ' -test_expect_failure 'add with lock not taken' ' +test_expect_success 'add with lock not taken' ' test_when_finished cleanup_git && git p4 clone --dest="$git" //depot && ( cd "$git" && echo line1 >>add-lock-not-taken && - git add file2 && + git add add-lock-not-taken && git commit -m "add add-lock-not-taken" && git config git-p4.skipSubmitEdit true && git p4 submit --verbose @@ -107,7 +107,7 @@ test_expect_failure 'chmod with lock taken' ' ) ' -test_expect_failure 'copy with lock taken' ' +test_expect_success 'copy with lock taken' ' lock_in_another_client && test_when_finished cleanup_git && test_when_finished "cd \"$cli\" && p4 revert file2 && rm -f file2" && @@ -130,8 +130,8 @@ test_expect_failure 'move with lock taken' ' git p4 clone --dest="$git" //depot && ( cd "$git" && - git mv file1 file2 && - git commit -m "mv file1 to file2" && + git mv file1 file3 && + git commit -m "mv file1 to file3" && git config git-p4.skipSubmitEdit true && git config git-p4.detectRenames true && git p4 submit --verbose diff --git a/t/t9817-git-p4-exclude.sh b/t/t9817-git-p4-exclude.sh new file mode 100755 index 0000000000..aac568eadf --- /dev/null +++ b/t/t9817-git-p4-exclude.sh @@ -0,0 +1,71 @@ +#!/bin/sh + +test_description='git p4 tests for excluded paths during clone and sync' + +. ./lib-git-p4.sh + +test_expect_success 'start p4d' ' + start_p4d +' + +# Create a repo with the structure: +# +# //depot/wanted/foo +# //depot/discard/foo +# +# Check that we can exclude a subdirectory with both +# clone and sync operations. + +test_expect_success 'create exclude repo' ' + ( + cd "$cli" && + mkdir -p wanted discard && + echo wanted >wanted/foo && + echo discard >discard/foo && + p4 add wanted/foo discard/foo && + p4 submit -d "initial revision" + ) +' + +test_expect_success 'check the repo was created correctly' ' + test_when_finished cleanup_git && + git p4 clone --dest="$git" //depot/...@all && + ( + cd "$git" && + test_path_is_file wanted/foo && + test_path_is_file discard/foo + ) +' + +test_expect_success 'clone, excluding part of repo' ' + test_when_finished cleanup_git && + git p4 clone -//depot/discard/... --dest="$git" //depot/...@all && + ( + cd "$git" && + test_path_is_file wanted/foo && + test_path_is_missing discard/foo + ) +' + +test_expect_success 'clone, then sync with exclude' ' + test_when_finished cleanup_git && + git p4 clone -//depot/discard/... --dest="$git" //depot/...@all && + ( + cd "$cli" && + p4 edit wanted/foo discard/foo && + date >>wanted/foo && + date >>discard/foo && + p4 submit -d "updating" && + + cd "$git" && + git p4 sync -//depot/discard/... && + test_path_is_file wanted/foo && + test_path_is_missing discard/foo + ) +' + +test_expect_success 'kill p4d' ' + kill_p4d +' + +test_done diff --git a/t/t9818-git-p4-block.sh b/t/t9818-git-p4-block.sh new file mode 100755 index 0000000000..153b20afbd --- /dev/null +++ b/t/t9818-git-p4-block.sh @@ -0,0 +1,64 @@ +#!/bin/sh + +test_description='git p4 fetching changes in multiple blocks' + +. ./lib-git-p4.sh + +test_expect_success 'start p4d' ' + start_p4d +' + +test_expect_success 'Create a repo with ~100 changes' ' + ( + cd "$cli" && + >file.txt && + p4 add file.txt && + p4 submit -d "Add file.txt" && + for i in $(test_seq 0 9) + do + >outer$i.txt && + p4 add outer$i.txt && + p4 submit -d "Adding outer$i.txt" && + for j in $(test_seq 0 9) + do + p4 edit file.txt && + echo $i$j >file.txt && + p4 submit -d "Commit $i$j" || exit + done || exit + done + ) +' + +test_expect_success 'Clone the repo' ' + git p4 clone --dest="$git" --changes-block-size=10 --verbose //depot@all +' + +test_expect_success 'All files are present' ' + echo file.txt >expected && + test_write_lines outer0.txt outer1.txt outer2.txt outer3.txt outer4.txt >>expected && + test_write_lines outer5.txt outer6.txt outer7.txt outer8.txt outer9.txt >>expected && + ls "$git" >current && + test_cmp expected current +' + +test_expect_success 'file.txt is correct' ' + echo 99 >expected && + test_cmp expected "$git/file.txt" +' + +test_expect_success 'Correct number of commits' ' + (cd "$git" && git log --oneline) >log && + test_line_count = 111 log +' + +test_expect_success 'Previous version of file.txt is correct' ' + (cd "$git" && git checkout HEAD^^) && + echo 97 >expected && + test_cmp expected "$git/file.txt" +' + +test_expect_success 'kill p4d' ' + kill_p4d +' + +test_done diff --git a/t/t9819-git-p4-case-folding.sh b/t/t9819-git-p4-case-folding.sh new file mode 100755 index 0000000000..78f1d0f92d --- /dev/null +++ b/t/t9819-git-p4-case-folding.sh @@ -0,0 +1,54 @@ +#!/bin/sh + +test_description='interaction with P4 case-folding' + +. ./lib-git-p4.sh + +test_expect_success 'start p4d with case folding enabled' ' + start_p4d -C1 +' + +test_expect_success 'Create a repo, name is lowercase' ' + ( + client_view "//depot/... //client/..." && + cd "$cli" && + mkdir -p lc UC && + >lc/file.txt && >UC/file.txt && + p4 add lc/file.txt UC/file.txt && + p4 submit -d "Add initial lc and UC repos" + ) +' + +test_expect_success 'Check p4 is in case-folding mode' ' + ( + cd "$cli" && + >lc/FILE.TXT && + p4 add lc/FILE.TXT && + test_must_fail p4 submit -d "Cannot add file differing only in case" lc/FILE.TXT + ) +' + +# Check we created the repo properly +test_expect_success 'Clone lc repo using lc name' ' + git p4 clone //depot/lc/... && + test_path_is_file lc/file.txt && + git p4 clone //depot/UC/... && + test_path_is_file UC/file.txt +' + +# The clone should fail, since there is no repo called LC, but because +# we have case-insensitive p4d enabled, it appears to go ahead and work, +# but leaves an empty git repo in place. +test_expect_failure 'Clone lc repo using uc name' ' + test_must_fail git p4 clone //depot/LC/... +' + +test_expect_failure 'Clone UC repo with lc name' ' + test_must_fail git p4 clone //depot/uc/... +' + +test_expect_success 'kill p4d' ' + kill_p4d +' + +test_done diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 7a883d1a67..4a14a5892e 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -568,7 +568,7 @@ test_expect_success 'complete files' ' test_completion "git commit " "modified" && : TODO .gitignore should not be here && - test_completion "git ls-files " <<-\EOF + test_completion "git ls-files " <<-\EOF && .gitignore dir modified diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh index 46d7d37a51..49d58e6726 100755 --- a/t/t9903-bash-prompt.sh +++ b/t/t9903-bash-prompt.sh @@ -166,7 +166,7 @@ test_expect_success 'prompt - inside bare repository' ' ' test_expect_success 'prompt - interactive rebase' ' - printf " (b1|REBASE-i 2/3)" >expected + printf " (b1|REBASE-i 2/3)" >expected && write_script fake_editor.sh <<-\EOF && echo "exec echo" >"$1" echo "edit $(git log -1 --format="%h")" >>"$1" diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 0698ce7908..e8d3c0fdbc 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -348,11 +348,18 @@ test_declared_prereq () { return 1 } +test_verify_prereq () { + test -z "$test_prereq" || + expr >/dev/null "$test_prereq" : '[A-Z0-9_,!]*$' || + error "bug in the test script: '$test_prereq' does not look like a prereq" +} + test_expect_failure () { test_start_ test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq= test "$#" = 2 || error "bug in the test script: not 2 or 3 parameters to test-expect-failure" + test_verify_prereq export test_prereq if ! test_skip "$@" then @@ -372,6 +379,7 @@ test_expect_success () { test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq= test "$#" = 2 || error "bug in the test script: not 2 or 3 parameters to test-expect-success" + test_verify_prereq export test_prereq if ! test_skip "$@" then @@ -400,6 +408,7 @@ test_external () { error >&5 "bug in the test script: not 3 or 4 parameters to test_external" descr="$1" shift + test_verify_prereq export test_prereq if ! test_skip "$descr" "$@" then @@ -478,7 +487,7 @@ test_external_without_stderr () { test_path_is_file () { if ! test -f "$1" then - echo "File $1 doesn't exist. $*" + echo "File $1 doesn't exist. $2" false fi } @@ -486,7 +495,7 @@ test_path_is_file () { test_path_is_dir () { if ! test -d "$1" then - echo "Directory $1 doesn't exist. $*" + echo "Directory $1 doesn't exist. $2" false fi } diff --git a/t/test-lib.sh b/t/test-lib.sh index 9914d3e1cf..39da9c2d99 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -229,6 +229,12 @@ do --root=*) root=$(expr "z$1" : 'z[^=]*=\(.*\)') shift ;; + --chain-lint) + GIT_TEST_CHAIN_LINT=1 + shift ;; + --no-chain-lint) + GIT_TEST_CHAIN_LINT=0 + shift ;; -x) trace=t verbose=t @@ -522,6 +528,16 @@ test_eval_ () { test_run_ () { test_cleanup=: expecting_failure=$2 + + if test "${GIT_TEST_CHAIN_LINT:-1}" != 0; then + # 117 is magic because it is unlikely to match the exit + # code of other programs + test_eval_ "(exit 117) && $1" + if test "$?" != 117; then + error "bug in the test script: broken &&-chain: $1" + fi + fi + setup_malloc_check test_eval_ "$1" eval_ret=$? |