Merge branch 'es/test-chain-lint'

Broken &&-chains in the test scripts have been corrected.

* es/test-chain-lint:
  t6000-t9999: detect and signal failure within loop
  t5000-t5999: detect and signal failure within loop
  t4000-t4999: detect and signal failure within loop
  t0000-t3999: detect and signal failure within loop
  tests: simplify by dropping unnecessary `for` loops
  tests: apply modern idiom for exiting loop upon failure
  tests: apply modern idiom for signaling test failure
  tests: fix broken &&-chains in `{...}` groups
  tests: fix broken &&-chains in `$(...)` command substitutions
  tests: fix broken &&-chains in compound statements
  tests: use test_write_lines() to generate line-oriented output
  tests: simplify construction of large blocks of text
  t9107: use shell parameter expansion to avoid breaking &&-chain
  t6300: make `%(raw:size) --shell` test more robust
  t5516: drop unnecessary subshell and command invocation
  t4202: clarify intent by creating expected content less cleverly
  t1020: avoid aborting entire test script when one test fails
  t1010: fix unnoticed failure on Windows
  t/lib-pager: use sane_unset() to avoid breaking &&-chain
This commit is contained in:
Junio C Hamano 2022-01-03 16:24:15 -08:00
commit 4f4b18497a
163 changed files with 740 additions and 847 deletions

View File

@ -12,7 +12,7 @@ test_expect_success 'creating page w/ >500 revisions' '
for i in $(test_seq 501) for i in $(test_seq 501)
do do
echo "creating revision $i" && echo "creating revision $i" &&
wiki_editpage foo "revision $i<br/>" true wiki_editpage foo "revision $i<br/>" true || return 1
done done
' '

View File

@ -1445,7 +1445,7 @@ test_expect_success 'subtree descendant check' '
) && ) &&
test_create_commit "$test_count" folder_subtree/0 && test_create_commit "$test_count" folder_subtree/0 &&
test_create_commit "$test_count" folder_subtree/b && test_create_commit "$test_count" folder_subtree/b &&
cherry=$(cd "$test_count"; git rev-parse HEAD) && cherry=$(cd "$test_count" && git rev-parse HEAD) &&
( (
cd "$test_count" && cd "$test_count" &&
git checkout branch git checkout branch

View File

@ -161,7 +161,7 @@ test_expect_success 'blame huge graft' '
GIT_AUTHOR_NAME=$i$j GIT_AUTHOR_EMAIL=$i$j@test.git \ GIT_AUTHOR_NAME=$i$j GIT_AUTHOR_EMAIL=$i$j@test.git \
git commit -a -m "$i$j" && git commit -a -m "$i$j" &&
commit=$(git rev-parse --verify HEAD) && commit=$(git rev-parse --verify HEAD) &&
graft="$graft$commit " graft="$graft$commit " || return 1
done done
done && done &&
printf "%s " $graft >.git/info/grafts && printf "%s " $graft >.git/info/grafts &&

View File

@ -3,7 +3,7 @@
test_expect_success 'determine default pager' ' test_expect_success 'determine default pager' '
test_might_fail git config --unset core.pager && test_might_fail git config --unset core.pager &&
less=$( less=$(
unset PAGER GIT_PAGER; sane_unset PAGER GIT_PAGER &&
git var GIT_PAGER git var GIT_PAGER
) && ) &&
test -n "$less" test -n "$less"

View File

@ -24,17 +24,17 @@ test_perf_default_repo
test_expect_success "setup repo" ' test_expect_success "setup repo" '
if git rev-parse --verify refs/heads/p0006-ballast^{commit} if git rev-parse --verify refs/heads/p0006-ballast^{commit}
then then
echo Assuming synthetic repo from many-files.sh echo Assuming synthetic repo from many-files.sh &&
git branch br_base master git branch br_base master &&
git branch br_ballast p0006-ballast git branch br_ballast p0006-ballast &&
git config --local core.sparsecheckout 1 git config --local core.sparsecheckout 1 &&
cat >.git/info/sparse-checkout <<-EOF cat >.git/info/sparse-checkout <<-EOF
/* /*
!ballast/* !ballast/*
EOF EOF
else else
echo Assuming non-synthetic repo... echo Assuming non-synthetic repo... &&
git branch br_base $(git rev-list HEAD | tail -n 1) git branch br_base $(git rev-list HEAD | tail -n 1) &&
git branch br_ballast HEAD git branch br_ballast HEAD
fi && fi &&
git checkout -q br_ballast && git checkout -q br_ballast &&

View File

@ -24,21 +24,21 @@ test_perf_default_repo
test_expect_success "setup repo" ' test_expect_success "setup repo" '
if git rev-parse --verify refs/heads/p0006-ballast^{commit} if git rev-parse --verify refs/heads/p0006-ballast^{commit}
then then
echo Assuming synthetic repo from many-files.sh echo Assuming synthetic repo from many-files.sh &&
git branch br_base master git branch br_base master &&
git branch br_ballast p0006-ballast^ git branch br_ballast p0006-ballast^ &&
git branch br_ballast_alias p0006-ballast^ git branch br_ballast_alias p0006-ballast^ &&
git branch br_ballast_plus_1 p0006-ballast git branch br_ballast_plus_1 p0006-ballast &&
git config --local core.sparsecheckout 1 git config --local core.sparsecheckout 1 &&
cat >.git/info/sparse-checkout <<-EOF cat >.git/info/sparse-checkout <<-EOF
/* /*
!ballast/* !ballast/*
EOF EOF
else else
echo Assuming non-synthetic repo... echo Assuming non-synthetic repo... &&
git branch br_base $(git rev-list HEAD | tail -n 1) git branch br_base $(git rev-list HEAD | tail -n 1) &&
git branch br_ballast HEAD^ || error "no ancestor commit from current head" git branch br_ballast HEAD^ || error "no ancestor commit from current head" &&
git branch br_ballast_alias HEAD^ git branch br_ballast_alias HEAD^ &&
git branch br_ballast_plus_1 HEAD git branch br_ballast_plus_1 HEAD
fi && fi &&
git checkout -q br_ballast && git checkout -q br_ballast &&

View File

@ -9,8 +9,8 @@ test_perf_default_repo
test_expect_success "setup repo" ' test_expect_success "setup repo" '
if git rev-parse --verify refs/heads/p0006-ballast^{commit} if git rev-parse --verify refs/heads/p0006-ballast^{commit}
then then
echo Assuming synthetic repo from many-files.sh echo Assuming synthetic repo from many-files.sh &&
git config --local core.sparsecheckout 1 git config --local core.sparsecheckout 1 &&
cat >.git/info/sparse-checkout <<-EOF cat >.git/info/sparse-checkout <<-EOF
/* /*
!ballast/* !ballast/*

View File

@ -19,9 +19,9 @@ test_expect_success 'setup' '
printf "a" >>refname && printf "a" >>refname &&
for j in $(test_seq 1 $i) for j in $(test_seq 1 $i)
do do
printf "a*" >>refglob.$i printf "a*" >>refglob.$i || return 1
done && done &&
echo b >>refglob.$i echo b >>refglob.$i || return 1
done && done &&
test_commit test $(cat refname).t "" $(cat refname).t test_commit test $(cat refname).t "" $(cat refname).t
' '

View File

@ -13,7 +13,7 @@ test_expect_success "setup" '
do do
printf "start\ncreate refs/heads/%d PRE\ncommit\n" $i && printf "start\ncreate refs/heads/%d PRE\ncommit\n" $i &&
printf "start\nupdate refs/heads/%d POST PRE\ncommit\n" $i && printf "start\nupdate refs/heads/%d POST PRE\ncommit\n" $i &&
printf "start\ndelete refs/heads/%d POST\ncommit\n" $i printf "start\ndelete refs/heads/%d POST\ncommit\n" $i || return 1
done >instructions done >instructions
' '
@ -22,7 +22,7 @@ test_perf "update-ref" '
do do
git update-ref refs/heads/branch PRE && git update-ref refs/heads/branch PRE &&
git update-ref refs/heads/branch POST PRE && git update-ref refs/heads/branch POST PRE &&
git update-ref -d refs/heads/branch git update-ref -d refs/heads/branch || return 1
done done
' '

View File

@ -15,7 +15,7 @@ test_expect_success "setup $n bad commits" '
echo "committer C <c@example.com> 1234567890 +0000" && echo "committer C <c@example.com> 1234567890 +0000" &&
echo "data <<EOF" && echo "data <<EOF" &&
echo "$i.Q." && echo "$i.Q." &&
echo "EOF" echo "EOF" || return 1
done | q_to_nul | git fast-import done | q_to_nul | git fast-import
' '

View File

@ -22,7 +22,7 @@ test_expect_success 'setup rebasing on top of a lot of changes' '
git add unrelated-file$i && git add unrelated-file$i &&
test_tick && test_tick &&
git commit -m commit$i-reverse unrelated-file$i || git commit -m commit$i-reverse unrelated-file$i ||
break return 1
done && done &&
git checkout to-rebase && git checkout to-rebase &&
test_commit our-patch interesting-file test_commit our-patch interesting-file

View File

@ -21,8 +21,8 @@ test_expect_success 'set up thread-counting tests' '
threads= && threads= &&
while test $t -gt 0 while test $t -gt 0
do do
threads="$t $threads" threads="$t $threads" &&
t=$((t / 2)) t=$((t / 2)) || return 1
done done
' '

View File

@ -126,11 +126,11 @@ done
# Measure pack loading with 10,000 packs. # Measure pack loading with 10,000 packs.
test_expect_success 'generate lots of packs' ' test_expect_success 'generate lots of packs' '
for i in $(test_seq 10000); do for i in $(test_seq 10000); do
echo "blob" echo "blob" &&
echo "data <<EOF" echo "data <<EOF" &&
echo "blob $i" echo "blob $i" &&
echo "EOF" echo "EOF" &&
echo "checkpoint" echo "checkpoint" || return 1
done | done |
git -c fastimport.unpackLimit=0 fast-import git -c fastimport.unpackLimit=0 fast-import
' '

View File

@ -119,10 +119,10 @@ test_expect_success "one time repo setup" '
fi && fi &&
mkdir 1_file 10_files 100_files 1000_files 10000_files && mkdir 1_file 10_files 100_files 1000_files 10000_files &&
for i in $(test_seq 1 10); do touch 10_files/$i; done && for i in $(test_seq 1 10); do touch 10_files/$i || return 1; done &&
for i in $(test_seq 1 100); do touch 100_files/$i; done && for i in $(test_seq 1 100); do touch 100_files/$i || return 1; done &&
for i in $(test_seq 1 1000); do touch 1000_files/$i; done && for i in $(test_seq 1 1000); do touch 1000_files/$i || return 1; done &&
for i in $(test_seq 1 10000); do touch 10000_files/$i; done && for i in $(test_seq 1 10000); do touch 10000_files/$i || return 1; done &&
git add 1_file 10_files 100_files 1000_files 10000_files && git add 1_file 10_files 100_files 1000_files 10000_files &&
git commit -qm "Add files" && git commit -qm "Add files" &&

View File

@ -48,7 +48,7 @@ test_expect_success !MINGW 'a constipated git dies with SIGPIPE' '
' '
test_expect_success !MINGW 'a constipated git dies with SIGPIPE even if parent ignores it' ' 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_match_signal 13 "$OUT" test_match_signal 13 "$OUT"
' '

View File

@ -200,7 +200,7 @@ test_expect_success 'setup' '
do do
: >$dir/not-ignored && : >$dir/not-ignored &&
: >$dir/ignored-and-untracked && : >$dir/ignored-and-untracked &&
: >$dir/ignored-but-in-index : >$dir/ignored-but-in-index || return 1
done && done &&
git add -f ignored-but-in-index a/ignored-but-in-index && git add -f ignored-but-in-index a/ignored-but-in-index &&
cat <<-\EOF >a/.gitignore && cat <<-\EOF >a/.gitignore &&

View File

@ -220,7 +220,7 @@ test_expect_success 'grow / shrink' '
for n in $(test_seq 51) for n in $(test_seq 51)
do do
echo put key$n value$n >> in && echo put key$n value$n >> in &&
echo NULL >> expect echo NULL >> expect || return 1
done && done &&
echo size >> in && echo size >> in &&
echo 64 51 >> expect && echo 64 51 >> expect &&
@ -231,7 +231,7 @@ test_expect_success 'grow / shrink' '
for n in $(test_seq 12) for n in $(test_seq 12)
do do
echo remove key$n >> in && echo remove key$n >> in &&
echo value$n >> expect echo value$n >> expect || return 1
done && done &&
echo size >> in && echo size >> in &&
echo 256 40 >> expect && echo 256 40 >> expect &&

View File

@ -23,10 +23,10 @@ test_expect_success setup '
git config core.autocrlf false && git config core.autocrlf false &&
for w in Hello world how are you; do echo $w; done >one && test_write_lines Hello world how are you >one &&
mkdir dir && mkdir dir &&
for w in I am very very fine thank you; do echo $w; done >dir/two && test_write_lines I am very very fine thank you >dir/two &&
for w in Oh here is NULQin text here; do echo $w; done | q_to_nul >three && test_write_lines Oh here is NULQin text here | q_to_nul >three &&
git add . && git add . &&
git commit -m initial && git commit -m initial &&
@ -36,7 +36,7 @@ test_expect_success setup '
two=$(git rev-parse HEAD:dir/two) && two=$(git rev-parse HEAD:dir/two) &&
three=$(git rev-parse HEAD:three) && three=$(git rev-parse HEAD:three) &&
for w in Some extra lines here; do echo $w; done >>one && test_write_lines Some extra lines here >>one &&
git diff >patch.file && git diff >patch.file &&
patched=$(git hash-object --stdin <one) && patched=$(git hash-object --stdin <one) &&
git read-tree --reset -u HEAD git read-tree --reset -u HEAD
@ -47,7 +47,7 @@ test_expect_success 'safecrlf: autocrlf=input, all CRLF' '
git config core.autocrlf input && git config core.autocrlf input &&
git config core.safecrlf true && git config core.safecrlf true &&
for w in I am all CRLF; do echo $w; done | append_cr >allcrlf && test_write_lines I am all CRLF | append_cr >allcrlf &&
test_must_fail git add allcrlf test_must_fail git add allcrlf
' '
@ -56,7 +56,7 @@ test_expect_success 'safecrlf: autocrlf=input, mixed LF/CRLF' '
git config core.autocrlf input && git config core.autocrlf input &&
git config core.safecrlf true && git config core.safecrlf true &&
for w in Oh here is CRLFQ in text; do echo $w; done | q_to_cr >mixed && test_write_lines Oh here is CRLFQ in text | q_to_cr >mixed &&
test_must_fail git add mixed test_must_fail git add mixed
' '
@ -65,7 +65,7 @@ test_expect_success 'safecrlf: autocrlf=true, all LF' '
git config core.autocrlf true && git config core.autocrlf true &&
git config core.safecrlf true && git config core.safecrlf true &&
for w in I am all LF; do echo $w; done >alllf && test_write_lines I am all LF >alllf &&
test_must_fail git add alllf test_must_fail git add alllf
' '
@ -74,7 +74,7 @@ test_expect_success 'safecrlf: autocrlf=true mixed LF/CRLF' '
git config core.autocrlf true && git config core.autocrlf true &&
git config core.safecrlf true && git config core.safecrlf true &&
for w in Oh here is CRLFQ in text; do echo $w; done | q_to_cr >mixed && test_write_lines Oh here is CRLFQ in text | q_to_cr >mixed &&
test_must_fail git add mixed test_must_fail git add mixed
' '
@ -83,10 +83,10 @@ test_expect_success 'safecrlf: print warning only once' '
git config core.autocrlf input && git config core.autocrlf input &&
git config core.safecrlf warn && git config core.safecrlf warn &&
for w in I am all LF; do echo $w; done >doublewarn && test_write_lines I am all LF >doublewarn &&
git add doublewarn && git add doublewarn &&
git commit -m "nowarn" && git commit -m "nowarn" &&
for w in Oh here is CRLFQ in text; do echo $w; done | q_to_cr >doublewarn && test_write_lines Oh here is CRLFQ in text | q_to_cr >doublewarn &&
git add doublewarn 2>err && git add doublewarn 2>err &&
grep "CRLF will be replaced by LF" err >err.warnings && grep "CRLF will be replaced by LF" err >err.warnings &&
test_line_count = 1 err.warnings test_line_count = 1 err.warnings
@ -104,7 +104,7 @@ test_expect_success 'safecrlf: no warning with safecrlf=false' '
git config core.autocrlf input && git config core.autocrlf input &&
git config core.safecrlf false && git config core.safecrlf false &&
for w in I am all CRLF; do echo $w; done | append_cr >allcrlf && test_write_lines I am all CRLF | append_cr >allcrlf &&
git add allcrlf 2>err && git add allcrlf 2>err &&
test_must_be_empty err test_must_be_empty err
' '
@ -352,9 +352,9 @@ test_expect_success 'setting up for new autocrlf tests' '
git config core.autocrlf false && git config core.autocrlf false &&
git config core.safecrlf false && git config core.safecrlf false &&
rm -rf .????* * && rm -rf .????* * &&
for w in I am all LF; do echo $w; done >alllf && test_write_lines I am all LF >alllf &&
for w in Oh here is CRLFQ in text; do echo $w; done | q_to_cr >mixed && test_write_lines Oh here is CRLFQ in text | q_to_cr >mixed &&
for w in I am all CRLF; do echo $w; done | append_cr >allcrlf && test_write_lines I am all CRLF | append_cr >allcrlf &&
git add -A . && git add -A . &&
git commit -m "alllf, allcrlf and mixed only" && git commit -m "alllf, allcrlf and mixed only" &&
git tag -a -m "message" autocrlf-checkpoint git tag -a -m "message" autocrlf-checkpoint

View File

@ -76,13 +76,13 @@ test_expect_success setup '
git config filter.rot13.clean ./rot13.sh && git config filter.rot13.clean ./rot13.sh &&
{ {
echo "*.t filter=rot13" echo "*.t filter=rot13" &&
echo "*.i ident" echo "*.i ident"
} >.gitattributes && } >.gitattributes &&
{ {
echo a b c d e f g h i j k l m echo a b c d e f g h i j k l m &&
echo n o p q r s t u v w x y z echo n o p q r s t u v w x y z &&
echo '\''$Id$'\'' echo '\''$Id$'\''
} >test && } >test &&
cat test >test.t && cat test >test.t &&
@ -118,17 +118,17 @@ test_expect_success check '
# If an expanded ident ever gets into the repository, we want to make sure that # If an expanded ident ever gets into the repository, we want to make sure that
# it is collapsed before being expanded again on checkout # it is collapsed before being expanded again on checkout
test_expect_success expanded_in_repo ' test_expect_success expanded_in_repo '
{ cat >expanded-keywords.0 <<-\EOF &&
echo "File with expanded keywords" File with expanded keywords
echo "\$Id\$" $Id$
echo "\$Id:\$" $Id:$
echo "\$Id: 0000000000000000000000000000000000000000 \$" $Id: 0000000000000000000000000000000000000000 $
echo "\$Id: NoSpaceAtEnd\$" $Id: NoSpaceAtEnd$
echo "\$Id:NoSpaceAtFront \$" $Id:NoSpaceAtFront $
echo "\$Id:NoSpaceAtEitherEnd\$" $Id:NoSpaceAtEitherEnd$
echo "\$Id: NoTerminatingSymbol" $Id: NoTerminatingSymbol
echo "\$Id: Foreign Commit With Spaces \$" $Id: Foreign Commit With Spaces $
} >expanded-keywords.0 && EOF
{ {
cat expanded-keywords.0 && cat expanded-keywords.0 &&
@ -139,17 +139,17 @@ test_expect_success expanded_in_repo '
git commit -m "File with keywords expanded" && git commit -m "File with keywords expanded" &&
id=$(git rev-parse --verify :expanded-keywords) && id=$(git rev-parse --verify :expanded-keywords) &&
{ cat >expected-output.0 <<-EOF &&
echo "File with expanded keywords" File with expanded keywords
echo "\$Id: $id \$" \$Id: $id \$
echo "\$Id: $id \$" \$Id: $id \$
echo "\$Id: $id \$" \$Id: $id \$
echo "\$Id: $id \$" \$Id: $id \$
echo "\$Id: $id \$" \$Id: $id \$
echo "\$Id: $id \$" \$Id: $id \$
echo "\$Id: NoTerminatingSymbol" \$Id: NoTerminatingSymbol
echo "\$Id: Foreign Commit With Spaces \$" \$Id: Foreign Commit With Spaces \$
} >expected-output.0 && EOF
{ {
cat expected-output.0 && cat expected-output.0 &&
printf "\$Id: NoTerminatingSymbolAtEOF" printf "\$Id: NoTerminatingSymbolAtEOF"
@ -159,7 +159,7 @@ test_expect_success expanded_in_repo '
printf "\$Id: NoTerminatingSymbolAtEOF" printf "\$Id: NoTerminatingSymbolAtEOF"
} >expected-output-crlf && } >expected-output-crlf &&
{ {
echo "expanded-keywords ident" echo "expanded-keywords ident" &&
echo "expanded-keywords-crlf ident text eol=crlf" echo "expanded-keywords-crlf ident text eol=crlf"
} >>.gitattributes && } >>.gitattributes &&
@ -285,7 +285,7 @@ test_expect_success 'required filter with absent smudge field' '
test_expect_success 'filtering large input to small output should use little memory' ' test_expect_success 'filtering large input to small output should use little memory' '
test_config filter.devnull.clean "cat >/dev/null" && test_config filter.devnull.clean "cat >/dev/null" &&
test_config filter.devnull.required true && test_config filter.devnull.required true &&
for i in $(test_seq 1 30); do printf "%1048576d" 1; done >30MB && for i in $(test_seq 1 30); do printf "%1048576d" 1 || return 1; done >30MB &&
echo "30MB filter=devnull" >.gitattributes && echo "30MB filter=devnull" >.gitattributes &&
GIT_MMAP_LIMIT=1m GIT_ALLOC_LIMIT=1m git add 30MB GIT_MMAP_LIMIT=1m GIT_ALLOC_LIMIT=1m git add 30MB
' '
@ -303,7 +303,7 @@ test_expect_success 'filter that does not read is fine' '
test_expect_success EXPENSIVE 'filter large file' ' test_expect_success EXPENSIVE 'filter large file' '
test_config filter.largefile.smudge cat && test_config filter.largefile.smudge cat &&
test_config filter.largefile.clean cat && test_config filter.largefile.clean cat &&
for i in $(test_seq 1 2048); do printf "%1048576d" 1; done >2GB && for i in $(test_seq 1 2048); do printf "%1048576d" 1 || return 1; done >2GB &&
echo "2GB filter=largefile" >.gitattributes && echo "2GB filter=largefile" >.gitattributes &&
git add 2GB 2>err && git add 2GB 2>err &&
test_must_be_empty err && test_must_be_empty err &&
@ -643,7 +643,7 @@ test_expect_success PERL 'required process filter should process multiple packet
for FILE in "$TEST_ROOT"/*.file for FILE in "$TEST_ROOT"/*.file
do do
cp "$FILE" . && cp "$FILE" . &&
rot13.sh <"$FILE" >"$FILE.rot13" rot13.sh <"$FILE" >"$FILE.rot13" || return 1
done && done &&
echo "*.file filter=protocol" >.gitattributes && echo "*.file filter=protocol" >.gitattributes &&
@ -682,7 +682,7 @@ test_expect_success PERL 'required process filter should process multiple packet
for FILE in *.file for FILE in *.file
do do
test_cmp_committed_rot13 "$TEST_ROOT/$FILE" $FILE test_cmp_committed_rot13 "$TEST_ROOT/$FILE" $FILE || return 1
done done
) )
' '

View File

@ -15,8 +15,8 @@ test_expect_success setup '
echo "one text" > .gitattributes && echo "one text" > .gitattributes &&
for w in Hello world how are you; do echo $w; done >one && test_write_lines Hello world how are you >one &&
for w in I am very very fine thank you; do echo $w; done >two && test_write_lines I am very very fine thank you >two &&
git add . && git add . &&
git commit -m initial && git commit -m initial &&

View File

@ -216,7 +216,7 @@ test_expect_success SYMLINKS 'real path works on symlinks' '
mkdir second && mkdir second &&
ln -s ../first second/other && ln -s ../first second/other &&
mkdir third && mkdir third &&
dir="$(cd .git; pwd -P)" && dir="$(cd .git && pwd -P)" &&
dir2=third/../second/other/.git && dir2=third/../second/other/.git &&
test "$dir" = "$(test-tool path-utils real_path $dir2)" && test "$dir" = "$(test-tool path-utils real_path $dir2)" &&
file="$dir"/index && file="$dir"/index &&
@ -224,7 +224,7 @@ test_expect_success SYMLINKS 'real path works on symlinks' '
basename=blub && basename=blub &&
test "$dir/$basename" = "$(cd .git && test-tool path-utils real_path "$basename")" && test "$dir/$basename" = "$(cd .git && test-tool path-utils real_path "$basename")" &&
ln -s ../first/file .git/syml && ln -s ../first/file .git/syml &&
sym="$(cd first; pwd -P)"/file && sym="$(cd first && pwd -P)"/file &&
test "$sym" = "$(test-tool path-utils real_path "$dir2/syml")" test "$sym" = "$(test-tool path-utils real_path "$dir2/syml")"
' '

View File

@ -28,7 +28,7 @@ test_expect_success 'oidtree insert and contains' '
EOF EOF
{ {
echoid insert 444 1 2 3 4 5 a b c d e && echoid insert 444 1 2 3 4 5 a b c d e &&
echoid contains 44 441 440 444 4440 4444 echoid contains 44 441 440 444 4440 4444 &&
echo clear echo clear
} | test-tool oidtree >actual && } | test-tool oidtree >actual &&
test_cmp expect actual test_cmp expect actual
@ -37,11 +37,11 @@ test_expect_success 'oidtree insert and contains' '
test_expect_success 'oidtree each' ' test_expect_success 'oidtree each' '
echoid "" 123 321 321 >expect && echoid "" 123 321 321 >expect &&
{ {
echoid insert f 9 8 123 321 a b c d e echoid insert f 9 8 123 321 a b c d e &&
echo each 12300 echo each 12300 &&
echo each 3211 echo each 3211 &&
echo each 3210 echo each 3210 &&
echo each 32100 echo each 32100 &&
echo clear echo clear
} | test-tool oidtree >actual && } | test-tool oidtree >actual &&
test_cmp expect actual test_cmp expect actual

View File

@ -84,7 +84,7 @@ test_expect_success 'get bloom filter for commit with 10 changes' '
mkdir smallDir && mkdir smallDir &&
for i in $(test_seq 0 9) for i in $(test_seq 0 9)
do do
echo $i >smallDir/$i echo $i >smallDir/$i || return 1
done && done &&
git add smallDir && git add smallDir &&
git commit -m "commit with 10 changes" && git commit -m "commit with 10 changes" &&
@ -102,7 +102,7 @@ test_expect_success EXPENSIVE 'get bloom filter for commit with 513 changes' '
mkdir bigDir && mkdir bigDir &&
for i in $(test_seq 0 511) for i in $(test_seq 0 511)
do do
echo $i >bigDir/$i echo $i >bigDir/$i || return 1
done && done &&
git add bigDir && git add bigDir &&
git commit -m "commit with 513 changes" && git commit -m "commit with 513 changes" &&

View File

@ -469,7 +469,7 @@ test_expect_success 'rev-list dies for missing objects on cmd line' '
git -C repo rev-list --ignore-missing --objects \ git -C repo rev-list --ignore-missing --objects \
--exclude-promisor-objects "$OBJ" && --exclude-promisor-objects "$OBJ" &&
git -C repo rev-list --ignore-missing --objects-edge-aggressive \ git -C repo rev-list --ignore-missing --objects-edge-aggressive \
--exclude-promisor-objects "$OBJ" --exclude-promisor-objects "$OBJ" || return 1
done done
' '

View File

@ -211,14 +211,14 @@ done
test_expect_success "--batch-check for a non-existent named object" ' test_expect_success "--batch-check for a non-existent named object" '
test "foobar42 missing test "foobar42 missing
foobar84 missing" = \ foobar84 missing" = \
"$( ( echo foobar42; echo_without_newline foobar84; ) | git cat-file --batch-check)" "$( ( echo foobar42 && echo_without_newline foobar84 ) | git cat-file --batch-check)"
' '
test_expect_success "--batch-check for a non-existent hash" ' test_expect_success "--batch-check for a non-existent hash" '
test "0000000000000000000000000000000000000042 missing test "0000000000000000000000000000000000000042 missing
0000000000000000000000000000000000000084 missing" = \ 0000000000000000000000000000000000000084 missing" = \
"$( ( echo 0000000000000000000000000000000000000042; "$( ( echo 0000000000000000000000000000000000000042 &&
echo_without_newline 0000000000000000000000000000000000000084; ) | echo_without_newline 0000000000000000000000000000000000000084 ) |
git cat-file --batch-check)" git cat-file --batch-check)"
' '
@ -226,8 +226,8 @@ test_expect_success "--batch for an existent and a non-existent hash" '
test "$tag_sha1 tag $tag_size test "$tag_sha1 tag $tag_size
$tag_content $tag_content
0000000000000000000000000000000000000000 missing" = \ 0000000000000000000000000000000000000000 missing" = \
"$( ( echo $tag_sha1; "$( ( echo $tag_sha1 &&
echo_without_newline 0000000000000000000000000000000000000000; ) | echo_without_newline 0000000000000000000000000000000000000000 ) |
git cat-file --batch)" git cat-file --batch)"
' '
@ -283,7 +283,7 @@ test_expect_success "--batch-check with multiple sha1s gives correct format" '
test_expect_success 'setup blobs which are likely to delta' ' test_expect_success 'setup blobs which are likely to delta' '
test-tool genrandom foo 10240 >foo && test-tool genrandom foo 10240 >foo &&
{ cat foo; echo plus; } >foo-plus && { cat foo && echo plus; } >foo-plus &&
git add foo foo-plus && git add foo foo-plus &&
git commit -m foo && git commit -m foo &&
cat >blobs <<-\EOF cat >blobs <<-\EOF

View File

@ -6,10 +6,10 @@ TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh . ./test-lib.sh
test_expect_success setup ' test_expect_success setup '
for d in a a. a0 for d in a a- a0
do do
mkdir "$d" && echo "$d/one" >"$d/one" && mkdir "$d" && echo "$d/one" >"$d/one" &&
git add "$d" git add "$d" || return 1
done && done &&
echo zero >one && echo zero >one &&
git update-index --add --info-only one && git update-index --add --info-only one &&

View File

@ -11,9 +11,9 @@ test_description='Try various core-level commands in subdirectory.
test_expect_success setup ' test_expect_success setup '
long="a b c d e f g h i j k l m n o p q r s t u v w x y z" && long="a b c d e f g h i j k l m n o p q r s t u v w x y z" &&
for c in $long; do echo $c; done >one && test_write_lines $long >one &&
mkdir dir && mkdir dir &&
for c in x y z $long a b c; do echo $c; done >dir/two && test_write_lines x y z $long a b c >dir/two &&
cp one original.one && cp one original.one &&
cp dir/two original.two cp dir/two original.two
' '
@ -22,7 +22,7 @@ test_expect_success 'update-index and ls-files' '
git update-index --add one && git update-index --add one &&
case "$(git ls-files)" in case "$(git ls-files)" in
one) echo pass one ;; one) echo pass one ;;
*) echo bad one; exit 1 ;; *) echo bad one; return 1 ;;
esac && esac &&
( (
cd dir && cd dir &&
@ -34,7 +34,7 @@ test_expect_success 'update-index and ls-files' '
) && ) &&
case "$(git ls-files)" in case "$(git ls-files)" in
dir/two"$LF"one) echo pass both ;; dir/two"$LF"one) echo pass both ;;
*) echo bad; exit 1 ;; *) echo bad; return 1 ;;
esac esac
' '
@ -57,7 +57,7 @@ test_expect_success 'diff-files' '
echo d >>dir/two && echo d >>dir/two &&
case "$(git diff-files --name-only)" in case "$(git diff-files --name-only)" in
dir/two"$LF"one) echo pass top ;; dir/two"$LF"one) echo pass top ;;
*) echo bad top; exit 1 ;; *) echo bad top; return 1 ;;
esac && esac &&
# diff should not omit leading paths # diff should not omit leading paths
( (

View File

@ -51,42 +51,32 @@ EOF
test_expect_success 'add a large file or two' ' test_expect_success 'add a large file or two' '
git add large1 huge large2 && git add large1 huge large2 &&
# make sure we got a single packfile and no loose objects # make sure we got a single packfile and no loose objects
bad= count=0 idx= && count=0 idx= &&
for p in .git/objects/pack/pack-*.pack for p in .git/objects/pack/pack-*.pack
do do
count=$(( $count + 1 )) count=$(( $count + 1 )) &&
if test_path_is_file "$p" && test_path_is_file "$p" &&
idx=${p%.pack}.idx && test_path_is_file "$idx" idx=${p%.pack}.idx &&
then test_path_is_file "$idx" || return 1
continue
fi
bad=t
done && done &&
test -z "$bad" &&
test $count = 1 && test $count = 1 &&
cnt=$(git show-index <"$idx" | wc -l) && cnt=$(git show-index <"$idx" | wc -l) &&
test $cnt = 2 && test $cnt = 2 &&
for l in .git/objects/$OIDPATH_REGEX for l in .git/objects/$OIDPATH_REGEX
do do
test_path_is_file "$l" || continue test_path_is_missing "$l" || return 1
bad=t
done && done &&
test -z "$bad" &&
# attempt to add another copy of the same # attempt to add another copy of the same
git add large3 && git add large3 &&
bad= count=0 && bad= count=0 &&
for p in .git/objects/pack/pack-*.pack for p in .git/objects/pack/pack-*.pack
do do
count=$(( $count + 1 )) count=$(( $count + 1 )) &&
if test_path_is_file "$p" && test_path_is_file "$p" &&
idx=${p%.pack}.idx && test_path_is_file "$idx" idx=${p%.pack}.idx &&
then test_path_is_file "$idx" || return 1
continue
fi
bad=t
done && done &&
test -z "$bad" &&
test $count = 1 test $count = 1
' '
@ -115,7 +105,7 @@ test_expect_success 'packsize limit' '
count=0 && count=0 &&
for pi in .git/objects/pack/pack-*.idx for pi in .git/objects/pack/pack-*.idx
do do
test_path_is_file "$pi" && count=$(( $count + 1 )) test_path_is_file "$pi" && count=$(( $count + 1 )) || return 1
done && done &&
test $count = 2 && test $count = 2 &&
@ -128,7 +118,7 @@ test_expect_success 'packsize limit' '
for pi in .git/objects/pack/pack-*.idx for pi in .git/objects/pack/pack-*.idx
do do
git show-index <"$pi" git show-index <"$pi" || return 1
done | done |
sed -e "s/^[0-9]* \([0-9a-f]*\) .*/\1/" | sed -e "s/^[0-9]* \([0-9a-f]*\) .*/\1/" |
sort >actual && sort >actual &&

View File

@ -586,7 +586,7 @@ test_expect_success 'pattern-checks: contained glob characters' '
!/*/ !/*/
something$c-else/ something$c-else/
EOF EOF
check_read_tree_errors repo "a" "disabling cone pattern matching" check_read_tree_errors repo "a" "disabling cone pattern matching" || return 1
done done
' '

View File

@ -718,8 +718,8 @@ test_expect_success bool '
rm -f result && rm -f result &&
for i in 1 2 3 4 for i in 1 2 3 4
do do
git config --bool --get bool.true$i >>result git config --bool --get bool.true$i >>result &&
git config --bool --get bool.false$i >>result git config --bool --get bool.false$i >>result || return 1
done && done &&
test_cmp expect result' test_cmp expect result'
@ -902,7 +902,7 @@ test_expect_success 'get --expiry-date' '
EOF EOF
: "work around heredoc parsing bug fixed in dash 0.5.7 (in ec2c84d)" && : "work around heredoc parsing bug fixed in dash 0.5.7 (in ec2c84d)" &&
{ {
echo "$rel_out $(git config --expiry-date date.valid1)" echo "$rel_out $(git config --expiry-date date.valid1)" &&
git config --expiry-date date.valid2 && git config --expiry-date date.valid2 &&
git config --expiry-date date.valid3 && git config --expiry-date date.valid3 &&
git config --expiry-date date.valid4 && git config --expiry-date date.valid4 &&

View File

@ -1368,7 +1368,7 @@ test_expect_success ULIMIT_FILE_DESCRIPTORS 'large transaction creating branches
( (
for i in $(test_seq 33) for i in $(test_seq 33)
do do
echo "create refs/heads/$i HEAD" echo "create refs/heads/$i HEAD" || exit 1
done >large_input && done >large_input &&
run_with_limited_open_files git update-ref --stdin <large_input && run_with_limited_open_files git update-ref --stdin <large_input &&
git rev-parse --verify -q refs/heads/33 git rev-parse --verify -q refs/heads/33
@ -1379,7 +1379,7 @@ test_expect_success ULIMIT_FILE_DESCRIPTORS 'large transaction deleting branches
( (
for i in $(test_seq 33) for i in $(test_seq 33)
do do
echo "delete refs/heads/$i HEAD" echo "delete refs/heads/$i HEAD" || exit 1
done >large_input && done >large_input &&
run_with_limited_open_files git update-ref --stdin <large_input && run_with_limited_open_files git update-ref --stdin <large_input &&
test_must_fail git rev-parse --verify -q refs/heads/33 test_must_fail git rev-parse --verify -q refs/heads/33

View File

@ -79,7 +79,7 @@ test_expect_success 'show-ref --verify -q' '
test_expect_success 'show-ref -d' ' test_expect_success 'show-ref -d' '
{ {
echo $(git rev-parse refs/tags/A) refs/tags/A && echo $(git rev-parse refs/tags/A) refs/tags/A &&
echo $(git rev-parse refs/tags/A^0) "refs/tags/A^{}" echo $(git rev-parse refs/tags/A^0) "refs/tags/A^{}" &&
echo $(git rev-parse refs/tags/C) refs/tags/C echo $(git rev-parse refs/tags/C) refs/tags/C
} >expect && } >expect &&
git show-ref -d A C >actual && git show-ref -d A C >actual &&
@ -124,14 +124,14 @@ test_expect_success 'show-ref -d' '
test_expect_success 'show-ref --heads, --tags, --head, pattern' ' test_expect_success 'show-ref --heads, --tags, --head, pattern' '
for branch in B main side for branch in B main side
do do
echo $(git rev-parse refs/heads/$branch) refs/heads/$branch echo $(git rev-parse refs/heads/$branch) refs/heads/$branch || return 1
done >expect.heads && done >expect.heads &&
git show-ref --heads >actual && git show-ref --heads >actual &&
test_cmp expect.heads actual && test_cmp expect.heads actual &&
for tag in A B C for tag in A B C
do do
echo $(git rev-parse refs/tags/$tag) refs/tags/$tag echo $(git rev-parse refs/tags/$tag) refs/tags/$tag || return 1
done >expect.tags && done >expect.tags &&
git show-ref --tags >actual && git show-ref --tags >actual &&
test_cmp expect.tags actual && test_cmp expect.tags actual &&
@ -149,7 +149,7 @@ test_expect_success 'show-ref --heads, --tags, --head, pattern' '
{ {
echo $(git rev-parse HEAD) HEAD && echo $(git rev-parse HEAD) HEAD &&
echo $(git rev-parse refs/heads/B) refs/heads/B echo $(git rev-parse refs/heads/B) refs/heads/B &&
echo $(git rev-parse refs/tags/B) refs/tags/B echo $(git rev-parse refs/tags/B) refs/tags/B
} >expect && } >expect &&
git show-ref --head B >actual && git show-ref --head B >actual &&
@ -157,8 +157,8 @@ test_expect_success 'show-ref --heads, --tags, --head, pattern' '
{ {
echo $(git rev-parse HEAD) HEAD && echo $(git rev-parse HEAD) HEAD &&
echo $(git rev-parse refs/heads/B) refs/heads/B echo $(git rev-parse refs/heads/B) refs/heads/B &&
echo $(git rev-parse refs/tags/B) refs/tags/B echo $(git rev-parse refs/tags/B) refs/tags/B &&
echo $(git rev-parse refs/tags/B^0) "refs/tags/B^{}" echo $(git rev-parse refs/tags/B^0) "refs/tags/B^{}"
} >expect && } >expect &&
git show-ref --head -d B >actual && git show-ref --head -d B >actual &&

View File

@ -349,12 +349,12 @@ test_expect_success SHA1 'parsing reverse reflogs at BUFSIZ boundaries' '
printf "$zf%02d $zf%02d %s\t" $i $(($i+1)) "$ident" && printf "$zf%02d $zf%02d %s\t" $i $(($i+1)) "$ident" &&
if test $i = 75; then if test $i = 75; then
for j in $(test_seq 1 89); do for j in $(test_seq 1 89); do
printf X printf X || return 1
done done
else else
printf X printf X
fi && fi &&
printf "\n" printf "\n" || return 1
done >.git/logs/refs/heads/reflogskip && done >.git/logs/refs/heads/reflogskip &&
git rev-parse reflogskip@{73} >actual && git rev-parse reflogskip@{73} >actual &&
echo ${zf}03 >expect && echo ${zf}03 >expect &&

View File

@ -34,10 +34,7 @@ fi
test_expect_success 'blob and tree' ' test_expect_success 'blob and tree' '
test_tick && test_tick &&
( (
for i in 0 1 2 3 4 5 6 7 8 9 test_write_lines 0 1 2 3 4 5 6 7 8 9 &&
do
echo $i
done &&
echo && echo &&
echo b1rwzyc3 echo b1rwzyc3
) >a0blgqsjc && ) >a0blgqsjc &&
@ -204,10 +201,7 @@ test_expect_success 'more history' '
git checkout v1.0.0^0 && git checkout v1.0.0^0 &&
git mv a0blgqsjc f5518nwu && git mv a0blgqsjc f5518nwu &&
for i in h62xsjeu j08bekfvt kg7xflhm test_write_lines h62xsjeu j08bekfvt kg7xflhm >>f5518nwu &&
do
echo $i
done >>f5518nwu &&
git add f5518nwu && git add f5518nwu &&
test_tick && test_tick &&
@ -387,7 +381,7 @@ test_expect_success 'ambiguous commits are printed by type first, then hash orde
do do
grep $type objects >$type.objects && grep $type objects >$type.objects &&
sort $type.objects >$type.objects.sorted && sort $type.objects >$type.objects.sorted &&
test_cmp $type.objects.sorted $type.objects test_cmp $type.objects.sorted $type.objects || return 1
done done
' '

View File

@ -48,10 +48,10 @@ test_expect_success 'enable split index' '
# NEEDSWORK: Stop hard-coding checksums. # NEEDSWORK: Stop hard-coding checksums.
if test "$indexversion" = "4" if test "$indexversion" = "4"
then then
own=$(test_oid own_v4) own=$(test_oid own_v4) &&
base=$(test_oid base_v4) base=$(test_oid base_v4)
else else
own=$(test_oid own_v3) own=$(test_oid own_v3) &&
base=$(test_oid base_v3) base=$(test_oid base_v3)
fi && fi &&

View File

@ -57,7 +57,7 @@ test_expect_success 'checkout all stage 0 to temporary files' '
test $(grep $f actual | cut "-d " -f2) = $f && test $(grep $f actual | cut "-d " -f2) = $f &&
p=$(grep $f actual | cut "-d " -f1) && p=$(grep $f actual | cut "-d " -f1) &&
test -f $p && test -f $p &&
test $(cat $p) = tree1$f test $(cat $p) = tree1$f || return 1
done done
' '
@ -85,7 +85,7 @@ test_expect_success 'checkout all stage 2 to temporary files' '
test $(grep $f actual | cut "-d " -f2) = $f && test $(grep $f actual | cut "-d " -f2) = $f &&
p=$(grep $f actual | cut "-d " -f1) && p=$(grep $f actual | cut "-d " -f1) &&
test -f $p && test -f $p &&
test $(cat $p) = tree2$f test $(cat $p) = tree2$f || return 1
done done
' '

View File

@ -49,14 +49,14 @@ test_expect_success '"checkout -" detaches again' '
test_expect_success 'more switches' ' test_expect_success 'more switches' '
for i in 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 for i in 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
do do
git checkout -b branch$i git checkout -b branch$i || return 1
done done
' '
more_switches () { more_switches () {
for i in 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 for i in 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
do do
git checkout branch$i git checkout branch$i || return 1
done done
} }

View File

@ -26,7 +26,7 @@ test_expect_success \
'the index entry must still be a symbolic link' ' 'the index entry must still be a symbolic link' '
case "$(git ls-files --stage --cached symlink)" in case "$(git ls-files --stage --cached symlink)" in
120000" "*symlink) echo pass;; 120000" "*symlink) echo pass;;
*) echo fail; git ls-files --stage --cached symlink; (exit 1);; *) echo fail; git ls-files --stage --cached symlink; false;;
esac' esac'
test_done test_done

View File

@ -24,7 +24,7 @@ test_expect_success basics '
test_cmp expect actual && test_cmp expect actual &&
git update-index --add one two three && git update-index --add one two three &&
for i in one three two; do echo $i; done >expect && test_write_lines one three two >expect &&
git ls-files >actual && git ls-files >actual &&
test_cmp expect actual && test_cmp expect actual &&

View File

@ -151,13 +151,13 @@ test_expect_success 'add -u resolves unmerged paths' '
{ {
for path in path1 path2 for path in path1 path2
do do
echo "100644 $one 1 $path" echo "100644 $one 1 $path" &&
echo "100644 $two 2 $path" echo "100644 $two 2 $path" &&
echo "100644 $three 3 $path" echo "100644 $three 3 $path" || return 1
done done &&
echo "100644 $one 1 path3" echo "100644 $one 1 path3" &&
echo "100644 $one 1 path4" echo "100644 $one 1 path4" &&
echo "100644 $one 3 path5" echo "100644 $one 3 path5" &&
echo "100644 $one 3 path6" echo "100644 $one 3 path6"
} | } |
git update-index --index-info && git update-index --index-info &&
@ -174,8 +174,8 @@ test_expect_success 'add -u resolves unmerged paths' '
git add -u && git add -u &&
git ls-files -s path1 path2 path3 path4 path5 path6 >actual && git ls-files -s path1 path2 path3 path4 path5 path6 >actual &&
{ {
echo "100644 $three 0 path1" echo "100644 $three 0 path1" &&
echo "100644 $two 0 path3" echo "100644 $two 0 path3" &&
echo "100644 $two 0 path5" echo "100644 $two 0 path5"
} >expect && } >expect &&
test_cmp expect actual test_cmp expect actual

View File

@ -98,17 +98,17 @@ test_expect_success modify '
" "
} >expect && } >expect &&
{ {
cat expect cat expect &&
echo ":100644 160000 $_empty $ZERO_OID T yonk" echo ":100644 160000 $_empty $ZERO_OID T yonk" &&
echo ":100644 000000 $_empty $ZERO_OID D zifmia" echo ":100644 000000 $_empty $ZERO_OID D zifmia"
} >expect-files && } >expect-files &&
{ {
cat expect cat expect &&
echo ":000000 160000 $ZERO_OID $ZERO_OID A yonk" echo ":000000 160000 $ZERO_OID $ZERO_OID A yonk"
} >expect-index && } >expect-index &&
{ {
echo "100644 $_empty 0 nitfol" echo "100644 $_empty 0 nitfol" &&
echo "160000 $yomin 0 yomin" echo "160000 $yomin 0 yomin" &&
echo "160000 $yonk 0 yonk" echo "160000 $yonk 0 yonk"
} >expect-final } >expect-final
' '

View File

@ -116,7 +116,7 @@ test_expect_success 'cache-tree does not ignore dir that has i-t-a entries' '
mkdir 2 && mkdir 2 &&
for f in 1 2/1 2/2 3 for f in 1 2/1 2/2 3
do do
echo "$f" >"$f" echo "$f" >"$f" || return 1
done && done &&
git add 1 2/2 3 && git add 1 2/2 3 &&
git add -N 2/1 && git add -N 2/1 &&

View File

@ -39,10 +39,7 @@ test_expect_success 'ls-files with mixed levels' '
test_expect_success 'ls-files -c' ' test_expect_success 'ls-files -c' '
( (
cd top/sub && cd top/sub &&
for f in ../y* printf "error: pathspec $SQ%s$SQ did not match any file(s) known to git\n" ../y* >expect.err &&
do
echo "error: pathspec $SQ$f$SQ did not match any file(s) known to git"
done >expect.err &&
echo "Did you forget to ${SQ}git add${SQ}?" >>expect.err && echo "Did you forget to ${SQ}git add${SQ}?" >>expect.err &&
ls ../x* >expect.out && ls ../x* >expect.out &&
test_must_fail git ls-files -c --error-unmatch ../[xy]* >actual.out 2>actual.err && test_must_fail git ls-files -c --error-unmatch ../[xy]* >actual.out 2>actual.err &&
@ -54,10 +51,7 @@ test_expect_success 'ls-files -c' '
test_expect_success 'ls-files -o' ' test_expect_success 'ls-files -o' '
( (
cd top/sub && cd top/sub &&
for f in ../x* printf "error: pathspec $SQ%s$SQ did not match any file(s) known to git\n" ../x* >expect.err &&
do
echo "error: pathspec $SQ$f$SQ did not match any file(s) known to git"
done >expect.err &&
echo "Did you forget to ${SQ}git add${SQ}?" >>expect.err && echo "Did you forget to ${SQ}git add${SQ}?" >>expect.err &&
ls ../y* >expect.out && ls ../y* >expect.out &&
test_must_fail git ls-files -o --error-unmatch ../[xy]* >actual.out 2>actual.err && test_must_fail git ls-files -o --error-unmatch ../[xy]* >actual.out 2>actual.err &&

View File

@ -193,7 +193,7 @@ match() {
file=$(cat .git/expected_test_file) && file=$(cat .git/expected_test_file) &&
if should_create_test_file "$file" if should_create_test_file "$file"
then then
dirs=${file%/*} dirs=${file%/*} &&
if test "$file" != "$dirs" if test "$file" != "$dirs"
then then
mkdir -p -- "$dirs" && mkdir -p -- "$dirs" &&

View File

@ -12,7 +12,7 @@ test_expect_success 'setup' '
for i in $(test_seq 1 10) for i in $(test_seq 1 10)
do do
git checkout -b branch$i initial && git checkout -b branch$i initial &&
test_commit --no-tag branch$i test_commit --no-tag branch$i || return 1
done && done &&
git for-each-ref \ git for-each-ref \
--sort=version:refname \ --sort=version:refname \
@ -52,7 +52,7 @@ test_expect_success 'show-branch with more than 8 branches' '
test_expect_success 'show-branch with showbranch.default' ' test_expect_success 'show-branch with showbranch.default' '
for branch in $(cat branches.sorted) for branch in $(cat branches.sorted)
do do
test_config showbranch.default $branch --add test_config showbranch.default $branch --add || return 1
done && done &&
git show-branch >actual && git show-branch >actual &&
test_cmp expect actual test_cmp expect actual
@ -127,7 +127,7 @@ test_expect_success 'show branch --merge-base with one argument' '
do do
git rev-parse $branch >expect && git rev-parse $branch >expect &&
git show-branch --merge-base $branch >actual && git show-branch --merge-base $branch >actual &&
test_cmp expect actual test_cmp expect actual || return 1
done done
' '
@ -136,7 +136,7 @@ test_expect_success 'show branch --merge-base with two arguments' '
do do
git rev-parse initial >expect && git rev-parse initial >expect &&
git show-branch --merge-base initial $branch >actual && git show-branch --merge-base initial $branch >actual &&
test_cmp expect actual test_cmp expect actual || return 1
done done
' '

View File

@ -31,7 +31,7 @@ verify_notes () {
while [ $i -gt 0 ]; do while [ $i -gt 0 ]; do
echo " commit #$i" && echo " commit #$i" &&
echo " note for commit #$i" && echo " note for commit #$i" &&
i=$(($i-1)); i=$(($i-1)) || return 1
done > expect && done > expect &&
test_cmp expect output test_cmp expect output
} }
@ -43,7 +43,7 @@ test_expect_success "setup: create $number_of_commits commits" '
while [ $nr -lt $number_of_commits ]; do while [ $nr -lt $number_of_commits ]; do
nr=$(($nr+1)) && nr=$(($nr+1)) &&
test_tick && test_tick &&
cat <<INPUT_END cat <<INPUT_END || return 1
commit refs/heads/main commit refs/heads/main
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT data <<COMMIT
@ -179,7 +179,7 @@ verify_concatenated_notes () {
echo " first note for commit #$i" && echo " first note for commit #$i" &&
echo " " && echo " " &&
echo " second note for commit #$i" && echo " second note for commit #$i" &&
i=$(($i-1)); i=$(($i-1)) || return 1
done > expect && done > expect &&
test_cmp expect output test_cmp expect output
} }

View File

@ -58,7 +58,7 @@ test_expect_success 'many notes created correctly with git-notes' '
do do
echo " commit #$i" && echo " commit #$i" &&
echo " note #$i" && echo " note #$i" &&
i=$(($i - 1)); i=$(($i - 1)) || return 1
done > expect && done > expect &&
test_cmp expect output test_cmp expect output
' '
@ -107,7 +107,7 @@ test_expect_success 'most notes deleted correctly with git-notes' '
do do
echo " commit #$i" && echo " commit #$i" &&
echo " note #$i" && echo " note #$i" &&
i=$(($i - 1)); i=$(($i - 1)) || return 1
done > expect && done > expect &&
test_cmp expect output test_cmp expect output
' '

View File

@ -68,7 +68,7 @@ test_expect_success 'merge and rebase should match' '
if test -s difference if test -s difference
then then
cat difference cat difference
(exit 1) false
else else
echo happy echo happy
fi fi
@ -102,7 +102,7 @@ test_expect_success 'merge and rebase should match' '
if test -s difference if test -s difference
then then
cat difference cat difference
(exit 1) false
else else
echo happy echo happy
fi fi
@ -117,7 +117,7 @@ test_expect_success 'picking rebase' '
echo happy echo happy
else else
git show-branch git show-branch
(exit 1) false
fi && fi &&
f=$(git diff-tree --name-only HEAD^ HEAD) && f=$(git diff-tree --name-only HEAD^ HEAD) &&
g=$(git diff-tree --name-only HEAD^^ HEAD^) && g=$(git diff-tree --name-only HEAD^^ HEAD^) &&
@ -127,7 +127,7 @@ test_expect_success 'picking rebase' '
*) *)
echo "$f" echo "$f"
echo "$g" echo "$g"
(exit 1) false
esac esac
' '

View File

@ -824,7 +824,7 @@ test_expect_success 'always cherry-pick with --no-ff' '
do do
test ! $(git rev-parse HEAD~$p) = $(git rev-parse original-no-ff-branch~$p) && test ! $(git rev-parse HEAD~$p) = $(git rev-parse original-no-ff-branch~$p) &&
git diff HEAD~$p original-no-ff-branch~$p > out && git diff HEAD~$p original-no-ff-branch~$p > out &&
test_must_be_empty out test_must_be_empty out || return 1
done && done &&
test_cmp_rev HEAD~3 original-no-ff-branch~3 && test_cmp_rev HEAD~3 original-no-ff-branch~3 &&
git diff HEAD~3 original-no-ff-branch~3 > out && git diff HEAD~3 original-no-ff-branch~3 > out &&
@ -1339,7 +1339,7 @@ test_expect_success 'rebase --continue removes CHERRY_PICK_HEAD' '
test_seq 5 | sed "s/$double/&&/" >seq && test_seq 5 | sed "s/$double/&&/" >seq &&
git add seq && git add seq &&
test_tick && test_tick &&
git commit -m seq-$double git commit -m seq-$double || return 1
done && done &&
git tag seq-onto && git tag seq-onto &&
git reset --hard HEAD~2 && git reset --hard HEAD~2 &&

View File

@ -115,9 +115,7 @@ test_expect_success 'at beginning of file' '
git config core.whitespace "blank-at-eol" && git config core.whitespace "blank-at-eol" &&
cp beginning file && cp beginning file &&
git commit -m beginning file && git commit -m beginning file &&
for i in 1 2 3 4 5; do test_write_lines 1 2 3 4 5 >>file &&
echo $i
done >> file &&
git commit -m more file && git commit -m more file &&
git rebase --whitespace=fix HEAD^^ && git rebase --whitespace=fix HEAD^^ &&
test_cmp expect-beginning file test_cmp expect-beginning file

View File

@ -19,7 +19,7 @@ test_expect_success setup '
for l in a b c d e f g h i j k l m n o for l in a b c d e f g h i j k l m n o
do do
echo $l$l$l$l$l$l$l$l$l echo $l$l$l$l$l$l$l$l$l || return 1
done >oops && done >oops &&
test_tick && test_tick &&

View File

@ -29,7 +29,7 @@ test_expect_success setup '
git add file1 && git add file1 &&
test_tick && test_tick &&
git commit -m "$val" && git commit -m "$val" &&
git tag $val git tag $val || return 1
done done
' '

View File

@ -265,7 +265,7 @@ test_expect_success 'choking "git rm" should not let it die with cruft (induce S
test_expect_success !MINGW 'choking "git rm" should not let it die with cruft (induce and check SIGPIPE)' ' test_expect_success !MINGW 'choking "git rm" should not let it die with cruft (induce and check SIGPIPE)' '
choke_git_rm_setup && choke_git_rm_setup &&
OUT=$( ((trap "" PIPE; git rm -n "some-file-*"; echo $? 1>&3) | :) 3>&1 ) && OUT=$( ((trap "" PIPE && git rm -n "some-file-*"; echo $? 1>&3) | :) 3>&1 ) &&
test_match_signal 13 "$OUT" && test_match_signal 13 "$OUT" &&
test_path_is_missing .git/index.lock test_path_is_missing .git/index.lock
' '
@ -274,10 +274,7 @@ test_expect_success 'Resolving by removal is not a warning-worthy event' '
git reset -q --hard && git reset -q --hard &&
test_when_finished "rm -f .git/index.lock msg && git reset -q --hard" && test_when_finished "rm -f .git/index.lock msg && git reset -q --hard" &&
blob=$(echo blob | git hash-object -w --stdin) && blob=$(echo blob | git hash-object -w --stdin) &&
for stage in 1 2 3 printf "100644 $blob %d\tblob\n" 1 2 3 | git update-index --index-info &&
do
echo "100644 $blob $stage blob"
done | git update-index --index-info &&
git rm blob >msg 2>&1 && git rm blob >msg 2>&1 &&
test_i18ngrep ! "needs merge" msg && test_i18ngrep ! "needs merge" msg &&
test_must_fail git ls-files -s --error-unmatch blob test_must_fail git ls-files -s --error-unmatch blob

View File

@ -141,9 +141,9 @@ test_expect_success 'check correct prefix detection' '
test_expect_success 'git add with filemode=0, symlinks=0, and unmerged entries' ' test_expect_success 'git add with filemode=0, symlinks=0, and unmerged entries' '
for s in 1 2 3 for s in 1 2 3
do do
echo $s > stage$s echo $s > stage$s &&
echo "100755 $(git hash-object -w stage$s) $s file" echo "100755 $(git hash-object -w stage$s) $s file" &&
echo "120000 $(printf $s | git hash-object -w -t blob --stdin) $s symlink" echo "120000 $(printf $s | git hash-object -w -t blob --stdin) $s symlink" || return 1
done | git update-index --index-info && done | git update-index --index-info &&
git config core.filemode 0 && git config core.filemode 0 &&
git config core.symlinks 0 && git config core.symlinks 0 &&
@ -177,7 +177,7 @@ test_expect_success 'git add --refresh' '
git read-tree HEAD && git read-tree HEAD &&
case "$(git diff-index HEAD -- foo)" in case "$(git diff-index HEAD -- foo)" in
:100644" "*"M foo") echo pass;; :100644" "*"M foo") echo pass;;
*) echo fail; (exit 1);; *) echo fail; false;;
esac && esac &&
git add --refresh -- foo && git add --refresh -- foo &&
test -z "$(git diff-index HEAD -- foo)" test -z "$(git diff-index HEAD -- foo)"

View File

@ -70,7 +70,7 @@ test_crlf_subject_body_and_contents() {
for ref in ${LIB_CRLF_BRANCHES} for ref in ${LIB_CRLF_BRANCHES}
do do
cat .crlf-${file}-\"\${ref}\".txt >>expect && cat .crlf-${file}-\"\${ref}\".txt >>expect &&
printf \"\n\" >>expect printf \"\n\" >>expect || return 1
done && done &&
git $command_and_args --format=\"%${atom}\" >actual && git $command_and_args --format=\"%${atom}\" >actual &&
test_cmp expect actual test_cmp expect actual
@ -90,7 +90,7 @@ test_expect_success 'branch: --verbose works with messages using CRLF' '
do do
printf " " >>expect && printf " " >>expect &&
cat .crlf-subject-${branch}.txt >>expect && cat .crlf-subject-${branch}.txt >>expect &&
printf "\n" >>expect printf "\n" >>expect || return 1
done && done &&
git branch -v >tmp && git branch -v >tmp &&
# Remove first two columns, and the line for the currently checked out branch # Remove first two columns, and the line for the currently checked out branch

View File

@ -174,7 +174,7 @@ test_expect_success 'setup for many rename source candidates' '
do do
for j in 0 1 2 3 4 5 6 7 8 9; for j in 0 1 2 3 4 5 6 7 8 9;
do do
echo "$i$j" >"path$i$j" echo "$i$j" >"path$i$j" || return 1
done done
done && done &&
git add "path??" && git add "path??" &&

View File

@ -123,7 +123,7 @@ test_expect_success 'diff --stat with binary files and big change count' '
i=0 && i=0 &&
while test $i -lt 10000; do while test $i -lt 10000; do
echo $i && echo $i &&
i=$(($i + 1)) i=$(($i + 1)) || return 1
done >textfile && done >textfile &&
git add textfile && git add textfile &&
git diff --cached --stat binfile textfile >output && git diff --cached --stat binfile textfile >output &&

View File

@ -19,8 +19,8 @@ test_expect_success setup '
mkdir dir && mkdir dir &&
mkdir dir2 && mkdir dir2 &&
for i in 1 2 3; do echo $i; done >file0 && test_write_lines 1 2 3 >file0 &&
for i in A B; do echo $i; done >dir/sub && test_write_lines A B >dir/sub &&
cat file0 >file2 && cat file0 >file2 &&
git add file0 file2 dir/sub && git add file0 file2 dir/sub &&
git commit -m Initial && git commit -m Initial &&
@ -32,8 +32,8 @@ test_expect_success setup '
GIT_COMMITTER_DATE="2006-06-26 00:01:00 +0000" && GIT_COMMITTER_DATE="2006-06-26 00:01:00 +0000" &&
export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
for i in 4 5 6; do echo $i; done >>file0 && test_write_lines 4 5 6 >>file0 &&
for i in C D; do echo $i; done >>dir/sub && test_write_lines C D >>dir/sub &&
rm -f file2 && rm -f file2 &&
git update-index --remove file0 file2 dir/sub && git update-index --remove file0 file2 dir/sub &&
git commit -m "Second${LF}${LF}This is the second commit." && git commit -m "Second${LF}${LF}This is the second commit." &&
@ -42,9 +42,9 @@ test_expect_success setup '
GIT_COMMITTER_DATE="2006-06-26 00:02:00 +0000" && GIT_COMMITTER_DATE="2006-06-26 00:02:00 +0000" &&
export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
for i in A B C; do echo $i; done >file1 && test_write_lines A B C >file1 &&
git add file1 && git add file1 &&
for i in E F; do echo $i; done >>dir/sub && test_write_lines E F >>dir/sub &&
git update-index dir/sub && git update-index dir/sub &&
git commit -m Third && git commit -m Third &&
@ -53,8 +53,8 @@ test_expect_success setup '
export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
git checkout side && git checkout side &&
for i in A B C; do echo $i; done >>file0 && test_write_lines A B C >>file0 &&
for i in 1 2; do echo $i; done >>dir/sub && test_write_lines 1 2 >>dir/sub &&
cat dir/sub >file3 && cat dir/sub >file3 &&
git add file3 && git add file3 &&
git update-index file0 dir/sub && git update-index file0 dir/sub &&
@ -71,8 +71,8 @@ test_expect_success setup '
GIT_COMMITTER_DATE="2006-06-26 00:05:00 +0000" && GIT_COMMITTER_DATE="2006-06-26 00:05:00 +0000" &&
export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
for i in A B C; do echo $i; done >>file0 && test_write_lines A B C >>file0 &&
for i in 1 2; do echo $i; done >>dir/sub && test_write_lines 1 2 >>dir/sub &&
git update-index file0 dir/sub && git update-index file0 dir/sub &&
mkdir dir3 && mkdir dir3 &&
@ -86,7 +86,7 @@ test_expect_success setup '
GIT_COMMITTER_DATE="2006-06-26 00:06:00 +0000" && GIT_COMMITTER_DATE="2006-06-26 00:06:00 +0000" &&
export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
git checkout -b rearrange initial && git checkout -b rearrange initial &&
for i in B A; do echo $i; done >dir/sub && test_write_lines B A >dir/sub &&
git add dir/sub && git add dir/sub &&
git commit -m "Rearranged lines in dir/sub" && git commit -m "Rearranged lines in dir/sub" &&
git checkout master && git checkout master &&

View File

@ -12,25 +12,25 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. "$TEST_DIRECTORY"/lib-terminal.sh . "$TEST_DIRECTORY"/lib-terminal.sh
test_expect_success setup ' test_expect_success setup '
for i in 1 2 3 4 5 6 7 8 9 10; do echo "$i"; done >file && test_write_lines 1 2 3 4 5 6 7 8 9 10 >file &&
cat file >elif && cat file >elif &&
git add file elif && git add file elif &&
test_tick && test_tick &&
git commit -m Initial && git commit -m Initial &&
git checkout -b side && git checkout -b side &&
for i in 1 2 5 6 A B C 7 8 9 10; do echo "$i"; done >file && test_write_lines 1 2 5 6 A B C 7 8 9 10 >file &&
test_chmod +x elif && test_chmod +x elif &&
test_tick && test_tick &&
git commit -m "Side changes #1" && git commit -m "Side changes #1" &&
for i in D E F; do echo "$i"; done >>file && test_write_lines D E F >>file &&
git update-index file && git update-index file &&
test_tick && test_tick &&
git commit -m "Side changes #2" && git commit -m "Side changes #2" &&
git tag C2 && git tag C2 &&
for i in 5 6 1 2 3 A 4 B C 7 8 9 10 D E F; do echo "$i"; done >file && test_write_lines 5 6 1 2 3 A 4 B C 7 8 9 10 D E F >file &&
git update-index file && git update-index file &&
test_tick && test_tick &&
git commit -m "Side changes #3 with \\n backslash-n in it." && git commit -m "Side changes #3 with \\n backslash-n in it." &&
@ -43,18 +43,18 @@ test_expect_success setup '
git checkout side && git checkout side &&
git checkout -b patchid && git checkout -b patchid &&
for i in 5 6 1 2 3 A 4 B C 7 8 9 10 D E F; do echo "$i"; done >file2 && test_write_lines 5 6 1 2 3 A 4 B C 7 8 9 10 D E F >file2 &&
for i in 1 2 3 A 4 B C 7 8 9 10 D E F 5 6; do echo "$i"; done >file3 && test_write_lines 1 2 3 A 4 B C 7 8 9 10 D E F 5 6 >file3 &&
for i in 8 9 10; do echo "$i"; done >file && test_write_lines 8 9 10 >file &&
git add file file2 file3 && git add file file2 file3 &&
test_tick && test_tick &&
git commit -m "patchid 1" && git commit -m "patchid 1" &&
for i in 4 A B 7 8 9 10; do echo "$i"; done >file2 && test_write_lines 4 A B 7 8 9 10 >file2 &&
for i in 8 9 10 5 6; do echo "$i"; done >file3 && test_write_lines 8 9 10 5 6 >file3 &&
git add file2 file3 && git add file2 file3 &&
test_tick && test_tick &&
git commit -m "patchid 2" && git commit -m "patchid 2" &&
for i in 10 5 6; do echo "$i"; done >file && test_write_lines 10 5 6 >file &&
git add file && git add file &&
test_tick && test_tick &&
git commit -m "patchid 3" && git commit -m "patchid 3" &&
@ -325,7 +325,7 @@ test_expect_success 'filename length limit' '
max=$( max=$(
for patch in 000[1-9]-*.patch for patch in 000[1-9]-*.patch
do do
echo "$patch" | wc -c echo "$patch" | wc -c || exit 1
done | done |
sort -nr | sort -nr |
head -n 1 head -n 1
@ -343,7 +343,7 @@ test_expect_success 'filename length limit from config' '
max=$( max=$(
for patch in 000[1-9]-*.patch for patch in 000[1-9]-*.patch
do do
echo "$patch" | wc -c echo "$patch" | wc -c || exit 1
done | done |
sort -nr | sort -nr |
head -n 1 head -n 1
@ -361,7 +361,7 @@ test_expect_success 'filename limit applies only to basename' '
max=$( max=$(
for patch in patches/000[1-9]-*.patch for patch in patches/000[1-9]-*.patch
do do
echo "${patch#patches/}" | wc -c echo "${patch#patches/}" | wc -c || exit 1
done | done |
sort -nr | sort -nr |
head -n 1 head -n 1
@ -653,7 +653,7 @@ test_expect_success 'excessive subject' '
git checkout side && git checkout side &&
before=$(git hash-object file) && before=$(git hash-object file) &&
before=$(git rev-parse --short $before) && before=$(git rev-parse --short $before) &&
for i in 5 6 1 2 3 A 4 B C 7 8 9 10 D E F; do echo "$i"; done >>file && test_write_lines 5 6 1 2 3 A 4 B C 7 8 9 10 D E F >>file &&
after=$(git hash-object file) && after=$(git hash-object file) &&
after=$(git rev-parse --short $after) && after=$(git rev-parse --short $after) &&
git update-index file && git update-index file &&
@ -1086,7 +1086,7 @@ test_expect_success TTY 'format-patch --stdout paginates' '
test_expect_success 'format-patch handles multi-line subjects' ' test_expect_success 'format-patch handles multi-line subjects' '
rm -rf patches/ && rm -rf patches/ &&
echo content >>file && echo content >>file &&
for i in one two three; do echo $i; done >msg && test_write_lines one two three >msg &&
git add file && git add file &&
git commit -F msg && git commit -F msg &&
git format-patch -o patches -1 && git format-patch -o patches -1 &&
@ -1098,7 +1098,7 @@ test_expect_success 'format-patch handles multi-line subjects' '
test_expect_success 'format-patch handles multi-line encoded subjects' ' test_expect_success 'format-patch handles multi-line encoded subjects' '
rm -rf patches/ && rm -rf patches/ &&
echo content >>file && echo content >>file &&
for i in en två tre; do echo $i; done >msg && test_write_lines en två tre >msg &&
git add file && git add file &&
git commit -F msg && git commit -F msg &&
git format-patch -o patches -1 && git format-patch -o patches -1 &&

View File

@ -843,7 +843,7 @@ test_expect_success 'whitespace changes with modification reported (diffstat)' '
test_expect_success 'whitespace-only changes reported across renames (diffstat)' ' test_expect_success 'whitespace-only changes reported across renames (diffstat)' '
git reset --hard && git reset --hard &&
for i in 1 2 3 4 5 6 7 8 9; do echo "$i$i$i$i$i$i"; done >x && for i in 1 2 3 4 5 6 7 8 9; do echo "$i$i$i$i$i$i" || return 1; done >x &&
git add x && git add x &&
git commit -m "base" && git commit -m "base" &&
sed -e "5s/^/ /" x >z && sed -e "5s/^/ /" x >z &&
@ -859,7 +859,7 @@ test_expect_success 'whitespace-only changes reported across renames (diffstat)'
test_expect_success 'whitespace-only changes reported across renames' ' test_expect_success 'whitespace-only changes reported across renames' '
git reset --hard HEAD~1 && git reset --hard HEAD~1 &&
for i in 1 2 3 4 5 6 7 8 9; do echo "$i$i$i$i$i$i"; done >x && for i in 1 2 3 4 5 6 7 8 9; do echo "$i$i$i$i$i$i" || return 1; done >x &&
git add x && git add x &&
hash_x=$(git hash-object x) && hash_x=$(git hash-object x) &&
before=$(git rev-parse --short "$hash_x") && before=$(git rev-parse --short "$hash_x") &&

View File

@ -75,7 +75,7 @@ test_expect_success 'last regexp must not be negated' '
test_expect_success 'setup hunk header tests' ' test_expect_success 'setup hunk header tests' '
for i in $diffpatterns for i in $diffpatterns
do do
echo "$i-* diff=$i" echo "$i-* diff=$i" || return 1
done > .gitattributes && done > .gitattributes &&
# add all test files to the index # add all test files to the index

View File

@ -287,9 +287,9 @@ test_expect_success 'do not color trailing cr in context' '
' '
test_expect_success 'color new trailing blank lines' ' test_expect_success 'color new trailing blank lines' '
{ echo a; echo b; echo; echo; } >x && test_write_lines a b "" "" >x &&
git add x && git add x &&
{ echo a; echo; echo; echo; echo c; echo; echo; echo; echo; } >x && test_write_lines a "" "" "" c "" "" "" "" >x &&
git diff --color x >output && git diff --color x >output &&
cnt=$($grep_a "${blue_grep}" output | wc -l) && cnt=$($grep_a "${blue_grep}" output | wc -l) &&
test $cnt = 2 test $cnt = 2

View File

@ -55,7 +55,7 @@ test_expect_success 'cross renames to be detected for regular files' '
git diff-tree five six -r --name-status -B -M | sort >actual && git diff-tree five six -r --name-status -B -M | sort >actual &&
{ {
echo "R100 foo bar" echo "R100 foo bar" &&
echo "R100 bar foo" echo "R100 bar foo"
} | sort >expect && } | sort >expect &&
test_cmp expect actual test_cmp expect actual
@ -66,7 +66,7 @@ test_expect_success 'cross renames to be detected for typechange' '
git diff-tree one two -r --name-status -B -M | sort >actual && git diff-tree one two -r --name-status -B -M | sort >actual &&
{ {
echo "R100 foo bar" echo "R100 foo bar" &&
echo "R100 bar foo" echo "R100 bar foo"
} | sort >expect && } | sort >expect &&
test_cmp expect actual test_cmp expect actual
@ -78,7 +78,7 @@ test_expect_success 'moves and renames' '
git diff-tree three four -r --name-status -B -M | sort >actual && git diff-tree three four -r --name-status -B -M | sort >actual &&
{ {
# see -B -M (#6) in t4008 # see -B -M (#6) in t4008
echo "C100 foo bar" echo "C100 foo bar" &&
echo "T100 foo" echo "T100 foo"
} | sort >expect && } | sort >expect &&
test_cmp expect actual test_cmp expect actual

View File

@ -149,7 +149,7 @@ test_expect_success 'diff -U0' '
for n in $sample for n in $sample
do do
git diff -U0 file-?$n git diff -U0 file-?$n || return 1
done | zc >actual && done | zc >actual &&
test_cmp expect actual test_cmp expect actual

View File

@ -14,15 +14,9 @@ test_expect_success setup '
( (
echo "A $NS" && echo "A $NS" &&
for c in B C D E F G H I J K printf " %s\n" B C D E F G H I J K &&
do
echo " $c"
done &&
echo "L $NS" && echo "L $NS" &&
for c in M N O P Q R S T U V printf " %s\n" M N O P Q R S T U V
do
echo " $c"
done
) >file && ) >file &&
git add file && git add file &&

View File

@ -100,7 +100,7 @@ test_expect_success 'setup for --cc --raw' '
for i in $(test_seq 1 40) for i in $(test_seq 1 40)
do do
blob=$(echo file$i | git hash-object --stdin -w) && blob=$(echo file$i | git hash-object --stdin -w) &&
trees="$trees$(echo "100644 blob $blob file" | git mktree)$LF" trees="$trees$(echo "100644 blob $blob file" | git mktree)$LF" || return 1
done done
' '

View File

@ -20,7 +20,7 @@ test_expect_success setup '
for t in o x for t in o x
do do
path="$b$o$t" && path="$b$o$t" &&
case "$path" in ooo) continue ;; esac case "$path" in ooo) continue ;; esac &&
paths="$paths$path " && paths="$paths$path " &&
p=" $path" && p=" $path" &&
case "$b" in x) echo "$m1$p" ;; esac && case "$b" in x) echo "$m1$p" ;; esac &&
@ -39,7 +39,7 @@ test_expect_success 'diff-files -0' '
for path in $paths for path in $paths
do do
>"$path" && >"$path" &&
echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" || return 1
done >diff-files-0.expect && done >diff-files-0.expect &&
git diff-files -0 >diff-files-0.actual && git diff-files -0 >diff-files-0.actual &&
test_cmp diff-files-0.expect diff-files-0.actual test_cmp diff-files-0.expect diff-files-0.actual
@ -52,7 +52,7 @@ test_expect_success 'diff-files -1' '
echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" && echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" &&
case "$path" in case "$path" in
x??) echo ":100644 100644 $blob1 $ZERO_OID M $path" x??) echo ":100644 100644 $blob1 $ZERO_OID M $path"
esac esac || return 1
done >diff-files-1.expect && done >diff-files-1.expect &&
git diff-files -1 >diff-files-1.actual && git diff-files -1 >diff-files-1.actual &&
test_cmp diff-files-1.expect diff-files-1.actual test_cmp diff-files-1.expect diff-files-1.actual
@ -65,7 +65,7 @@ test_expect_success 'diff-files -2' '
echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" && echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" &&
case "$path" in case "$path" in
?x?) echo ":100644 100644 $blob2 $ZERO_OID M $path" ?x?) echo ":100644 100644 $blob2 $ZERO_OID M $path"
esac esac || return 1
done >diff-files-2.expect && done >diff-files-2.expect &&
git diff-files -2 >diff-files-2.actual && git diff-files -2 >diff-files-2.actual &&
test_cmp diff-files-2.expect diff-files-2.actual && test_cmp diff-files-2.expect diff-files-2.actual &&
@ -80,7 +80,7 @@ test_expect_success 'diff-files -3' '
echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" && echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" &&
case "$path" in case "$path" in
??x) echo ":100644 100644 $blob3 $ZERO_OID M $path" ??x) echo ":100644 100644 $blob3 $ZERO_OID M $path"
esac esac || return 1
done >diff-files-3.expect && done >diff-files-3.expect &&
git diff-files -3 >diff-files-3.actual && git diff-files -3 >diff-files-3.actual &&
test_cmp diff-files-3.expect diff-files-3.actual test_cmp diff-files-3.expect diff-files-3.actual

View File

@ -53,7 +53,7 @@ test_expect_success 'exclude unmerged entries from total file count' '
git rm -f d && git rm -f d &&
for stage in 1 2 3 for stage in 1 2 3
do do
sed -e "s/ 0 a/ $stage d/" x sed -e "s/ 0 a/ $stage d/" x || return 1
done | done |
git update-index --index-info && git update-index --index-info &&
echo d >d && echo d >d &&

View File

@ -101,7 +101,7 @@ test_expect_success 'preparation for big change tests' '
i=0 && i=0 &&
while test $i -lt 1000 while test $i -lt 1000
do do
echo $i && i=$(($i + 1)) echo $i && i=$(($i + 1)) || return 1
done >abcd && done >abcd &&
git commit -m message abcd git commit -m message abcd
' '

View File

@ -18,13 +18,13 @@ test_expect_success 'trivial merge - combine-diff empty' '
for i in $(test_seq 1 9) for i in $(test_seq 1 9)
do do
echo $i >$i.txt && echo $i >$i.txt &&
git add $i.txt git add $i.txt || return 1
done && done &&
git commit -m "init" && git commit -m "init" &&
git checkout -b side && git checkout -b side &&
for i in $(test_seq 2 9) for i in $(test_seq 2 9)
do do
echo $i/2 >>$i.txt echo $i/2 >>$i.txt || return 1
done && done &&
git commit -a -m "side 2-9" && git commit -a -m "side 2-9" &&
git checkout main && git checkout main &&
@ -40,14 +40,14 @@ test_expect_success 'only one truly conflicting path' '
git checkout side && git checkout side &&
for i in $(test_seq 2 9) for i in $(test_seq 2 9)
do do
echo $i/3 >>$i.txt echo $i/3 >>$i.txt || return 1
done && done &&
echo "4side" >>4.txt && echo "4side" >>4.txt &&
git commit -a -m "side 2-9 +4" && git commit -a -m "side 2-9 +4" &&
git checkout main && git checkout main &&
for i in $(test_seq 1 9) for i in $(test_seq 1 9)
do do
echo $i/3 >>$i.txt echo $i/3 >>$i.txt || return 1
done && done &&
echo "4main" >>4.txt && echo "4main" >>4.txt &&
git commit -a -m "main 1-9 +4" && git commit -a -m "main 1-9 +4" &&
@ -69,13 +69,13 @@ test_expect_success 'merge introduces new file' '
git checkout side && git checkout side &&
for i in $(test_seq 5 9) for i in $(test_seq 5 9)
do do
echo $i/4 >>$i.txt echo $i/4 >>$i.txt || return 1
done && done &&
git commit -a -m "side 5-9" && git commit -a -m "side 5-9" &&
git checkout main && git checkout main &&
for i in $(test_seq 1 3) for i in $(test_seq 1 3)
do do
echo $i/4 >>$i.txt echo $i/4 >>$i.txt || return 1
done && done &&
git commit -a -m "main 1-3 +4hello" && git commit -a -m "main 1-3 +4hello" &&
git merge side && git merge side &&
@ -90,13 +90,13 @@ test_expect_success 'merge removed a file' '
git checkout side && git checkout side &&
for i in $(test_seq 5 9) for i in $(test_seq 5 9)
do do
echo $i/5 >>$i.txt echo $i/5 >>$i.txt || return 1
done && done &&
git commit -a -m "side 5-9" && git commit -a -m "side 5-9" &&
git checkout main && git checkout main &&
for i in $(test_seq 1 3) for i in $(test_seq 1 3)
do do
echo $i/4 >>$i.txt echo $i/4 >>$i.txt || return 1
done && done &&
git commit -a -m "main 1-3" && git commit -a -m "main 1-3" &&
git merge side && git merge side &&

View File

@ -17,15 +17,9 @@ dotest () {
test_expect_success setup ' test_expect_success setup '
for i in 1 2 3 4 5 6 7 8 9 10 11 12 test_write_lines 1 2 3 4 5 6 7 8 9 10 11 12 >file &&
do
echo $i
done >file &&
git update-index --add file && git update-index --add file &&
for i in 1 2 3 4 5 6 7 a b c d e 8 9 10 11 12 test_write_lines 1 2 3 4 5 6 7 a b c d e 8 9 10 11 12 >file &&
do
echo $i
done >file &&
cat file >expect && cat file >expect &&
git diff >O0.diff && git diff >O0.diff &&

View File

@ -20,7 +20,10 @@ test_expect_success 'git apply --numstat - < patch' '
' '
test_expect_success 'git apply --numstat - < patch patch' ' test_expect_success 'git apply --numstat - < patch patch' '
for i in 1 2; do echo "1 1 text"; done >expect && cat >expect <<-\EOF &&
1 1 text
1 1 text
EOF
git apply --numstat - < patch patch >actual && git apply --numstat - < patch patch >actual &&
test_cmp expect actual test_cmp expect actual
' '

View File

@ -13,14 +13,14 @@ TEST_PASSES_SANITIZE_LEAK=true
test_expect_success setup ' test_expect_success setup '
for i in a b c d e f g h i j k l m n; do echo $i; done >file1 && test_write_lines a b c d e f g h i j k l m n >file1 &&
perl -pe "y/ijk/\\000\\001\\002/" <file1 >file2 && perl -pe "y/ijk/\\000\\001\\002/" <file1 >file2 &&
git add file1 file2 && git add file1 file2 &&
git commit -m initial && git commit -m initial &&
git tag initial && git tag initial &&
for i in a b c g h i J K L m o n p q; do echo $i; done >file1 && test_write_lines a b c g h i J K L m o n p q >file1 &&
perl -pe "y/mon/\\000\\001\\002/" <file1 >file2 && perl -pe "y/mon/\\000\\001\\002/" <file1 >file2 &&
git commit -a -m second && git commit -a -m second &&

View File

@ -10,25 +10,16 @@ test_description='git apply with rejects
. ./test-lib.sh . ./test-lib.sh
test_expect_success setup ' test_expect_success setup '
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 test_write_lines 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 >file1 &&
do
echo $i
done >file1 &&
cat file1 >saved.file1 && cat file1 >saved.file1 &&
git update-index --add file1 && git update-index --add file1 &&
git commit -m initial && git commit -m initial &&
for i in 1 2 A B 4 5 6 7 8 9 10 11 12 C 13 14 15 16 17 18 19 20 D 21 test_write_lines 1 2 A B 4 5 6 7 8 9 10 11 12 C 13 14 15 16 17 18 19 20 D 21 >file1 &&
do
echo $i
done >file1 &&
git diff >patch.1 && git diff >patch.1 &&
cat file1 >clean && cat file1 >clean &&
for i in 1 E 2 3 4 5 6 7 8 9 10 11 12 C 13 14 15 16 17 18 19 20 F 21 test_write_lines 1 E 2 3 4 5 6 7 8 9 10 11 12 C 13 14 15 16 17 18 19 20 F 21 >expected &&
do
echo $i
done >expected &&
mv file1 file2 && mv file1 file2 &&
git update-index --add --remove file1 file2 && git update-index --add --remove file1 file2 &&
@ -38,10 +29,7 @@ test_expect_success setup '
mv saved.file1 file1 && mv saved.file1 file1 &&
git update-index --add --remove file1 file2 && git update-index --add --remove file1 file2 &&
for i in 1 E 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 F 21 test_write_lines 1 E 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 F 21 >file1 &&
do
echo $i
done >file1 &&
cat file1 >saved.file1 cat file1 >saved.file1
' '

View File

@ -12,11 +12,7 @@ TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh . ./test-lib.sh
test_expect_success setup ' test_expect_success setup '
{ test_write_lines "" "" A B C "" >file1 &&
echo; echo;
echo A; echo B; echo C;
echo;
} >file1 &&
cat file1 >file1.orig && cat file1 >file1.orig &&
{ {
cat file1 && cat file1 &&

View File

@ -47,8 +47,8 @@ test_expect_success 'apply should fail gracefully' '
echo Oops, should not have succeeded echo Oops, should not have succeeded
false false
else else
status=$? status=$? &&
echo "Status was $status" echo "Status was $status" &&
if test -f .git/index.lock if test -f .git/index.lock
then then
echo Oops, should not have crashed echo Oops, should not have crashed

View File

@ -230,10 +230,10 @@ test_expect_success 'blank at EOF with --whitespace=fix (1)' '
test_might_fail git config --unset core.whitespace && test_might_fail git config --unset core.whitespace &&
rm -f .gitattributes && rm -f .gitattributes &&
{ echo a; echo b; echo c; } >one && test_write_lines a b c >one &&
git add one && git add one &&
{ echo a; echo b; echo c; } >expect && test_write_lines a b c >expect &&
{ cat expect; echo; } >one && { cat expect && echo; } >one &&
git diff -- one >patch && git diff -- one >patch &&
git checkout one && git checkout one &&
@ -242,10 +242,10 @@ test_expect_success 'blank at EOF with --whitespace=fix (1)' '
' '
test_expect_success 'blank at EOF with --whitespace=fix (2)' ' test_expect_success 'blank at EOF with --whitespace=fix (2)' '
{ echo a; echo b; echo c; } >one && test_write_lines a b c >one &&
git add one && git add one &&
{ echo a; echo c; } >expect && test_write_lines a b >expect &&
{ cat expect; echo; echo; } >one && { cat expect && test_write_lines "" ""; } >one &&
git diff -- one >patch && git diff -- one >patch &&
git checkout one && git checkout one &&
@ -254,10 +254,10 @@ test_expect_success 'blank at EOF with --whitespace=fix (2)' '
' '
test_expect_success 'blank at EOF with --whitespace=fix (3)' ' test_expect_success 'blank at EOF with --whitespace=fix (3)' '
{ echo a; echo b; echo; } >one && test_write_lines a b "" >one &&
git add one && git add one &&
{ echo a; echo c; echo; } >expect && test_write_lines a c "" >expect &&
{ cat expect; echo; echo; } >one && { cat expect && test_write_lines "" ""; } >one &&
git diff -- one >patch && git diff -- one >patch &&
git checkout one && git checkout one &&
@ -266,9 +266,9 @@ test_expect_success 'blank at EOF with --whitespace=fix (3)' '
' '
test_expect_success 'blank at end of hunk, not at EOF with --whitespace=fix' ' test_expect_success 'blank at end of hunk, not at EOF with --whitespace=fix' '
{ echo a; echo b; echo; echo; echo; echo; echo; echo d; } >one && test_write_lines a b "" "" "" "" "" d >one &&
git add one && git add one &&
{ echo a; echo c; echo; echo; echo; echo; echo; echo; echo d; } >expect && test_write_lines a b "" "" "" "" "" "" d >expect &&
cp expect one && cp expect one &&
git diff -- one >patch && git diff -- one >patch &&
@ -278,7 +278,7 @@ test_expect_success 'blank at end of hunk, not at EOF with --whitespace=fix' '
' '
test_expect_success 'blank at EOF with --whitespace=warn' ' test_expect_success 'blank at EOF with --whitespace=warn' '
{ echo a; echo b; echo c; } >one && test_write_lines a b c >one &&
git add one && git add one &&
echo >>one && echo >>one &&
cat one >expect && cat one >expect &&
@ -291,7 +291,7 @@ test_expect_success 'blank at EOF with --whitespace=warn' '
' '
test_expect_success 'blank at EOF with --whitespace=error' ' test_expect_success 'blank at EOF with --whitespace=error' '
{ echo a; echo b; echo c; } >one && test_write_lines a b c >one &&
git add one && git add one &&
cat one >expect && cat one >expect &&
echo >>one && echo >>one &&
@ -304,7 +304,7 @@ test_expect_success 'blank at EOF with --whitespace=error' '
' '
test_expect_success 'blank but not empty at EOF' ' test_expect_success 'blank but not empty at EOF' '
{ echo a; echo b; echo c; } >one && test_write_lines a b c >one &&
git add one && git add one &&
echo " " >>one && echo " " >>one &&
cat one >expect && cat one >expect &&
@ -317,13 +317,13 @@ test_expect_success 'blank but not empty at EOF' '
' '
test_expect_success 'applying beyond EOF requires one non-blank context line' ' test_expect_success 'applying beyond EOF requires one non-blank context line' '
{ echo; echo; echo; echo; } >one && test_write_lines "" "" "" "" >one &&
git add one && git add one &&
{ echo b; } >>one && echo b >>one &&
git diff -- one >patch && git diff -- one >patch &&
git checkout one && git checkout one &&
{ echo a; echo; } >one && test_write_lines a "" >one &&
cp one expect && cp one expect &&
test_must_fail git apply --whitespace=fix patch && test_must_fail git apply --whitespace=fix patch &&
test_cmp expect one && test_cmp expect one &&
@ -333,7 +333,7 @@ test_expect_success 'applying beyond EOF requires one non-blank context line' '
test_expect_success 'tons of blanks at EOF should not apply' ' test_expect_success 'tons of blanks at EOF should not apply' '
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do
echo; echo; echo; echo; test_write_lines "" "" "" "" || return 1
done >one && done >one &&
git add one && git add one &&
echo a >>one && echo a >>one &&
@ -362,9 +362,9 @@ test_expect_success 'missing blank line at end with --whitespace=fix' '
' '
test_expect_success 'two missing blank lines at end with --whitespace=fix' ' test_expect_success 'two missing blank lines at end with --whitespace=fix' '
{ echo a; echo; echo b; echo c; } >one && test_write_lines a "" b c >one &&
cp one no-blank-lines && cp one no-blank-lines &&
{ echo; echo; } >>one && test_write_lines "" "" >>one &&
git add one && git add one &&
echo d >>one && echo d >>one &&
cp one expect && cp one expect &&
@ -381,9 +381,9 @@ test_expect_success 'two missing blank lines at end with --whitespace=fix' '
' '
test_expect_success 'missing blank line at end, insert before end, --whitespace=fix' ' test_expect_success 'missing blank line at end, insert before end, --whitespace=fix' '
{ echo a; echo; } >one && test_write_lines a "" >one &&
git add one && git add one &&
{ echo b; echo a; echo; } >one && test_write_lines b a "" >one &&
cp one expect && cp one expect &&
git diff -- one >patch && git diff -- one >patch &&
echo a >one && echo a >one &&
@ -393,10 +393,10 @@ test_expect_success 'missing blank line at end, insert before end, --whitespace=
' '
test_expect_success 'shrink file with tons of missing blanks at end of file' ' test_expect_success 'shrink file with tons of missing blanks at end of file' '
{ echo a; echo b; echo c; } >one && test_write_lines a b c >one &&
cp one no-blank-lines && cp one no-blank-lines &&
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do
echo; echo; echo; echo; test_write_lines "" "" "" "" || return 1
done >>one && done >>one &&
git add one && git add one &&
echo a >one && echo a >one &&
@ -412,9 +412,9 @@ test_expect_success 'shrink file with tons of missing blanks at end of file' '
' '
test_expect_success 'missing blanks at EOF must only match blank lines' ' test_expect_success 'missing blanks at EOF must only match blank lines' '
{ echo a; echo b; } >one && test_write_lines a b >one &&
git add one && git add one &&
{ echo c; echo d; } >>one && test_write_lines c d >>one &&
git diff -- one >patch && git diff -- one >patch &&
echo a >one && echo a >one &&
@ -434,9 +434,9 @@ test_expect_success 'missing blank line should match context line with spaces' '
git add one && git add one &&
echo d >>one && echo d >>one &&
git diff -- one >patch && git diff -- one >patch &&
{ echo a; echo b; echo c; } >one && test_write_lines a b c >one &&
cp one expect && cp one expect &&
{ echo; echo d; } >>expect && test_write_lines "" d >>expect &&
git add one && git add one &&
git apply --whitespace=fix patch && git apply --whitespace=fix patch &&
@ -455,7 +455,7 @@ test_expect_success 'same, but with the --ignore-space-option' '
echo d >>one && echo d >>one &&
cp one expect && cp one expect &&
git diff -- one >patch && git diff -- one >patch &&
{ echo a; echo b; echo c; } >one && test_write_lines a b c >one &&
git add one && git add one &&
git checkout-index -f one && git checkout-index -f one &&

View File

@ -10,10 +10,7 @@ test_expect_success setup '
git add file && git add file &&
# file-0 is full of whitespace breakages # file-0 is full of whitespace breakages
for l in a bb c d eeee f ggg h printf "%s \n" a bb c d eeee f ggg h >file-0 &&
do
echo "$l "
done >file-0 &&
# patch-0 creates a whitespace broken file # patch-0 creates a whitespace broken file
cat file-0 >file && cat file-0 >file &&

View File

@ -13,10 +13,7 @@ test_expect_success setup '
git commit -m initial && git commit -m initial &&
git commit --allow-empty -m "empty commit" && git commit --allow-empty -m "empty commit" &&
git format-patch --always HEAD~ >empty.patch && git format-patch --always HEAD~ >empty.patch &&
for i in a b c d e test_write_lines a b c d e >empty &&
do
echo $i
done >empty &&
cat empty >expect && cat empty >expect &&
git diff | git diff |
sed -e "/^diff --git/d" \ sed -e "/^diff --git/d" \

View File

@ -12,10 +12,7 @@ modify () {
} }
test_expect_success setup ' test_expect_success setup '
for i in a b c d e f g h i j k l m test_write_lines a b c d e f g h i j k l m >same_fn &&
do
echo $i
done >same_fn &&
cp same_fn other_fn && cp same_fn other_fn &&
git add same_fn other_fn && git add same_fn other_fn &&
git commit -m initial git commit -m initial

View File

@ -29,8 +29,8 @@ test_expect_success setup '
x=1 && x=1 &&
while test $x -lt $n while test $x -lt $n
do do
printf "%63s%d\n" "" $x >>after printf "%63s%d\n" "" $x >>after &&
x=$(( $x + 1 )) x=$(( $x + 1 )) || return 1
done && done &&
printf "\t%s\n" d e f >>after && printf "\t%s\n" d e f >>after &&
test_expect_code 1 git diff --no-index before after >patch2.patch.raw && test_expect_code 1 git diff --no-index before after >patch2.patch.raw &&
@ -40,8 +40,8 @@ test_expect_success setup '
x=1 && x=1 &&
while test $x -lt $n while test $x -lt $n
do do
printf "%63s%d\n" "" $x >>expect-2 printf "%63s%d\n" "" $x >>expect-2 &&
x=$(( $x + 1 )) x=$(( $x + 1 )) || return 1
done && done &&
printf "%64s\n" d e f >>expect-2 && printf "%64s\n" d e f >>expect-2 &&
@ -52,8 +52,8 @@ test_expect_success setup '
x=0 && x=0 &&
while test $x -lt $n while test $x -lt $n
do do
printf "%63s%02d\n" "" $x >>after printf "%63s%02d\n" "" $x >>after &&
x=$(( $x + 1 )) x=$(( $x + 1 )) || return 1
done && done &&
printf "\t%s\n" d e f >>after && printf "\t%s\n" d e f >>after &&
test_expect_code 1 git diff --no-index before after >patch3.patch.raw && test_expect_code 1 git diff --no-index before after >patch3.patch.raw &&
@ -63,8 +63,8 @@ test_expect_success setup '
x=0 && x=0 &&
while test $x -lt $n while test $x -lt $n
do do
printf "%63s%02d\n" "" $x >>expect-3 printf "%63s%02d\n" "" $x >>expect-3 &&
x=$(( $x + 1 )) x=$(( $x + 1 )) || return 1
done && done &&
printf "%64s\n" d e f >>expect-3 && printf "%64s\n" d e f >>expect-3 &&
@ -73,16 +73,16 @@ test_expect_success setup '
x=0 && x=0 &&
while test $x -lt 50 while test $x -lt 50
do do
printf "\t%02d\n" $x >>before printf "\t%02d\n" $x >>before &&
x=$(( $x + 1 )) x=$(( $x + 1 )) || return 1
done && done &&
cat before >after && cat before >after &&
printf "%64s\n" a b c >>after && printf "%64s\n" a b c >>after &&
while test $x -lt 100 while test $x -lt 100
do do
printf "\t%02d\n" $x >>before printf "\t%02d\n" $x >>before &&
printf "\t%02d\n" $x >>after printf "\t%02d\n" $x >>after &&
x=$(( $x + 1 )) x=$(( $x + 1 )) || return 1
done && done &&
test_expect_code 1 git diff --no-index before after >patch4.patch.raw && test_expect_code 1 git diff --no-index before after >patch4.patch.raw &&
sed -e "s/before/test-4/" -e "s/after/test-4/" patch4.patch.raw >patch4.patch && sed -e "s/before/test-4/" -e "s/after/test-4/" patch4.patch.raw >patch4.patch &&
@ -90,16 +90,16 @@ test_expect_success setup '
x=0 && x=0 &&
while test $x -lt 50 while test $x -lt 50
do do
printf "%63s%02d\n" "" $x >>test-4 printf "%63s%02d\n" "" $x >>test-4 &&
x=$(( $x + 1 )) x=$(( $x + 1 )) || return 1
done && done &&
cat test-4 >expect-4 && cat test-4 >expect-4 &&
printf "%64s\n" a b c >>expect-4 && printf "%64s\n" a b c >>expect-4 &&
while test $x -lt 100 while test $x -lt 100
do do
printf "%63s%02d\n" "" $x >>test-4 printf "%63s%02d\n" "" $x >>test-4 &&
printf "%63s%02d\n" "" $x >>expect-4 printf "%63s%02d\n" "" $x >>expect-4 &&
x=$(( $x + 1 )) x=$(( $x + 1 )) || return 1
done && done &&
git config core.whitespace tab-in-indent,tabwidth=63 && git config core.whitespace tab-in-indent,tabwidth=63 &&

View File

@ -116,7 +116,7 @@ test_expect_success setup '
git format-patch --stdout first | sed -e "1d" git format-patch --stdout first | sed -e "1d"
} | append_cr >patch1-crlf.eml && } | append_cr >patch1-crlf.eml &&
{ {
printf "%255s\\n" "" printf "%255s\\n" "" &&
echo "X-Fake-Field: Line One" && echo "X-Fake-Field: Line One" &&
echo "X-Fake-Field: Line Two" && echo "X-Fake-Field: Line Two" &&
echo "X-Fake-Field: Line Three" && echo "X-Fake-Field: Line Three" &&

View File

@ -5,10 +5,7 @@ test_description='am --abort'
. ./test-lib.sh . ./test-lib.sh
test_expect_success setup ' test_expect_success setup '
for i in a b c d e f g test_write_lines a b c d e f g >file-1 &&
do
echo $i
done >file-1 &&
cp file-1 file-2 && cp file-1 file-2 &&
test_tick && test_tick &&
git add file-1 file-2 && git add file-1 file-2 &&
@ -43,10 +40,7 @@ do
test_must_fail git am$with3 000[1245]-*.patch && test_must_fail git am$with3 000[1245]-*.patch &&
git log --pretty=tformat:%s >actual && git log --pretty=tformat:%s >actual &&
for i in 3 2 initial test_write_lines 3 2 initial >expect &&
do
echo $i
done >expect &&
test_cmp expect actual test_cmp expect actual
' '

View File

@ -120,48 +120,48 @@ test_expect_success 'diff-filter=A' '
test_expect_success 'diff-filter=M' ' test_expect_success 'diff-filter=M' '
actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) && git log --pretty="format:%s" --diff-filter=M HEAD >actual &&
expect=$(echo second) && printf "second" >expect &&
verbose test "$actual" = "$expect" test_cmp expect actual
' '
test_expect_success 'diff-filter=D' ' test_expect_success 'diff-filter=D' '
actual=$(git log --no-renames --pretty="format:%s" --diff-filter=D HEAD) && git log --no-renames --pretty="format:%s" --diff-filter=D HEAD >actual &&
expect=$(echo sixth ; echo third) && printf "sixth\nthird" >expect &&
verbose test "$actual" = "$expect" test_cmp expect actual
' '
test_expect_success 'diff-filter=R' ' test_expect_success 'diff-filter=R' '
actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) && git log -M --pretty="format:%s" --diff-filter=R HEAD >actual &&
expect=$(echo third) && printf "third" >expect &&
verbose test "$actual" = "$expect" test_cmp expect actual
' '
test_expect_success 'diff-filter=C' ' test_expect_success 'diff-filter=C' '
actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) && git log -C -C --pretty="format:%s" --diff-filter=C HEAD >actual &&
expect=$(echo fourth) && printf "fourth" >expect &&
verbose test "$actual" = "$expect" test_cmp expect actual
' '
test_expect_success 'git log --follow' ' test_expect_success 'git log --follow' '
actual=$(git log --follow --pretty="format:%s" ichi) && git log --follow --pretty="format:%s" ichi >actual &&
expect=$(echo third ; echo second ; echo initial) && printf "third\nsecond\ninitial" >expect &&
verbose test "$actual" = "$expect" test_cmp expect actual
' '
test_expect_success 'git config log.follow works like --follow' ' test_expect_success 'git config log.follow works like --follow' '
test_config log.follow true && test_config log.follow true &&
actual=$(git log --pretty="format:%s" ichi) && git log --pretty="format:%s" ichi >actual &&
expect=$(echo third ; echo second ; echo initial) && printf "third\nsecond\ninitial" >expect &&
verbose test "$actual" = "$expect" test_cmp expect actual
' '
test_expect_success 'git config log.follow does not die with multiple paths' ' test_expect_success 'git config log.follow does not die with multiple paths' '
@ -176,9 +176,9 @@ test_expect_success 'git config log.follow does not die with no paths' '
test_expect_success 'git config log.follow is overridden by --no-follow' ' test_expect_success 'git config log.follow is overridden by --no-follow' '
test_config log.follow true && test_config log.follow true &&
actual=$(git log --no-follow --pretty="format:%s" ichi) && git log --no-follow --pretty="format:%s" ichi >actual &&
expect="third" && printf "third" >expect &&
verbose test "$actual" = "$expect" test_cmp expect actual
' '
# Note that these commits are intentionally listed out of order. # Note that these commits are intentionally listed out of order.

View File

@ -976,7 +976,7 @@ test_expect_success '%(describe) vs git describe' '
else else
: >expect-contains-bad : >expect-contains-bad
fi && fi &&
echo "$hash $desc" echo "$hash $desc" || return 1
done >expect && done >expect &&
test_path_exists expect-contains-good && test_path_exists expect-contains-good &&
test_path_exists expect-contains-bad && test_path_exists expect-contains-bad &&

View File

@ -137,7 +137,7 @@ test_expect_success 'range_set_union' '
test_seq 1000 > c.c && test_seq 1000 > c.c &&
git add c.c && git add c.c &&
git commit -m "modify many lines" && git commit -m "modify many lines" &&
git log $(for x in $(test_seq 200); do echo -L $((2*x)),+1:c.c; done) git log $(for x in $(test_seq 200); do echo -L $((2*x)),+1:c.c || return 1; done)
' '
test_expect_success '-s shows only line-log commits' ' test_expect_success '-s shows only line-log commits' '

View File

@ -20,10 +20,10 @@ test_expect_success 'fsck notices broken commit' '
test_expect_success 'git log with broken author email' ' test_expect_success 'git log with broken author email' '
{ {
echo commit $(cat broken_email.hash) echo commit $(cat broken_email.hash) &&
echo "Author: A U Thor <author@example.com>" echo "Author: A U Thor <author@example.com>" &&
echo "Date: Thu Apr 7 15:13:13 2005 -0700" echo "Date: Thu Apr 7 15:13:13 2005 -0700" &&
echo echo &&
echo " foo" echo " foo"
} >expect.out && } >expect.out &&

View File

@ -374,7 +374,7 @@ test_expect_success 'Bloom generation backfills empty commits' '
cd empty && cd empty &&
for i in $(test_seq 1 6) for i in $(test_seq 1 6)
do do
git commit --allow-empty -m "$i" git commit --allow-empty -m "$i" || return 1
done && done &&
# Generate Bloom filters for empty commits 1-6, two at a time. # Generate Bloom filters for empty commits 1-6, two at a time.
@ -387,7 +387,7 @@ test_expect_success 'Bloom generation backfills empty commits' '
test_filter_computed 2 trace.event && test_filter_computed 2 trace.event &&
test_filter_not_computed 4 trace.event && test_filter_not_computed 4 trace.event &&
test_filter_trunc_empty 2 trace.event && test_filter_trunc_empty 2 trace.event &&
test_filter_trunc_large 0 trace.event test_filter_trunc_large 0 trace.event || return 1
done && done &&
# Finally, make sure that once all commits have filters, that # Finally, make sure that once all commits have filters, that

View File

@ -77,7 +77,7 @@ check_tar() {
path=$(get_pax_header $header path) && path=$(get_pax_header $header path) &&
if test -n "$path" if test -n "$path"
then then
mv "$data" "$path" mv "$data" "$path" || exit 1
fi fi
fi fi
done done
@ -133,7 +133,7 @@ test_expect_success 'populate workdir' '
for depth in 1 2 3 4 5 for depth in 1 2 3 4 5
do do
mkdir $p && mkdir $p &&
cd $p cd $p || exit 1
done && done &&
echo text >file_with_long_path echo text >file_with_long_path
) && ) &&

View File

@ -106,7 +106,7 @@ test_expect_success \
printf "A\$Format:%s\$O" "$SUBSTFORMAT" >a/substfile1 && printf "A\$Format:%s\$O" "$SUBSTFORMAT" >a/substfile1 &&
printf "A not substituted O" >a/substfile2 && printf "A not substituted O" >a/substfile2 &&
(p=long_path_to_a_file && cd a && (p=long_path_to_a_file && cd a &&
for depth in 1 2 3 4 5; do mkdir $p && cd $p; done && for depth in 1 2 3 4 5; do mkdir $p && cd $p || exit 1; done &&
echo text >file_with_long_path) echo text >file_with_long_path)
' '

View File

@ -131,7 +131,7 @@ test_expect_success ZIPINFO 'zip archive with many entries' '
do do
for b in 0 1 2 3 4 5 6 7 8 9 a b c d e f for b in 0 1 2 3 4 5 6 7 8 9 a b c d e f
do do
: >00/$a$b : >00/$a$b || return 1
done done
done && done &&
git add 00 && git add 00 &&
@ -143,7 +143,7 @@ test_expect_success ZIPINFO 'zip archive with many entries' '
do do
for d in 0 1 2 3 4 5 6 7 8 9 a b c d e f for d in 0 1 2 3 4 5 6 7 8 9 a b c d e f
do do
echo "040000 tree $subtree $c$d" echo "040000 tree $subtree $c$d" || return 1
done done
done >tree && done >tree &&
tree=$(git mktree <tree) && tree=$(git mktree <tree) &&
@ -171,7 +171,7 @@ test_expect_success EXPENSIVE,UNZIP,UNZIP_ZIP64_SUPPORT \
# create tree containing 65500 entries of that blob # create tree containing 65500 entries of that blob
for i in $(test_seq 1 65500) for i in $(test_seq 1 65500)
do do
echo "100644 blob $blob $i" echo "100644 blob $blob $i" || return 1
done >tree && done >tree &&
tree=$(git mktree <tree) && tree=$(git mktree <tree) &&

View File

@ -122,7 +122,7 @@ test_expect_success 'mailinfo unescapes with --mboxrd' '
do do
git mailinfo mboxrd/msg mboxrd/patch \ git mailinfo mboxrd/msg mboxrd/patch \
<mboxrd/$i >mboxrd/out && <mboxrd/$i >mboxrd/out &&
test_cmp "$DATA/${i}mboxrd" mboxrd/msg test_cmp "$DATA/${i}mboxrd" mboxrd/msg || return 1
done && done &&
sp=" " && sp=" " &&
echo "From " >expect && echo "From " >expect &&

View File

@ -347,7 +347,7 @@ test_expect_success 'unpacking with --strict' '
for i in 0 1 2 3 4 5 6 7 8 9 for i in 0 1 2 3 4 5 6 7 8 9
do do
o=$(echo $j$i | git hash-object -w --stdin) && o=$(echo $j$i | git hash-object -w --stdin) &&
echo "100644 $o 0 $j$i" echo "100644 $o 0 $j$i" || return 1
done done
done >LIST && done >LIST &&
rm -f .git/index && rm -f .git/index &&
@ -361,11 +361,7 @@ test_expect_success 'unpacking with --strict' '
ST=$(git write-tree) && ST=$(git write-tree) &&
git rev-list --objects "$LIST" "$LI" "$ST" >actual && git rev-list --objects "$LIST" "$LI" "$ST" >actual &&
PACK5=$( git pack-objects test-5 <actual ) && PACK5=$( git pack-objects test-5 <actual ) &&
PACK6=$( ( PACK6=$( test_write_lines "$LIST" "$LI" "$ST" | git pack-objects test-6 ) &&
echo "$LIST"
echo "$LI"
echo "$ST"
) | git pack-objects test-6 ) &&
test_create_repo test-5 && test_create_repo test-5 &&
( (
cd test-5 && cd test-5 &&
@ -394,7 +390,7 @@ test_expect_success 'index-pack with --strict' '
for i in 0 1 2 3 4 5 6 7 8 9 for i in 0 1 2 3 4 5 6 7 8 9
do do
o=$(echo $j$i | git hash-object -w --stdin) && o=$(echo $j$i | git hash-object -w --stdin) &&
echo "100644 $o 0 $j$i" echo "100644 $o 0 $j$i" || return 1
done done
done >LIST && done >LIST &&
rm -f .git/index && rm -f .git/index &&
@ -408,11 +404,7 @@ test_expect_success 'index-pack with --strict' '
ST=$(git write-tree) && ST=$(git write-tree) &&
git rev-list --objects "$LIST" "$LI" "$ST" >actual && git rev-list --objects "$LIST" "$LI" "$ST" >actual &&
PACK5=$( git pack-objects test-5 <actual ) && PACK5=$( git pack-objects test-5 <actual ) &&
PACK6=$( ( PACK6=$( test_write_lines "$LIST" "$LI" "$ST" | git pack-objects test-6 ) &&
echo "$LIST"
echo "$LI"
echo "$ST"
) | git pack-objects test-6 ) &&
test_create_repo test-7 && test_create_repo test-7 &&
( (
cd test-7 && cd test-7 &&
@ -594,7 +586,7 @@ test_expect_success 'setup for --stdin-packs tests' '
for id in A B C for id in A B C
do do
git pack-objects .git/objects/pack/pack-$id \ git pack-objects .git/objects/pack/pack-$id \
--incremental --revs <<-EOF --incremental --revs <<-EOF || exit 1
refs/tags/$id refs/tags/$id
EOF EOF
done && done &&

View File

@ -14,7 +14,7 @@ test_expect_success 'setup' '
i=1 && i=1 &&
while test $i -le 100 while test $i -le 100
do do
iii=$(printf "%03i" $i) iii=$(printf "%03i" $i) &&
test-tool genrandom "bar" 200 > wide_delta_$iii && test-tool genrandom "bar" 200 > wide_delta_$iii &&
test-tool genrandom "baz $iii" 50 >> wide_delta_$iii && test-tool genrandom "baz $iii" 50 >> wide_delta_$iii &&
test-tool genrandom "foo"$i 100 > deep_delta_$iii && test-tool genrandom "foo"$i 100 > deep_delta_$iii &&

View File

@ -12,7 +12,7 @@ test_description='git-pack-object with missing base
# #
test_expect_success \ test_expect_success \
'setup base' \ 'setup base' \
'for a in a b c d e f g h i; do echo $a >>text; done && 'test_write_lines a b c d e f g h i >text &&
echo side >side && echo side >side &&
git update-index --add text side && git update-index --add text side &&
A=$(echo A | git commit-tree $(git write-tree)) && A=$(echo A | git commit-tree $(git write-tree)) &&

View File

@ -12,7 +12,7 @@ test_expect_success setup '
git add "file$i" && git add "file$i" &&
test_tick && test_tick &&
git commit -m "$i" && git commit -m "$i" &&
git tag "tag$i" git tag "tag$i" || return 1
done && done &&
obj=$(git rev-parse --verify tag3) && obj=$(git rev-parse --verify tag3) &&
fanout=$(expr "$obj" : "\(..\)") && fanout=$(expr "$obj" : "\(..\)") &&

View File

@ -228,7 +228,7 @@ test_expect_success 'pack reuse respects --honor-pack-keep' '
test_when_finished "rm -f .git/objects/pack/*.keep" && test_when_finished "rm -f .git/objects/pack/*.keep" &&
for i in .git/objects/pack/*.pack for i in .git/objects/pack/*.pack
do do
>${i%.pack}.keep >${i%.pack}.keep || return 1
done && done &&
reusable_pack --honor-pack-keep >empty.pack && reusable_pack --honor-pack-keep >empty.pack &&
git index-pack empty.pack && git index-pack empty.pack &&

View File

@ -57,8 +57,11 @@ test_expect_success 'create series of packs' '
git commit -m $i && git commit -m $i &&
cur=$(git rev-parse HEAD^{tree}) && cur=$(git rev-parse HEAD^{tree}) &&
{ {
test -n "$prev" && echo "-$prev" if test -n "$prev"
echo $cur then
echo "-$prev"
fi &&
echo $cur &&
echo "$(git rev-parse :file) file" echo "$(git rev-parse :file) file"
} | git pack-objects --stdout >tmp && } | git pack-objects --stdout >tmp &&
git index-pack --stdin --fix-thin <tmp || return 1 git index-pack --stdin --fix-thin <tmp || return 1

View File

@ -16,9 +16,9 @@ test_expect_success 'setup r1' '
git init r1 && git init r1 &&
for n in 1 2 3 4 5 for n in 1 2 3 4 5
do do
echo "This is file: $n" > r1/file.$n echo "This is file: $n" > r1/file.$n &&
git -C r1 add file.$n git -C r1 add file.$n &&
git -C r1 commit -m "$n" git -C r1 commit -m "$n" || return 1
done done
' '
@ -116,9 +116,9 @@ test_expect_success 'setup r2' '
git init r2 && git init r2 &&
for n in 1000 10000 for n in 1000 10000
do do
printf "%"$n"s" X > r2/large.$n printf "%"$n"s" X > r2/large.$n &&
git -C r2 add large.$n git -C r2 add large.$n &&
git -C r2 commit -m "$n" git -C r2 commit -m "$n" || return 1
done done
' '
@ -278,10 +278,10 @@ test_expect_success 'setup r3' '
mkdir r3/dir1 && mkdir r3/dir1 &&
for n in sparse1 sparse2 for n in sparse1 sparse2
do do
echo "This is file: $n" > r3/$n echo "This is file: $n" > r3/$n &&
git -C r3 add $n git -C r3 add $n &&
echo "This is file: dir1/$n" > r3/dir1/$n echo "This is file: dir1/$n" > r3/dir1/$n &&
git -C r3 add dir1/$n git -C r3 add dir1/$n || return 1
done && done &&
git -C r3 commit -m "sparse" && git -C r3 commit -m "sparse" &&
echo dir1/ >pattern1 && echo dir1/ >pattern1 &&
@ -331,10 +331,10 @@ test_expect_success 'setup r4' '
mkdir r4/dir1 && mkdir r4/dir1 &&
for n in sparse1 sparse2 for n in sparse1 sparse2
do do
echo "This is file: $n" > r4/$n echo "This is file: $n" > r4/$n &&
git -C r4 add $n git -C r4 add $n &&
echo "This is file: dir1/$n" > r4/dir1/$n echo "This is file: dir1/$n" > r4/dir1/$n &&
git -C r4 add dir1/$n git -C r4 add dir1/$n || return 1
done && done &&
echo dir1/ >r4/pattern && echo dir1/ >r4/pattern &&
git -C r4 add pattern && git -C r4 add pattern &&
@ -409,7 +409,7 @@ test_expect_success 'setup r1 - delete loose blobs' '
for id in `cat expected | sed "s|..|&/|"` for id in `cat expected | sed "s|..|&/|"`
do do
rm r1/.git/objects/$id rm r1/.git/objects/$id || return 1
done done
' '

View File

@ -64,7 +64,7 @@ test_expect_success 'create commits and repack' '
for i in $(test_seq 3) for i in $(test_seq 3)
do do
test_commit $i && test_commit $i &&
git branch commits/$i git branch commits/$i || return 1
done && done &&
git repack git repack
' '
@ -147,13 +147,13 @@ test_expect_success 'Add more commits' '
for i in $(test_seq 4 5) for i in $(test_seq 4 5)
do do
test_commit $i && test_commit $i &&
git branch commits/$i git branch commits/$i || return 1
done && done &&
git reset --hard commits/2 && git reset --hard commits/2 &&
for i in $(test_seq 6 7) for i in $(test_seq 6 7)
do do
test_commit $i && test_commit $i &&
git branch commits/$i git branch commits/$i || return 1
done && done &&
git reset --hard commits/2 && git reset --hard commits/2 &&
git merge commits/4 && git merge commits/4 &&

Some files were not shown because too many files have changed in this diff Show More