Merge branch 'md/test-cleanup'

Various test scripts have been updated for style and also correct
handling of exit status of various commands.

* md/test-cleanup:
  tests: order arguments to git-rev-list properly
  t9109: don't swallow Git errors upstream of pipes
  tests: don't swallow Git errors upstream of pipes
  t/*: fix ordering of expected/observed arguments
  tests: standardize pipe placement
  Documentation: add shell guidelines
  t/README: reformat Do, Don't, Keep in mind lists
This commit is contained in:
Junio C Hamano 2018-10-16 16:16:01 +09:00
commit f2e2136ad7
39 changed files with 568 additions and 399 deletions

View File

@ -118,6 +118,24 @@ For shell scripts specifically (not exhaustive):
do this do this
fi fi
- If a command sequence joined with && or || or | spans multiple
lines, put each command on a separate line and put && and || and |
operators at the end of each line, rather than the start. This
means you don't need to use \ to join lines, since the above
operators imply the sequence isn't finished.
(incorrect)
grep blob verify_pack_result \
| awk -f print_1.awk \
| sort >actual &&
...
(correct)
grep blob verify_pack_result |
awk -f print_1.awk |
sort >actual &&
...
- We prefer "test" over "[ ... ]". - We prefer "test" over "[ ... ]".
- We do not write the noiseword "function" in front of shell - We do not write the noiseword "function" in front of shell

View File

@ -401,13 +401,13 @@ This test harness library does the following things:
consistently when command line arguments --verbose (or -v), consistently when command line arguments --verbose (or -v),
--debug (or -d), and --immediate (or -i) is given. --debug (or -d), and --immediate (or -i) is given.
Do's, don'ts & things to keep in mind Do's & don'ts
------------------------------------- -------------
Here are a few examples of things you probably should and shouldn't do Here are a few examples of things you probably should and shouldn't do
when writing tests. when writing tests.
Do: Here are the "do's:"
- Put all code inside test_expect_success and other assertions. - Put all code inside test_expect_success and other assertions.
@ -452,16 +452,21 @@ Do:
Windows, where the shell (MSYS bash) mangles absolute path names. Windows, where the shell (MSYS bash) mangles absolute path names.
For details, see the commit message of 4114156ae9. For details, see the commit message of 4114156ae9.
Don't: - Remember that inside the <script> part, the standard output and
standard error streams are discarded, and the test harness only
reports "ok" or "not ok" to the end user running the tests. Under
--verbose, they are shown to help debug the tests.
- exit() within a <script> part. And here are the "don'ts:"
- Don't exit() within a <script> part.
The harness will catch this as a programming error of the test. The harness will catch this as a programming error of the test.
Use test_done instead if you need to stop the tests early (see Use test_done instead if you need to stop the tests early (see
"Skipping tests" below). "Skipping tests" below).
- use '! git cmd' when you want to make sure the git command exits - Don't use '! git cmd' when you want to make sure the git command
with failure in a controlled way by calling "die()". Instead, exits with failure in a controlled way by calling "die()". Instead,
use 'test_must_fail git cmd'. This will signal a failure if git use 'test_must_fail git cmd'. This will signal a failure if git
dies in an unexpected way (e.g. segfault). dies in an unexpected way (e.g. segfault).
@ -469,8 +474,35 @@ Don't:
platform commands; just use '! cmd'. We are not in the business platform commands; just use '! cmd'. We are not in the business
of verifying that the world given to us sanely works. of verifying that the world given to us sanely works.
- use perl without spelling it as "$PERL_PATH". This is to help our - Don't feed the output of a git command to a pipe, as in:
friends on Windows where the platform Perl often adds CR before
git -C repo ls-files |
xargs -n 1 basename |
grep foo
which will discard git's exit code and may mask a crash. In the
above example, all exit codes are ignored except grep's.
Instead, write the output of that command to a temporary
file with ">" or assign it to a variable with "x=$(git ...)" rather
than pipe it.
- Don't use command substitution in a way that discards git's exit
code. When assigning to a variable, the exit code is not discarded,
e.g.:
x=$(git cat-file -p $sha) &&
...
is OK because a crash in "git cat-file" will cause the "&&" chain
to fail, but:
test "refs/heads/foo" = "$(git symbolic-ref HEAD)"
is not OK and a crash in git could go undetected.
- Don't use perl without spelling it as "$PERL_PATH". This is to help
our friends on Windows where the platform Perl often adds CR before
the end of line, and they bundle Git with a version of Perl that the end of line, and they bundle Git with a version of Perl that
does not do so, whose path is specified with $PERL_PATH. Note that we does not do so, whose path is specified with $PERL_PATH. Note that we
provide a "perl" function which uses $PERL_PATH under the hood, so provide a "perl" function which uses $PERL_PATH under the hood, so
@ -478,17 +510,17 @@ Don't:
(but you do, for example, on a shebang line or in a sub script (but you do, for example, on a shebang line or in a sub script
created via "write_script"). created via "write_script").
- use sh without spelling it as "$SHELL_PATH", when the script can - Don't use sh without spelling it as "$SHELL_PATH", when the script
be misinterpreted by broken platform shell (e.g. Solaris). can be misinterpreted by broken platform shell (e.g. Solaris).
- chdir around in tests. It is not sufficient to chdir to - Don't chdir around in tests. It is not sufficient to chdir to
somewhere and then chdir back to the original location later in somewhere and then chdir back to the original location later in
the test, as any intermediate step can fail and abort the test, the test, as any intermediate step can fail and abort the test,
causing the next test to start in an unexpected directory. Do so causing the next test to start in an unexpected directory. Do so
inside a subshell if necessary. inside a subshell if necessary.
- save and verify the standard error of compound commands, i.e. group - Don't save and verify the standard error of compound commands, i.e.
commands, subshells, and shell functions (except test helper group commands, subshells, and shell functions (except test helper
functions like 'test_must_fail') like this: functions like 'test_must_fail') like this:
( cd dir && git cmd ) 2>error && ( cd dir && git cmd ) 2>error &&
@ -503,7 +535,7 @@ Don't:
( cd dir && git cmd 2>../error ) && ( cd dir && git cmd 2>../error ) &&
test_cmp expect error test_cmp expect error
- Break the TAP output - Don't break the TAP output
The raw output from your test may be interpreted by a TAP harness. TAP The raw output from your test may be interpreted by a TAP harness. TAP
harnesses will ignore everything they don't know about, but don't step harnesses will ignore everything they don't know about, but don't step
@ -523,13 +555,6 @@ Don't:
but the best indication is to just run the tests with prove(1), but the best indication is to just run the tests with prove(1),
it'll complain if anything is amiss. it'll complain if anything is amiss.
Keep in mind:
- Inside the <script> part, the standard output and standard error
streams are discarded, and the test harness only reports "ok" or
"not ok" to the end user running the tests. Under --verbose, they
are shown to help debugging the tests.
Skipping tests Skipping tests
-------------- --------------

View File

@ -57,9 +57,12 @@ then
echo | gpgsm --homedir "${GNUPGHOME}" 2>/dev/null \ echo | gpgsm --homedir "${GNUPGHOME}" 2>/dev/null \
--passphrase-fd 0 --pinentry-mode loopback \ --passphrase-fd 0 --pinentry-mode loopback \
--import "$TEST_DIRECTORY"/lib-gpg/gpgsm_cert.p12 && --import "$TEST_DIRECTORY"/lib-gpg/gpgsm_cert.p12 &&
gpgsm --homedir "${GNUPGHOME}" 2>/dev/null -K \
| grep fingerprint: | cut -d" " -f4 | tr -d '\n' > \ gpgsm --homedir "${GNUPGHOME}" 2>/dev/null -K |
${GNUPGHOME}/trustlist.txt && grep fingerprint: |
cut -d" " -f4 |
tr -d '\n' >"${GNUPGHOME}/trustlist.txt" &&
echo " S relax" >> ${GNUPGHOME}/trustlist.txt && echo " S relax" >> ${GNUPGHOME}/trustlist.txt &&
(gpgconf --kill gpg-agent >/dev/null 2>&1 || : ) && (gpgconf --kill gpg-agent >/dev/null 2>&1 || : ) &&
echo hello | gpgsm --homedir "${GNUPGHOME}" >/dev/null \ echo hello | gpgsm --homedir "${GNUPGHOME}" >/dev/null \

View File

@ -1097,7 +1097,7 @@ test_expect_success 'validate git diff-files output for a know cache/work tree s
:120000 120000 $(test_oid subp3s) $ZERO_OID M path3/subp3/file3sym :120000 120000 $(test_oid subp3s) $ZERO_OID M path3/subp3/file3sym
EOF EOF
git diff-files >current && git diff-files >current &&
test_cmp current expected test_cmp expected current
' '
test_expect_success 'git update-index --refresh should succeed' ' test_expect_success 'git update-index --refresh should succeed' '

View File

@ -166,10 +166,10 @@ test_expect_success expanded_in_repo '
rm -f expanded-keywords expanded-keywords-crlf && rm -f expanded-keywords expanded-keywords-crlf &&
git checkout -- expanded-keywords && git checkout -- expanded-keywords &&
test_cmp expanded-keywords expected-output && test_cmp expected-output expanded-keywords &&
git checkout -- expanded-keywords-crlf && git checkout -- expanded-keywords-crlf &&
test_cmp expanded-keywords-crlf expected-output-crlf test_cmp expected-output-crlf expanded-keywords-crlf
' '
# The use of %f in a filter definition is expanded to the path to # The use of %f in a filter definition is expanded to the path to

View File

@ -220,8 +220,8 @@ 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)"
' '
test_expect_success "--batch for an existent and a non-existent hash" ' test_expect_success "--batch for an existent and a non-existent hash" '
@ -229,8 +229,8 @@ test_expect_success "--batch for an existent and a non-existent hash" '
$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)"
' '
test_expect_success "--batch-check for an empty line" ' test_expect_success "--batch-check for an empty line" '

View File

@ -1001,7 +1001,7 @@ EOF
test_expect_success 'value continued on next line' ' test_expect_success 'value continued on next line' '
git config --list > result && git config --list > result &&
test_cmp result expect test_cmp expect result
' '
cat > .git/config <<\EOF cat > .git/config <<\EOF
@ -1770,8 +1770,9 @@ test_expect_success '--show-origin stdin with file include' '
cat >expect <<-EOF && cat >expect <<-EOF &&
file:$INCLUDE_DIR/stdin.include include file:$INCLUDE_DIR/stdin.include include
EOF EOF
echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" \ echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" |
| git config --show-origin --includes --file - user.stdin >output && git config --show-origin --includes --file - user.stdin >output &&
test_cmp expect output test_cmp expect output
' '
@ -1881,7 +1882,7 @@ test_expect_success '--replace-all does not invent newlines' '
Qkey = b Qkey = b
EOF EOF
git config --replace-all abc.key b && git config --replace-all abc.key b &&
test_cmp .git/config expect test_cmp expect .git/config
' '
test_done test_done

View File

@ -14,7 +14,7 @@ setup() {
check() { check() {
echo "$2" >expected echo "$2" >expected
git config --get "$1" >actual 2>&1 git config --get "$1" >actual 2>&1
test_cmp actual expected test_cmp expected actual
} }
# 'check section.key regex value' verifies that the entry for # 'check section.key regex value' verifies that the entry for
@ -22,7 +22,7 @@ check() {
check_regex() { check_regex() {
echo "$3" >expected echo "$3" >expected
git config --get "$1" "$2" >actual 2>&1 git config --get "$1" "$2" >actual 2>&1
test_cmp actual expected test_cmp expected actual
} }
test_expect_success 'modify same key' ' test_expect_success 'modify same key' '

View File

@ -73,7 +73,7 @@ test_expect_success 'update-index --update from subdir' '
100644 $(git hash-object dir1/file3) 0 dir1/file3 100644 $(git hash-object dir1/file3) 0 dir1/file3
100644 $file2 0 file2 100644 $file2 0 file2
EOF EOF
test_cmp current expected test_cmp expected current
' '
test_expect_success 'update-index --update with pathspec' ' test_expect_success 'update-index --update with pathspec' '

View File

@ -1221,7 +1221,7 @@ test_expect_success 'use --edit-description' '
EOF EOF
EDITOR=./editor git branch --edit-description && EDITOR=./editor git branch --edit-description &&
echo "New contents" >expect && echo "New contents" >expect &&
test_cmp EDITOR_OUTPUT expect test_cmp expect EDITOR_OUTPUT
' '
test_expect_success 'detect typo in branch name when using --edit-description' ' test_expect_success 'detect typo in branch name when using --edit-description' '

View File

@ -44,7 +44,7 @@ test_expect_success 'merge z into y fails and sets NOTES_MERGE_REF' '
git config core.notesRef refs/notes/y && git config core.notesRef refs/notes/y &&
test_must_fail git notes merge z && test_must_fail git notes merge z &&
echo "ref: refs/notes/y" >expect && echo "ref: refs/notes/y" >expect &&
test_cmp .git/NOTES_MERGE_REF expect test_cmp expect .git/NOTES_MERGE_REF
' '
test_expect_success 'merge z into y while mid-merge in another workdir fails' ' test_expect_success 'merge z into y while mid-merge in another workdir fails' '
@ -66,7 +66,7 @@ test_expect_success 'merge z into x while mid-merge on y succeeds' '
grep -v "A notes merge into refs/notes/x is already in-progress in" out grep -v "A notes merge into refs/notes/x is already in-progress in" out
) && ) &&
echo "ref: refs/notes/x" >expect && echo "ref: refs/notes/x" >expect &&
test_cmp .git/worktrees/worktree2/NOTES_MERGE_REF expect test_cmp expect .git/worktrees/worktree2/NOTES_MERGE_REF
' '
test_done test_done

View File

@ -183,13 +183,13 @@ test_expect_success 'cherry-picked commits and fork-point work together' '
test_commit final_B B "Final B" && test_commit final_B B "Final B" &&
git rebase && git rebase &&
echo Amended >expect && echo Amended >expect &&
test_cmp A expect && test_cmp expect A &&
echo "Final B" >expect && echo "Final B" >expect &&
test_cmp B expect && test_cmp expect B &&
echo C >expect && echo C >expect &&
test_cmp C expect && test_cmp expect C &&
echo D >expect && echo D >expect &&
test_cmp D expect test_cmp expect D
' '
test_expect_success 'rebase -q is quiet' ' test_expect_success 'rebase -q is quiet' '

View File

@ -55,7 +55,7 @@ test_expect_success 'blank line at end of file; extend at end of file' '
git add file && git commit -m second && git add file && git commit -m second &&
git rebase --whitespace=fix HEAD^^ && git rebase --whitespace=fix HEAD^^ &&
git diff --exit-code HEAD^:file expect-first && git diff --exit-code HEAD^:file expect-first &&
test_cmp file expect-second test_cmp expect-second file
' '
# prepare third revision of "file" # prepare third revision of "file"
@ -82,7 +82,7 @@ test_expect_success 'two blanks line at end of file; extend at end of file' '
cp third file && git add file && git commit -m third && cp third file && git add file && git commit -m third &&
git rebase --whitespace=fix HEAD^^ && git rebase --whitespace=fix HEAD^^ &&
git diff --exit-code HEAD^:file expect-second && git diff --exit-code HEAD^:file expect-second &&
test_cmp file expect-third test_cmp expect-third file
' '
test_expect_success 'same, but do not remove trailing spaces' ' test_expect_success 'same, but do not remove trailing spaces' '
@ -120,7 +120,7 @@ test_expect_success 'at beginning of file' '
done >> file && done >> file &&
git commit -m more file && git commit -m more file &&
git rebase --whitespace=fix HEAD^^ && git rebase --whitespace=fix HEAD^^ &&
test_cmp file expect-beginning test_cmp expect-beginning file
' '
test_done test_done

View File

@ -110,10 +110,10 @@ test_expect_success 'add -e' '
cp second-part file && cp second-part file &&
git add -e && git add -e &&
test_cmp second-part file && test_cmp second-part file &&
test_cmp orig-patch expected-patch && test_cmp expected-patch orig-patch &&
git diff --cached >actual && git diff --cached >actual &&
grep -v index actual >out && grep -v index actual >out &&
test_cmp out expected test_cmp expected out
' '

View File

@ -36,7 +36,7 @@ EOF
test_expect_success 'parents of stash' ' test_expect_success 'parents of stash' '
test $(git rev-parse stash^) = $(git rev-parse HEAD) && test $(git rev-parse stash^) = $(git rev-parse HEAD) &&
git diff stash^2..stash > output && git diff stash^2..stash > output &&
test_cmp output expect test_cmp expect output
' '
test_expect_success 'applying bogus stash does nothing' ' test_expect_success 'applying bogus stash does nothing' '
@ -210,9 +210,9 @@ test_expect_success 'stash branch' '
test refs/heads/stashbranch = $(git symbolic-ref HEAD) && test refs/heads/stashbranch = $(git symbolic-ref HEAD) &&
test $(git rev-parse HEAD) = $(git rev-parse master^) && test $(git rev-parse HEAD) = $(git rev-parse master^) &&
git diff --cached > output && git diff --cached > output &&
test_cmp output expect && test_cmp expect output &&
git diff > output && git diff > output &&
test_cmp output expect1 && test_cmp expect1 output &&
git add file && git add file &&
git commit -m alternate\ second && git commit -m alternate\ second &&
git diff master..stashbranch > output && git diff master..stashbranch > output &&
@ -710,7 +710,7 @@ test_expect_success 'stash where working directory contains "HEAD" file' '
git diff-index --cached --quiet HEAD && git diff-index --cached --quiet HEAD &&
test "$(git rev-parse stash^)" = "$(git rev-parse HEAD)" && test "$(git rev-parse stash^)" = "$(git rev-parse HEAD)" &&
git diff stash^..stash > output && git diff stash^..stash > output &&
test_cmp output expect test_cmp expect output
' '
test_expect_success 'store called with invalid commit' ' test_expect_success 'store called with invalid commit' '

View File

@ -142,7 +142,7 @@ test_expect_success 'stash save --include-untracked removed files' '
rm -f file && rm -f file &&
git stash save --include-untracked && git stash save --include-untracked &&
echo 1 > expect && echo 1 > expect &&
test_cmp file expect test_cmp expect file
' '
rm -f expect rm -f expect

View File

@ -37,7 +37,7 @@ test_expect_success 'hunk header truncation with an overly long line' '
echo " A $N$N$N$N$N$N$N$N$N2" && echo " A $N$N$N$N$N$N$N$N$N2" &&
echo " L $N$N$N$N$N$N$N$N$N1" echo " L $N$N$N$N$N$N$N$N$N1"
) >expected && ) >expected &&
test_cmp actual expected test_cmp expected actual
' '

View File

@ -72,7 +72,7 @@ test_expect_success 'apply with --reject should fail but update the file' '
rm -f file1.rej file2.rej && rm -f file1.rej file2.rej &&
test_must_fail git apply --reject patch.1 && test_must_fail git apply --reject patch.1 &&
test_cmp file1 expected && test_cmp expected file1 &&
cat file1.rej && cat file1.rej &&
test_path_is_missing file2.rej test_path_is_missing file2.rej
@ -85,7 +85,7 @@ test_expect_success 'apply with --reject should fail but update the file' '
test_must_fail git apply --reject patch.2 >rejects && test_must_fail git apply --reject patch.2 >rejects &&
test_path_is_missing file1 && test_path_is_missing file1 &&
test_cmp file2 expected && test_cmp expected file2 &&
cat file2.rej && cat file2.rej &&
test_path_is_missing file1.rej test_path_is_missing file1.rej
@ -99,7 +99,7 @@ test_expect_success 'the same test with --verbose' '
test_must_fail git apply --reject --verbose patch.2 >rejects && test_must_fail git apply --reject --verbose patch.2 >rejects &&
test_path_is_missing file1 && test_path_is_missing file1 &&
test_cmp file2 expected && test_cmp expected file2 &&
cat file2.rej && cat file2.rej &&
test_path_is_missing file1.rej test_path_is_missing file1.rej

View File

@ -313,9 +313,9 @@ test_expect_success 'applying beyond EOF requires one non-blank context line' '
{ echo a; echo; } >one && { echo a; echo; } >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 one expect && test_cmp expect one &&
test_must_fail git apply --ignore-space-change --whitespace=fix patch && test_must_fail git apply --ignore-space-change --whitespace=fix patch &&
test_cmp one expect test_cmp expect one
' '
test_expect_success 'tons of blanks at EOF should not apply' ' test_expect_success 'tons of blanks at EOF should not apply' '
@ -342,10 +342,10 @@ test_expect_success 'missing blank line at end with --whitespace=fix' '
cp one saved-one && cp one saved-one &&
test_must_fail git apply patch && test_must_fail git apply patch &&
git apply --whitespace=fix patch && git apply --whitespace=fix patch &&
test_cmp one expect && test_cmp expect one &&
mv saved-one one && mv saved-one one &&
git apply --ignore-space-change --whitespace=fix patch && git apply --ignore-space-change --whitespace=fix patch &&
test_cmp one expect test_cmp expect one
' '
test_expect_success 'two missing blank lines at end with --whitespace=fix' ' test_expect_success 'two missing blank lines at end with --whitespace=fix' '
@ -360,11 +360,11 @@ test_expect_success 'two missing blank lines at end with --whitespace=fix' '
cp no-blank-lines one && cp no-blank-lines one &&
test_must_fail git apply patch && test_must_fail git apply patch &&
git apply --whitespace=fix patch && git apply --whitespace=fix patch &&
test_cmp one expect && test_cmp expect one &&
mv no-blank-lines one && mv no-blank-lines one &&
test_must_fail git apply patch && test_must_fail git apply patch &&
git apply --ignore-space-change --whitespace=fix patch && git apply --ignore-space-change --whitespace=fix patch &&
test_cmp one expect test_cmp expect one
' '
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' '
@ -376,7 +376,7 @@ test_expect_success 'missing blank line at end, insert before end, --whitespace=
echo a >one && echo a >one &&
test_must_fail git apply patch && test_must_fail git apply patch &&
git apply --whitespace=fix patch && git apply --whitespace=fix patch &&
test_cmp one expect test_cmp expect one
' '
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' '
@ -392,10 +392,10 @@ test_expect_success 'shrink file with tons of missing blanks at end of file' '
cp no-blank-lines one && cp no-blank-lines one &&
test_must_fail git apply patch && test_must_fail git apply patch &&
git apply --whitespace=fix patch && git apply --whitespace=fix patch &&
test_cmp one expect && test_cmp expect one &&
mv no-blank-lines one && mv no-blank-lines one &&
git apply --ignore-space-change --whitespace=fix patch && git apply --ignore-space-change --whitespace=fix patch &&
test_cmp one expect test_cmp expect one
' '
test_expect_success 'missing blanks at EOF must only match blank lines' ' test_expect_success 'missing blanks at EOF must only match blank lines' '
@ -427,7 +427,7 @@ test_expect_success 'missing blank line should match context line with spaces' '
git add one && git add one &&
git apply --whitespace=fix patch && git apply --whitespace=fix patch &&
test_cmp one expect test_cmp expect one
' '
sed -e's/Z//' >one <<EOF sed -e's/Z//' >one <<EOF
@ -447,7 +447,7 @@ test_expect_success 'same, but with the --ignore-space-option' '
git checkout-index -f one && git checkout-index -f one &&
git apply --ignore-space-change --whitespace=fix patch && git apply --ignore-space-change --whitespace=fix patch &&
test_cmp one expect test_cmp expect one
' '
test_expect_success 'same, but with CR-LF line endings && cr-at-eol set' ' test_expect_success 'same, but with CR-LF line endings && cr-at-eol set' '
@ -464,7 +464,7 @@ test_expect_success 'same, but with CR-LF line endings && cr-at-eol set' '
mv save-one one && mv save-one one &&
git apply --ignore-space-change --whitespace=fix patch && git apply --ignore-space-change --whitespace=fix patch &&
test_cmp one expect test_cmp expect one
' '
test_expect_success 'CR-LF line endings && add line && text=auto' ' test_expect_success 'CR-LF line endings && add line && text=auto' '
@ -478,7 +478,7 @@ test_expect_success 'CR-LF line endings && add line && text=auto' '
mv save-one one && mv save-one one &&
echo "one text=auto" >.gitattributes && echo "one text=auto" >.gitattributes &&
git apply patch && git apply patch &&
test_cmp one expect test_cmp expect one
' '
test_expect_success 'CR-LF line endings && change line && text=auto' ' test_expect_success 'CR-LF line endings && change line && text=auto' '
@ -491,7 +491,7 @@ test_expect_success 'CR-LF line endings && change line && text=auto' '
mv save-one one && mv save-one one &&
echo "one text=auto" >.gitattributes && echo "one text=auto" >.gitattributes &&
git apply patch && git apply patch &&
test_cmp one expect test_cmp expect one
' '
test_expect_success 'LF in repo, CRLF in worktree && change line && text=auto' ' test_expect_success 'LF in repo, CRLF in worktree && change line && text=auto' '
@ -503,7 +503,7 @@ test_expect_success 'LF in repo, CRLF in worktree && change line && text=auto' '
echo "one text=auto" >.gitattributes && echo "one text=auto" >.gitattributes &&
git -c core.eol=CRLF apply patch && git -c core.eol=CRLF apply patch &&
printf "b\r\n" >expect && printf "b\r\n" >expect &&
test_cmp one expect test_cmp expect one
' '
test_expect_success 'whitespace=fix to expand' ' test_expect_success 'whitespace=fix to expand' '

View File

@ -114,7 +114,7 @@ for t in 1 2 3 4
do do
test_expect_success 'apply with ws expansion (t=$t)' ' test_expect_success 'apply with ws expansion (t=$t)' '
git apply patch$t.patch && git apply patch$t.patch &&
test_cmp test-$t expect-$t test_cmp expect-$t test-$t
' '
done done

View File

@ -21,17 +21,21 @@ test_expect_success 'setup r1' '
test_expect_success 'verify blob count in normal packfile' ' test_expect_success 'verify blob count in normal packfile' '
git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \ git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
| awk -f print_2.awk \ >ls_files_result &&
| sort >expected && awk -f print_2.awk ls_files_result |
sort >expected &&
git -C r1 pack-objects --rev --stdout >all.pack <<-EOF && git -C r1 pack-objects --rev --stdout >all.pack <<-EOF &&
HEAD HEAD
EOF EOF
git -C r1 index-pack ../all.pack && git -C r1 index-pack ../all.pack &&
git -C r1 verify-pack -v ../all.pack \
| grep blob \ git -C r1 verify-pack -v ../all.pack >verify_result &&
| awk -f print_1.awk \ grep blob verify_result |
| sort >observed && awk -f print_1.awk |
test_cmp observed expected sort >observed &&
test_cmp expected observed
' '
test_expect_success 'verify blob:none packfile has no blobs' ' test_expect_success 'verify blob:none packfile has no blobs' '
@ -39,24 +43,28 @@ test_expect_success 'verify blob:none packfile has no blobs' '
HEAD HEAD
EOF EOF
git -C r1 index-pack ../filter.pack && git -C r1 index-pack ../filter.pack &&
git -C r1 verify-pack -v ../filter.pack \
| grep blob \ git -C r1 verify-pack -v ../filter.pack >verify_result &&
| awk -f print_1.awk \ grep blob verify_result |
| sort >observed && awk -f print_1.awk |
sort >observed &&
nr=$(wc -l <observed) && nr=$(wc -l <observed) &&
test 0 -eq $nr test 0 -eq $nr
' '
test_expect_success 'verify normal and blob:none packfiles have same commits/trees' ' test_expect_success 'verify normal and blob:none packfiles have same commits/trees' '
git -C r1 verify-pack -v ../all.pack \ git -C r1 verify-pack -v ../all.pack >verify_result &&
| grep -E "commit|tree" \ grep -E "commit|tree" verify_result |
| awk -f print_1.awk \ awk -f print_1.awk |
| sort >expected && sort >expected &&
git -C r1 verify-pack -v ../filter.pack \
| grep -E "commit|tree" \ git -C r1 verify-pack -v ../filter.pack >verify_result &&
| awk -f print_1.awk \ grep -E "commit|tree" verify_result |
| sort >observed && awk -f print_1.awk |
test_cmp observed expected sort >observed &&
test_cmp expected observed
' '
# Test blob:limit=<n>[kmg] filter. # Test blob:limit=<n>[kmg] filter.
@ -75,18 +83,21 @@ test_expect_success 'setup r2' '
' '
test_expect_success 'verify blob count in normal packfile' ' test_expect_success 'verify blob count in normal packfile' '
git -C r2 ls-files -s large.1000 large.10000 \ git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
| awk -f print_2.awk \ awk -f print_2.awk ls_files_result |
| sort >expected && sort >expected &&
git -C r2 pack-objects --rev --stdout >all.pack <<-EOF && git -C r2 pack-objects --rev --stdout >all.pack <<-EOF &&
HEAD HEAD
EOF EOF
git -C r2 index-pack ../all.pack && git -C r2 index-pack ../all.pack &&
git -C r2 verify-pack -v ../all.pack \
| grep blob \ git -C r2 verify-pack -v ../all.pack >verify_result &&
| awk -f print_1.awk \ grep blob verify_result |
| sort >observed && awk -f print_1.awk |
test_cmp observed expected sort >observed &&
test_cmp expected observed
' '
test_expect_success 'verify blob:limit=500 omits all blobs' ' test_expect_success 'verify blob:limit=500 omits all blobs' '
@ -94,10 +105,12 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
HEAD HEAD
EOF EOF
git -C r2 index-pack ../filter.pack && git -C r2 index-pack ../filter.pack &&
git -C r2 verify-pack -v ../filter.pack \
| grep blob \ git -C r2 verify-pack -v ../filter.pack >verify_result &&
| awk -f print_1.awk \ grep blob verify_result |
| sort >observed && awk -f print_1.awk |
sort >observed &&
nr=$(wc -l <observed) && nr=$(wc -l <observed) &&
test 0 -eq $nr test 0 -eq $nr
' '
@ -107,100 +120,119 @@ test_expect_success 'verify blob:limit=1000' '
HEAD HEAD
EOF EOF
git -C r2 index-pack ../filter.pack && git -C r2 index-pack ../filter.pack &&
git -C r2 verify-pack -v ../filter.pack \
| grep blob \ git -C r2 verify-pack -v ../filter.pack >verify_result &&
| awk -f print_1.awk \ grep blob verify_result |
| sort >observed && awk -f print_1.awk |
sort >observed &&
nr=$(wc -l <observed) && nr=$(wc -l <observed) &&
test 0 -eq $nr test 0 -eq $nr
' '
test_expect_success 'verify blob:limit=1001' ' test_expect_success 'verify blob:limit=1001' '
git -C r2 ls-files -s large.1000 \ git -C r2 ls-files -s large.1000 >ls_files_result &&
| awk -f print_2.awk \ awk -f print_2.awk ls_files_result |
| sort >expected && sort >expected &&
git -C r2 pack-objects --rev --stdout --filter=blob:limit=1001 >filter.pack <<-EOF && git -C r2 pack-objects --rev --stdout --filter=blob:limit=1001 >filter.pack <<-EOF &&
HEAD HEAD
EOF EOF
git -C r2 index-pack ../filter.pack && git -C r2 index-pack ../filter.pack &&
git -C r2 verify-pack -v ../filter.pack \
| grep blob \ git -C r2 verify-pack -v ../filter.pack >verify_result &&
| awk -f print_1.awk \ grep blob verify_result |
| sort >observed && awk -f print_1.awk |
test_cmp observed expected sort >observed &&
test_cmp expected observed
' '
test_expect_success 'verify blob:limit=10001' ' test_expect_success 'verify blob:limit=10001' '
git -C r2 ls-files -s large.1000 large.10000 \ git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
| awk -f print_2.awk \ awk -f print_2.awk ls_files_result |
| sort >expected && sort >expected &&
git -C r2 pack-objects --rev --stdout --filter=blob:limit=10001 >filter.pack <<-EOF && git -C r2 pack-objects --rev --stdout --filter=blob:limit=10001 >filter.pack <<-EOF &&
HEAD HEAD
EOF EOF
git -C r2 index-pack ../filter.pack && git -C r2 index-pack ../filter.pack &&
git -C r2 verify-pack -v ../filter.pack \
| grep blob \ git -C r2 verify-pack -v ../filter.pack >verify_result &&
| awk -f print_1.awk \ grep blob verify_result |
| sort >observed && awk -f print_1.awk |
test_cmp observed expected sort >observed &&
test_cmp expected observed
' '
test_expect_success 'verify blob:limit=1k' ' test_expect_success 'verify blob:limit=1k' '
git -C r2 ls-files -s large.1000 \ git -C r2 ls-files -s large.1000 >ls_files_result &&
| awk -f print_2.awk \ awk -f print_2.awk ls_files_result |
| sort >expected && sort >expected &&
git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF && git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
HEAD HEAD
EOF EOF
git -C r2 index-pack ../filter.pack && git -C r2 index-pack ../filter.pack &&
git -C r2 verify-pack -v ../filter.pack \
| grep blob \ git -C r2 verify-pack -v ../filter.pack >verify_result &&
| awk -f print_1.awk \ grep blob verify_result |
| sort >observed && awk -f print_1.awk |
test_cmp observed expected sort >observed &&
test_cmp expected observed
' '
test_expect_success 'verify explicitly specifying oversized blob in input' ' test_expect_success 'verify explicitly specifying oversized blob in input' '
git -C r2 ls-files -s large.1000 large.10000 \ git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
| awk -f print_2.awk \ awk -f print_2.awk ls_files_result |
| sort >expected && sort >expected &&
git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF && git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
HEAD HEAD
$(git -C r2 rev-parse HEAD:large.10000) $(git -C r2 rev-parse HEAD:large.10000)
EOF EOF
git -C r2 index-pack ../filter.pack && git -C r2 index-pack ../filter.pack &&
git -C r2 verify-pack -v ../filter.pack \
| grep blob \ git -C r2 verify-pack -v ../filter.pack >verify_result &&
| awk -f print_1.awk \ grep blob verify_result |
| sort >observed && awk -f print_1.awk |
test_cmp observed expected sort >observed &&
test_cmp expected observed
' '
test_expect_success 'verify blob:limit=1m' ' test_expect_success 'verify blob:limit=1m' '
git -C r2 ls-files -s large.1000 large.10000 \ git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
| awk -f print_2.awk \ awk -f print_2.awk ls_files_result |
| sort >expected && sort >expected &&
git -C r2 pack-objects --rev --stdout --filter=blob:limit=1m >filter.pack <<-EOF && git -C r2 pack-objects --rev --stdout --filter=blob:limit=1m >filter.pack <<-EOF &&
HEAD HEAD
EOF EOF
git -C r2 index-pack ../filter.pack && git -C r2 index-pack ../filter.pack &&
git -C r2 verify-pack -v ../filter.pack \
| grep blob \ git -C r2 verify-pack -v ../filter.pack >verify_result &&
| awk -f print_1.awk \ grep blob verify_result |
| sort >observed && awk -f print_1.awk |
test_cmp observed expected sort >observed &&
test_cmp expected observed
' '
test_expect_success 'verify normal and blob:limit packfiles have same commits/trees' ' test_expect_success 'verify normal and blob:limit packfiles have same commits/trees' '
git -C r2 verify-pack -v ../all.pack \ git -C r2 verify-pack -v ../all.pack >verify_result &&
| grep -E "commit|tree" \ grep -E "commit|tree" verify_result |
| awk -f print_1.awk \ awk -f print_1.awk |
| sort >expected && sort >expected &&
git -C r2 verify-pack -v ../filter.pack \
| grep -E "commit|tree" \ git -C r2 verify-pack -v ../filter.pack >verify_result &&
| awk -f print_1.awk \ grep -E "commit|tree" verify_result |
| sort >observed && awk -f print_1.awk |
test_cmp observed expected sort >observed &&
test_cmp expected observed
' '
# Test sparse:path=<path> filter. # Test sparse:path=<path> filter.
@ -225,71 +257,85 @@ test_expect_success 'setup r3' '
test_expect_success 'verify blob count in normal packfile' ' test_expect_success 'verify blob count in normal packfile' '
git -C r3 ls-files -s sparse1 sparse2 dir1/sparse1 dir1/sparse2 \ git -C r3 ls-files -s sparse1 sparse2 dir1/sparse1 dir1/sparse2 \
| awk -f print_2.awk \ >ls_files_result &&
| sort >expected && awk -f print_2.awk ls_files_result |
sort >expected &&
git -C r3 pack-objects --rev --stdout >all.pack <<-EOF && git -C r3 pack-objects --rev --stdout >all.pack <<-EOF &&
HEAD HEAD
EOF EOF
git -C r3 index-pack ../all.pack && git -C r3 index-pack ../all.pack &&
git -C r3 verify-pack -v ../all.pack \
| grep blob \ git -C r3 verify-pack -v ../all.pack >verify_result &&
| awk -f print_1.awk \ grep blob verify_result |
| sort >observed && awk -f print_1.awk |
test_cmp observed expected sort >observed &&
test_cmp expected observed
' '
test_expect_success 'verify sparse:path=pattern1' ' test_expect_success 'verify sparse:path=pattern1' '
git -C r3 ls-files -s dir1/sparse1 dir1/sparse2 \ git -C r3 ls-files -s dir1/sparse1 dir1/sparse2 >ls_files_result &&
| awk -f print_2.awk \ awk -f print_2.awk ls_files_result |
| sort >expected && sort >expected &&
git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern1 >filter.pack <<-EOF && git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern1 >filter.pack <<-EOF &&
HEAD HEAD
EOF EOF
git -C r3 index-pack ../filter.pack && git -C r3 index-pack ../filter.pack &&
git -C r3 verify-pack -v ../filter.pack \
| grep blob \ git -C r3 verify-pack -v ../filter.pack >verify_result &&
| awk -f print_1.awk \ grep blob verify_result |
| sort >observed && awk -f print_1.awk |
test_cmp observed expected sort >observed &&
test_cmp expected observed
' '
test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same commits/trees' ' test_expect_success 'verify normal and sparse:path=pattern1 packfiles have same commits/trees' '
git -C r3 verify-pack -v ../all.pack \ git -C r3 verify-pack -v ../all.pack >verify_result &&
| grep -E "commit|tree" \ grep -E "commit|tree" verify_result |
| awk -f print_1.awk \ awk -f print_1.awk |
| sort >expected && sort >expected &&
git -C r3 verify-pack -v ../filter.pack \
| grep -E "commit|tree" \ git -C r3 verify-pack -v ../filter.pack >verify_result &&
| awk -f print_1.awk \ grep -E "commit|tree" verify_result |
| sort >observed && awk -f print_1.awk |
test_cmp observed expected sort >observed &&
test_cmp expected observed
' '
test_expect_success 'verify sparse:path=pattern2' ' test_expect_success 'verify sparse:path=pattern2' '
git -C r3 ls-files -s sparse1 dir1/sparse1 \ git -C r3 ls-files -s sparse1 dir1/sparse1 >ls_files_result &&
| awk -f print_2.awk \ awk -f print_2.awk ls_files_result |
| sort >expected && sort >expected &&
git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern2 >filter.pack <<-EOF && git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern2 >filter.pack <<-EOF &&
HEAD HEAD
EOF EOF
git -C r3 index-pack ../filter.pack && git -C r3 index-pack ../filter.pack &&
git -C r3 verify-pack -v ../filter.pack \
| grep blob \ git -C r3 verify-pack -v ../filter.pack >verify_result &&
| awk -f print_1.awk \ grep blob verify_result |
| sort >observed && awk -f print_1.awk |
test_cmp observed expected sort >observed &&
test_cmp expected observed
' '
test_expect_success 'verify normal and sparse:path=pattern2 packfiles have same commits/trees' ' test_expect_success 'verify normal and sparse:path=pattern2 packfiles have same commits/trees' '
git -C r3 verify-pack -v ../all.pack \ git -C r3 verify-pack -v ../all.pack >verify_result &&
| grep -E "commit|tree" \ grep -E "commit|tree" verify_result |
| awk -f print_1.awk \ awk -f print_1.awk |
| sort >expected && sort >expected &&
git -C r3 verify-pack -v ../filter.pack \
| grep -E "commit|tree" \ git -C r3 verify-pack -v ../filter.pack >verify_result &&
| awk -f print_1.awk \ grep -E "commit|tree" verify_result |
| sort >observed && awk -f print_1.awk |
test_cmp observed expected sort >observed &&
test_cmp expected observed
' '
# Test sparse:oid=<oid-ish> filter. # Test sparse:oid=<oid-ish> filter.
@ -313,48 +359,58 @@ test_expect_success 'setup r4' '
test_expect_success 'verify blob count in normal packfile' ' test_expect_success 'verify blob count in normal packfile' '
git -C r4 ls-files -s pattern sparse1 sparse2 dir1/sparse1 dir1/sparse2 \ git -C r4 ls-files -s pattern sparse1 sparse2 dir1/sparse1 dir1/sparse2 \
| awk -f print_2.awk \ >ls_files_result &&
| sort >expected && awk -f print_2.awk ls_files_result |
sort >expected &&
git -C r4 pack-objects --rev --stdout >all.pack <<-EOF && git -C r4 pack-objects --rev --stdout >all.pack <<-EOF &&
HEAD HEAD
EOF EOF
git -C r4 index-pack ../all.pack && git -C r4 index-pack ../all.pack &&
git -C r4 verify-pack -v ../all.pack \
| grep blob \ git -C r4 verify-pack -v ../all.pack >verify_result &&
| awk -f print_1.awk \ grep blob verify_result |
| sort >observed && awk -f print_1.awk |
test_cmp observed expected sort >observed &&
test_cmp expected observed
' '
test_expect_success 'verify sparse:oid=OID' ' test_expect_success 'verify sparse:oid=OID' '
git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 \ git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 >ls_files_result &&
| awk -f print_2.awk \ awk -f print_2.awk ls_files_result |
| sort >expected && sort >expected &&
oid=$(git -C r4 ls-files -s pattern | awk -f print_2.awk) && oid=$(git -C r4 ls-files -s pattern | awk -f print_2.awk) &&
git -C r4 pack-objects --rev --stdout --filter=sparse:oid=$oid >filter.pack <<-EOF && git -C r4 pack-objects --rev --stdout --filter=sparse:oid=$oid >filter.pack <<-EOF &&
HEAD HEAD
EOF EOF
git -C r4 index-pack ../filter.pack && git -C r4 index-pack ../filter.pack &&
git -C r4 verify-pack -v ../filter.pack \
| grep blob \ git -C r4 verify-pack -v ../filter.pack >verify_result &&
| awk -f print_1.awk \ grep blob verify_result |
| sort >observed && awk -f print_1.awk |
test_cmp observed expected sort >observed &&
test_cmp expected observed
' '
test_expect_success 'verify sparse:oid=oid-ish' ' test_expect_success 'verify sparse:oid=oid-ish' '
git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 \ git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 >ls_files_result &&
| awk -f print_2.awk \ awk -f print_2.awk ls_files_result |
| sort >expected && sort >expected &&
git -C r4 pack-objects --rev --stdout --filter=sparse:oid=master:pattern >filter.pack <<-EOF && git -C r4 pack-objects --rev --stdout --filter=sparse:oid=master:pattern >filter.pack <<-EOF &&
HEAD HEAD
EOF EOF
git -C r4 index-pack ../filter.pack && git -C r4 index-pack ../filter.pack &&
git -C r4 verify-pack -v ../filter.pack \
| grep blob \ git -C r4 verify-pack -v ../filter.pack >verify_result &&
| awk -f print_1.awk \ grep blob verify_result |
| sort >observed && awk -f print_1.awk |
test_cmp observed expected sort >observed &&
test_cmp expected observed
' '
# Delete some loose objects and use pack-objects, but WITHOUT any filtering. # Delete some loose objects and use pack-objects, but WITHOUT any filtering.
@ -362,8 +418,10 @@ test_expect_success 'verify sparse:oid=oid-ish' '
test_expect_success 'setup r1 - delete loose blobs' ' test_expect_success 'setup r1 - delete loose blobs' '
git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \ git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
| awk -f print_2.awk \ >ls_files_result &&
| sort >expected && awk -f print_2.awk ls_files_result |
sort >expected &&
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

View File

@ -36,7 +36,7 @@ test_expect_success 'create commits and repack' '
graph_git_two_modes() { graph_git_two_modes() {
git -c core.commitGraph=true $1 >output git -c core.commitGraph=true $1 >output
git -c core.commitGraph=false $1 >expect git -c core.commitGraph=false $1 >expect
test_cmp output expect test_cmp expect output
} }
graph_git_behavior() { graph_git_behavior() {

View File

@ -50,8 +50,11 @@ pull_to_client () {
case "$heads" in *B*) case "$heads" in *B*)
git update-ref refs/heads/B "$BTIP";; git update-ref refs/heads/B "$BTIP";;
esac && esac &&
git symbolic-ref HEAD refs/heads/$(echo $heads \
| sed -e "s/^\(.\).*$/\1/") && git symbolic-ref HEAD refs/heads/$(
echo $heads |
sed -e "s/^\(.\).*$/\1/"
) &&
git fsck --full && git fsck --full &&

View File

@ -34,10 +34,12 @@ test_expect_success 'setup bare clone for server' '
# confirm partial clone was registered in the local config. # confirm partial clone was registered in the local config.
test_expect_success 'do partial clone 1' ' test_expect_success 'do partial clone 1' '
git clone --no-checkout --filter=blob:none "file://$(pwd)/srv.bare" pc1 && git clone --no-checkout --filter=blob:none "file://$(pwd)/srv.bare" pc1 &&
git -C pc1 rev-list HEAD --quiet --objects --missing=print \
| awk -f print_1.awk \ git -C pc1 rev-list --quiet --objects --missing=print HEAD >revs &&
| sed "s/?//" \ awk -f print_1.awk revs |
| sort >observed.oids && sed "s/?//" |
sort >observed.oids &&
test_cmp expect_1.oids observed.oids && test_cmp expect_1.oids observed.oids &&
test "$(git -C pc1 config --local core.repositoryformatversion)" = "1" && test "$(git -C pc1 config --local core.repositoryformatversion)" = "1" &&
test "$(git -C pc1 config --local extensions.partialclone)" = "origin" && test "$(git -C pc1 config --local extensions.partialclone)" = "origin" &&
@ -46,10 +48,10 @@ test_expect_success 'do partial clone 1' '
# checkout master to force dynamic object fetch of blobs at HEAD. # checkout master to force dynamic object fetch of blobs at HEAD.
test_expect_success 'verify checkout with dynamic object fetch' ' test_expect_success 'verify checkout with dynamic object fetch' '
git -C pc1 rev-list HEAD --quiet --objects --missing=print >observed && git -C pc1 rev-list --quiet --objects --missing=print HEAD >observed &&
test_line_count = 4 observed && test_line_count = 4 observed &&
git -C pc1 checkout master && git -C pc1 checkout master &&
git -C pc1 rev-list HEAD --quiet --objects --missing=print >observed && git -C pc1 rev-list --quiet --objects --missing=print HEAD >observed &&
test_line_count = 0 observed test_line_count = 0 observed
' '
@ -72,7 +74,8 @@ test_expect_success 'push new commits to server' '
# have the new blobs. # have the new blobs.
test_expect_success 'partial fetch inherits filter settings' ' test_expect_success 'partial fetch inherits filter settings' '
git -C pc1 fetch origin && git -C pc1 fetch origin &&
git -C pc1 rev-list master..origin/master --quiet --objects --missing=print >observed && git -C pc1 rev-list --quiet --objects --missing=print \
master..origin/master >observed &&
test_line_count = 5 observed test_line_count = 5 observed
' '
@ -80,7 +83,8 @@ test_expect_success 'partial fetch inherits filter settings' '
# we should only get 1 new blob (for the file in origin/master). # we should only get 1 new blob (for the file in origin/master).
test_expect_success 'verify diff causes dynamic object fetch' ' test_expect_success 'verify diff causes dynamic object fetch' '
git -C pc1 diff master..origin/master -- file.1.txt && git -C pc1 diff master..origin/master -- file.1.txt &&
git -C pc1 rev-list master..origin/master --quiet --objects --missing=print >observed && git -C pc1 rev-list --quiet --objects --missing=print \
master..origin/master >observed &&
test_line_count = 4 observed test_line_count = 4 observed
' '
@ -89,7 +93,8 @@ test_expect_success 'verify diff causes dynamic object fetch' '
test_expect_success 'verify blame causes dynamic object fetch' ' test_expect_success 'verify blame causes dynamic object fetch' '
git -C pc1 blame origin/master -- file.1.txt >observed.blame && git -C pc1 blame origin/master -- file.1.txt >observed.blame &&
test_cmp expect.blame observed.blame && test_cmp expect.blame observed.blame &&
git -C pc1 rev-list master..origin/master --quiet --objects --missing=print >observed && git -C pc1 rev-list --quiet --objects --missing=print \
master..origin/master >observed &&
test_line_count = 0 observed test_line_count = 0 observed
' '
@ -109,7 +114,8 @@ test_expect_success 'push new commits to server for file.2.txt' '
# Verify we have all the new blobs. # Verify we have all the new blobs.
test_expect_success 'override inherited filter-spec using --no-filter' ' test_expect_success 'override inherited filter-spec using --no-filter' '
git -C pc1 fetch --no-filter origin && git -C pc1 fetch --no-filter origin &&
git -C pc1 rev-list master..origin/master --quiet --objects --missing=print >observed && git -C pc1 rev-list --quiet --objects --missing=print \
master..origin/master >observed &&
test_line_count = 0 observed test_line_count = 0 observed
' '
@ -130,16 +136,22 @@ test_expect_success 'push new commits to server for file.3.txt' '
# perhaps combined with a command in dry-run mode. # perhaps combined with a command in dry-run mode.
test_expect_success 'manual prefetch of missing objects' ' test_expect_success 'manual prefetch of missing objects' '
git -C pc1 fetch --filter=blob:none origin && git -C pc1 fetch --filter=blob:none origin &&
git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
| awk -f print_1.awk \ git -C pc1 rev-list --quiet --objects --missing=print \
| sed "s/?//" \ master..origin/master >revs &&
| sort >observed.oids && awk -f print_1.awk revs |
sed "s/?//" |
sort >observed.oids &&
test_line_count = 6 observed.oids && test_line_count = 6 observed.oids &&
git -C pc1 fetch-pack --stdin "file://$(pwd)/srv.bare" <observed.oids && git -C pc1 fetch-pack --stdin "file://$(pwd)/srv.bare" <observed.oids &&
git -C pc1 rev-list master..origin/master --quiet --objects --missing=print \
| awk -f print_1.awk \ git -C pc1 rev-list --quiet --objects --missing=print \
| sed "s/?//" \ master..origin/master >revs &&
| sort >observed.oids && awk -f print_1.awk revs |
sed "s/?//" |
sort >observed.oids &&
test_line_count = 0 observed.oids test_line_count = 0 observed.oids
' '
@ -194,7 +206,7 @@ test_expect_success 'upon cloning, check that all refs point to objects' '
# Craft a packfile not including that blob. # Craft a packfile not including that blob.
git -C "$SERVER" rev-parse HEAD | git -C "$SERVER" rev-parse HEAD |
git -C "$SERVER" pack-objects --stdout >incomplete.pack && git -C "$SERVER" pack-objects --stdout >incomplete.pack &&
# Replace the existing packfile with the crafted one. The protocol # Replace the existing packfile with the crafted one. The protocol
# requires that the packfile be sent in sideband 1, hence the extra # requires that the packfile be sent in sideband 1, hence the extra

View File

@ -16,7 +16,7 @@ test_expect_success 'test capability advertisement' '
git serve --advertise-capabilities >out && git serve --advertise-capabilities >out &&
test-tool pkt-line unpack <out >actual && test-tool pkt-line unpack <out >actual &&
test_cmp actual expect test_cmp expect actual
' '
test_expect_success 'stateless-rpc flag does not list capabilities' ' test_expect_success 'stateless-rpc flag does not list capabilities' '
@ -89,7 +89,7 @@ test_expect_success 'basics of ls-refs' '
git serve --stateless-rpc <in >out && git serve --stateless-rpc <in >out &&
test-tool pkt-line unpack <out >actual && test-tool pkt-line unpack <out >actual &&
test_cmp actual expect test_cmp expect actual
' '
test_expect_success 'basic ref-prefixes' ' test_expect_success 'basic ref-prefixes' '
@ -109,7 +109,7 @@ test_expect_success 'basic ref-prefixes' '
git serve --stateless-rpc <in >out && git serve --stateless-rpc <in >out &&
test-tool pkt-line unpack <out >actual && test-tool pkt-line unpack <out >actual &&
test_cmp actual expect test_cmp expect actual
' '
test_expect_success 'refs/heads prefix' ' test_expect_success 'refs/heads prefix' '
@ -129,7 +129,7 @@ test_expect_success 'refs/heads prefix' '
git serve --stateless-rpc <in >out && git serve --stateless-rpc <in >out &&
test-tool pkt-line unpack <out >actual && test-tool pkt-line unpack <out >actual &&
test_cmp actual expect test_cmp expect actual
' '
test_expect_success 'peel parameter' ' test_expect_success 'peel parameter' '
@ -150,7 +150,7 @@ test_expect_success 'peel parameter' '
git serve --stateless-rpc <in >out && git serve --stateless-rpc <in >out &&
test-tool pkt-line unpack <out >actual && test-tool pkt-line unpack <out >actual &&
test_cmp actual expect test_cmp expect actual
' '
test_expect_success 'symrefs parameter' ' test_expect_success 'symrefs parameter' '
@ -171,7 +171,7 @@ test_expect_success 'symrefs parameter' '
git serve --stateless-rpc <in >out && git serve --stateless-rpc <in >out &&
test-tool pkt-line unpack <out >actual && test-tool pkt-line unpack <out >actual &&
test_cmp actual expect test_cmp expect actual
' '
test_expect_success 'sending server-options' ' test_expect_success 'sending server-options' '
@ -191,7 +191,7 @@ test_expect_success 'sending server-options' '
git serve --stateless-rpc <in >out && git serve --stateless-rpc <in >out &&
test-tool pkt-line unpack <out >actual && test-tool pkt-line unpack <out >actual &&
test_cmp actual expect test_cmp expect actual
' '
test_expect_success 'unexpected lines are not allowed in fetch request' ' test_expect_success 'unexpected lines are not allowed in fetch request' '

View File

@ -29,7 +29,7 @@ test_expect_success 'list refs with git:// using protocol v2' '
grep "git< version 2" log && grep "git< version 2" log &&
git ls-remote --symref "$GIT_DAEMON_URL/parent" >expect && git ls-remote --symref "$GIT_DAEMON_URL/parent" >expect &&
test_cmp actual expect test_cmp expect actual
' '
test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' ' test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' '
@ -42,7 +42,7 @@ test_expect_success 'ref advertisment is filtered with ls-remote using protocol
$(git -C "$daemon_parent" rev-parse refs/heads/master)$(printf "\t")refs/heads/master $(git -C "$daemon_parent" rev-parse refs/heads/master)$(printf "\t")refs/heads/master
EOF EOF
test_cmp actual expect test_cmp expect actual
' '
test_expect_success 'clone with git:// using protocol v2' ' test_expect_success 'clone with git:// using protocol v2' '
@ -138,7 +138,7 @@ test_expect_success 'list refs with file:// using protocol v2' '
grep "git< version 2" log && grep "git< version 2" log &&
git ls-remote --symref "file://$(pwd)/file_parent" >expect && git ls-remote --symref "file://$(pwd)/file_parent" >expect &&
test_cmp actual expect test_cmp expect actual
' '
test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' ' test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' '
@ -151,7 +151,7 @@ test_expect_success 'ref advertisment is filtered with ls-remote using protocol
$(git -C file_parent rev-parse refs/heads/master)$(printf "\t")refs/heads/master $(git -C file_parent rev-parse refs/heads/master)$(printf "\t")refs/heads/master
EOF EOF
test_cmp actual expect test_cmp expect actual
' '
test_expect_success 'server-options are sent when using ls-remote' ' test_expect_success 'server-options are sent when using ls-remote' '
@ -164,7 +164,7 @@ test_expect_success 'server-options are sent when using ls-remote' '
$(git -C file_parent rev-parse refs/heads/master)$(printf "\t")refs/heads/master $(git -C file_parent rev-parse refs/heads/master)$(printf "\t")refs/heads/master
EOF EOF
test_cmp actual expect && test_cmp expect actual &&
grep "server-option=hello" log && grep "server-option=hello" log &&
grep "server-option=world" log grep "server-option=world" log
' '
@ -271,7 +271,7 @@ test_expect_success 'partial clone' '
grep "version 2" trace && grep "version 2" trace &&
# Ensure that the old version of the file is missing # Ensure that the old version of the file is missing
git -C client rev-list master --quiet --objects --missing=print \ git -C client rev-list --quiet --objects --missing=print master \
>observed.oids && >observed.oids &&
grep "$(git -C server rev-parse message1:a.txt)" observed.oids && grep "$(git -C server rev-parse message1:a.txt)" observed.oids &&
@ -297,7 +297,7 @@ test_expect_success 'partial fetch' '
grep "version 2" trace && grep "version 2" trace &&
# Ensure that the old version of the file is missing # Ensure that the old version of the file is missing
git -C client rev-list other --quiet --objects --missing=print \ git -C client rev-list --quiet --objects --missing=print other \
>observed.oids && >observed.oids &&
grep "$(git -C server rev-parse message1:a.txt)" observed.oids && grep "$(git -C server rev-parse message1:a.txt)" observed.oids &&

View File

@ -99,7 +99,7 @@ EOF
printf "propter nomen suum." >> expect.txt printf "propter nomen suum." >> expect.txt
test_expect_success "merge does not add LF away of change" \ test_expect_success "merge does not add LF away of change" \
"test_cmp test3.txt expect.txt" "test_cmp expect.txt test3.txt"
cp test.txt backup.txt cp test.txt backup.txt
test_expect_success "merge with conflicts" \ test_expect_success "merge with conflicts" \
@ -122,7 +122,7 @@ non timebo mala, quoniam tu mecum es:
virga tua et baculus tuus ipsa me consolata sunt. virga tua et baculus tuus ipsa me consolata sunt.
EOF EOF
test_expect_success "expected conflict markers" "test_cmp test.txt expect.txt" test_expect_success "expected conflict markers" "test_cmp expect.txt test.txt"
cp backup.txt test.txt cp backup.txt test.txt
@ -138,7 +138,7 @@ non timebo mala, quoniam tu mecum es:
virga tua et baculus tuus ipsa me consolata sunt. virga tua et baculus tuus ipsa me consolata sunt.
EOF EOF
test_expect_success "merge conflicting with --ours" \ test_expect_success "merge conflicting with --ours" \
"git merge-file --ours test.txt orig.txt new3.txt && test_cmp test.txt expect.txt" "git merge-file --ours test.txt orig.txt new3.txt && test_cmp expect.txt test.txt"
cp backup.txt test.txt cp backup.txt test.txt
cat > expect.txt << EOF cat > expect.txt << EOF
@ -154,7 +154,7 @@ non timebo mala, quoniam tu mecum es:
virga tua et baculus tuus ipsa me consolata sunt. virga tua et baculus tuus ipsa me consolata sunt.
EOF EOF
test_expect_success "merge conflicting with --theirs" \ test_expect_success "merge conflicting with --theirs" \
"git merge-file --theirs test.txt orig.txt new3.txt && test_cmp test.txt expect.txt" "git merge-file --theirs test.txt orig.txt new3.txt && test_cmp expect.txt test.txt"
cp backup.txt test.txt cp backup.txt test.txt
cat > expect.txt << EOF cat > expect.txt << EOF
@ -171,7 +171,7 @@ non timebo mala, quoniam tu mecum es:
virga tua et baculus tuus ipsa me consolata sunt. virga tua et baculus tuus ipsa me consolata sunt.
EOF EOF
test_expect_success "merge conflicting with --union" \ test_expect_success "merge conflicting with --union" \
"git merge-file --union test.txt orig.txt new3.txt && test_cmp test.txt expect.txt" "git merge-file --union test.txt orig.txt new3.txt && test_cmp expect.txt test.txt"
cp backup.txt test.txt cp backup.txt test.txt
test_expect_success "merge with conflicts, using -L" \ test_expect_success "merge with conflicts, using -L" \
@ -195,7 +195,7 @@ virga tua et baculus tuus ipsa me consolata sunt.
EOF EOF
test_expect_success "expected conflict markers, with -L" \ test_expect_success "expected conflict markers, with -L" \
"test_cmp test.txt expect.txt" "test_cmp expect.txt test.txt"
sed "s/ tu / TU /" < new1.txt > new5.txt sed "s/ tu / TU /" < new1.txt > new5.txt
test_expect_success "conflict in removed tail" \ test_expect_success "conflict in removed tail" \

View File

@ -45,7 +45,7 @@ test_expect_success resolve '
false false
else else
git ls-files -s >current git ls-files -s >current
test_cmp current expect test_cmp expect current
fi fi
' '
@ -60,7 +60,7 @@ test_expect_success recursive '
false false
else else
git ls-files -s >current git ls-files -s >current
test_cmp current expect test_cmp expect current
fi fi
' '

View File

@ -61,7 +61,7 @@ do_both_modes () {
git checkout -f a2 && git checkout -f a2 &&
test_must_fail git merge -s $strategy b2 && test_must_fail git merge -s $strategy b2 &&
git ls-files -u >actual && git ls-files -u >actual &&
test_cmp actual expect && test_cmp expect actual &&
git ls-files -s file2 | grep ^100755 git ls-files -s file2 | grep ^100755
' '

View File

@ -21,24 +21,31 @@ test_expect_success 'setup r1' '
test_expect_success 'verify blob:none omits all 5 blobs' ' test_expect_success 'verify blob:none omits all 5 blobs' '
git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \ git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
| awk -f print_2.awk \ >ls_files_result &&
| sort >expected && awk -f print_2.awk ls_files_result |
git -C r1 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:none \ sort >expected &&
| awk -f print_1.awk \
| sed "s/~//" \ git -C r1 rev-list --quiet --objects --filter-print-omitted \
| sort >observed && --filter=blob:none HEAD >revs &&
test_cmp observed expected awk -f print_1.awk revs |
sed "s/~//" |
sort >observed &&
test_cmp expected observed
' '
test_expect_success 'verify emitted+omitted == all' ' test_expect_success 'verify emitted+omitted == all' '
git -C r1 rev-list HEAD --objects \ git -C r1 rev-list --objects HEAD >revs &&
| awk -f print_1.awk \ awk -f print_1.awk revs |
| sort >expected && sort >expected &&
git -C r1 rev-list HEAD --objects --filter-print-omitted --filter=blob:none \
| awk -f print_1.awk \ git -C r1 rev-list --objects --filter-print-omitted --filter=blob:none \
| sed "s/~//" \ HEAD >revs &&
| sort >observed && awk -f print_1.awk revs |
test_cmp observed expected sed "s/~//" |
sort >observed &&
test_cmp expected observed
' '
@ -58,65 +65,82 @@ test_expect_success 'setup r2' '
' '
test_expect_success 'verify blob:limit=500 omits all blobs' ' test_expect_success 'verify blob:limit=500 omits all blobs' '
git -C r2 ls-files -s large.1000 large.10000 \ git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
| awk -f print_2.awk \ awk -f print_2.awk ls_files_result |
| sort >expected && sort >expected &&
git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=500 \
| awk -f print_1.awk \ git -C r2 rev-list --quiet --objects --filter-print-omitted \
| sed "s/~//" \ --filter=blob:limit=500 HEAD >revs &&
| sort >observed && awk -f print_1.awk revs |
test_cmp observed expected sed "s/~//" |
sort >observed &&
test_cmp expected observed
' '
test_expect_success 'verify emitted+omitted == all' ' test_expect_success 'verify emitted+omitted == all' '
git -C r2 rev-list HEAD --objects \ git -C r2 rev-list --objects HEAD >revs &&
| awk -f print_1.awk \ awk -f print_1.awk revs |
| sort >expected && sort >expected &&
git -C r2 rev-list HEAD --objects --filter-print-omitted --filter=blob:limit=500 \
| awk -f print_1.awk \ git -C r2 rev-list --objects --filter-print-omitted \
| sed "s/~//" \ --filter=blob:limit=500 HEAD >revs &&
| sort >observed && awk -f print_1.awk revs |
test_cmp observed expected sed "s/~//" |
sort >observed &&
test_cmp expected observed
' '
test_expect_success 'verify blob:limit=1000' ' test_expect_success 'verify blob:limit=1000' '
git -C r2 ls-files -s large.1000 large.10000 \ git -C r2 ls-files -s large.1000 large.10000 >ls_files_result &&
| awk -f print_2.awk \ awk -f print_2.awk ls_files_result |
| sort >expected && sort >expected &&
git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1000 \
| awk -f print_1.awk \ git -C r2 rev-list --quiet --objects --filter-print-omitted \
| sed "s/~//" \ --filter=blob:limit=1000 HEAD >revs &&
| sort >observed && awk -f print_1.awk revs |
test_cmp observed expected sed "s/~//" |
sort >observed &&
test_cmp expected observed
' '
test_expect_success 'verify blob:limit=1001' ' test_expect_success 'verify blob:limit=1001' '
git -C r2 ls-files -s large.10000 \ git -C r2 ls-files -s large.10000 >ls_files_result &&
| awk -f print_2.awk \ awk -f print_2.awk ls_files_result |
| sort >expected && sort >expected &&
git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1001 \
| awk -f print_1.awk \ git -C r2 rev-list --quiet --objects --filter-print-omitted \
| sed "s/~//" \ --filter=blob:limit=1001 HEAD >revs &&
| sort >observed && awk -f print_1.awk revs |
test_cmp observed expected sed "s/~//" |
sort >observed &&
test_cmp expected observed
' '
test_expect_success 'verify blob:limit=1k' ' test_expect_success 'verify blob:limit=1k' '
git -C r2 ls-files -s large.10000 \ git -C r2 ls-files -s large.10000 >ls_files_result &&
| awk -f print_2.awk \ awk -f print_2.awk ls_files_result |
| sort >expected && sort >expected &&
git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1k \
| awk -f print_1.awk \ git -C r2 rev-list --quiet --objects --filter-print-omitted \
| sed "s/~//" \ --filter=blob:limit=1k HEAD >revs &&
| sort >observed && awk -f print_1.awk revs |
test_cmp observed expected sed "s/~//" |
sort >observed &&
test_cmp expected observed
' '
test_expect_success 'verify blob:limit=1m' ' test_expect_success 'verify blob:limit=1m' '
git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1m \ git -C r2 rev-list --quiet --objects --filter-print-omitted \
| awk -f print_1.awk \ --filter=blob:limit=1m HEAD >revs &&
| sed "s/~//" \ awk -f print_1.awk revs |
| sort >observed && sed "s/~//" |
sort >observed &&
test_must_be_empty observed test_must_be_empty observed
' '
@ -141,25 +165,31 @@ test_expect_success 'setup r3' '
' '
test_expect_success 'verify sparse:path=pattern1 omits top-level files' ' test_expect_success 'verify sparse:path=pattern1 omits top-level files' '
git -C r3 ls-files -s sparse1 sparse2 \ git -C r3 ls-files -s sparse1 sparse2 >ls_files_result &&
| awk -f print_2.awk \ awk -f print_2.awk ls_files_result |
| sort >expected && sort >expected &&
git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern1 \
| awk -f print_1.awk \ git -C r3 rev-list --quiet --objects --filter-print-omitted \
| sed "s/~//" \ --filter=sparse:path=../pattern1 HEAD >revs &&
| sort >observed && awk -f print_1.awk revs |
test_cmp observed expected sed "s/~//" |
sort >observed &&
test_cmp expected observed
' '
test_expect_success 'verify sparse:path=pattern2 omits both sparse2 files' ' test_expect_success 'verify sparse:path=pattern2 omits both sparse2 files' '
git -C r3 ls-files -s sparse2 dir1/sparse2 \ git -C r3 ls-files -s sparse2 dir1/sparse2 >ls_files_result &&
| awk -f print_2.awk \ awk -f print_2.awk ls_files_result |
| sort >expected && sort >expected &&
git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:path=../pattern2 \
| awk -f print_1.awk \ git -C r3 rev-list --quiet --objects --filter-print-omitted \
| sed "s/~//" \ --filter=sparse:path=../pattern2 HEAD >revs &&
| sort >observed && awk -f print_1.awk revs |
test_cmp observed expected sed "s/~//" |
sort >observed &&
test_cmp expected observed
' '
# Test sparse:oid=<oid-ish> filter. # Test sparse:oid=<oid-ish> filter.
@ -173,26 +203,33 @@ test_expect_success 'setup r3 part 2' '
' '
test_expect_success 'verify sparse:oid=OID omits top-level files' ' test_expect_success 'verify sparse:oid=OID omits top-level files' '
git -C r3 ls-files -s pattern sparse1 sparse2 \ git -C r3 ls-files -s pattern sparse1 sparse2 >ls_files_result &&
| awk -f print_2.awk \ awk -f print_2.awk ls_files_result |
| sort >expected && sort >expected &&
oid=$(git -C r3 ls-files -s pattern | awk -f print_2.awk) && oid=$(git -C r3 ls-files -s pattern | awk -f print_2.awk) &&
git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=$oid \
| awk -f print_1.awk \ git -C r3 rev-list --quiet --objects --filter-print-omitted \
| sed "s/~//" \ --filter=sparse:oid=$oid HEAD >revs &&
| sort >observed && awk -f print_1.awk revs |
test_cmp observed expected sed "s/~//" |
sort >observed &&
test_cmp expected observed
' '
test_expect_success 'verify sparse:oid=oid-ish omits top-level files' ' test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
git -C r3 ls-files -s pattern sparse1 sparse2 \ git -C r3 ls-files -s pattern sparse1 sparse2 >ls_files_result &&
| awk -f print_2.awk \ awk -f print_2.awk ls_files_result |
| sort >expected && sort >expected &&
git -C r3 rev-list HEAD --quiet --objects --filter-print-omitted --filter=sparse:oid=master:pattern \
| awk -f print_1.awk \ git -C r3 rev-list --quiet --objects --filter-print-omitted \
| sed "s/~//" \ --filter=sparse:oid=master:pattern HEAD >revs &&
| sort >observed && awk -f print_1.awk revs |
test_cmp observed expected sed "s/~//" |
sort >observed &&
test_cmp expected observed
' '
# Delete some loose objects and use rev-list, but WITHOUT any filtering. # Delete some loose objects and use rev-list, but WITHOUT any filtering.
@ -200,17 +237,21 @@ test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
test_expect_success 'rev-list W/ --missing=print' ' test_expect_success 'rev-list W/ --missing=print' '
git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \ git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 \
| awk -f print_2.awk \ >ls_files_result &&
| sort >expected && awk -f print_2.awk ls_files_result |
sort >expected &&
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
done && done &&
git -C r1 rev-list --quiet HEAD --missing=print --objects \
| awk -f print_1.awk \ git -C r1 rev-list --quiet --missing=print --objects HEAD >revs &&
| sed "s/?//" \ awk -f print_1.awk revs |
| sort >observed && sed "s/?//" |
test_cmp observed expected sort >observed &&
test_cmp expected observed
' '
test_expect_success 'rev-list W/O --missing fails' ' test_expect_success 'rev-list W/O --missing fails' '

View File

@ -160,7 +160,7 @@ test_expect_success 'checkout -m with merge conflict' '
git diff master:one :3:uno | git diff master:one :3:uno |
sed -e "1,/^@@/d" -e "/^ /d" -e "s/^-/d/" -e "s/^+/a/" >current && sed -e "1,/^@@/d" -e "/^ /d" -e "s/^-/d/" -e "s/^+/a/" >current &&
fill d2 aT d7 aS >expect && fill d2 aT d7 aS >expect &&
test_cmp current expect && test_cmp expect current &&
git diff --cached two >current && git diff --cached two >current &&
test_must_be_empty current test_must_be_empty current
' '
@ -174,7 +174,7 @@ test_expect_success 'format of merge conflict from checkout -m' '
git ls-files >current && git ls-files >current &&
fill same two two two >expect && fill same two two two >expect &&
test_cmp current expect && test_cmp expect current &&
cat <<-EOF >expect && cat <<-EOF >expect &&
<<<<<<< simple <<<<<<< simple

View File

@ -789,7 +789,7 @@ test_expect_success 'submodule add places git-dir in superprojects git-dir' '
(cd .git/modules/deeper/submodule && (cd .git/modules/deeper/submodule &&
git log > ../../../../actual git log > ../../../../actual
) && ) &&
test_cmp actual expected test_cmp expected actual
) )
' '
@ -807,7 +807,7 @@ test_expect_success 'submodule update places git-dir in superprojects git-dir' '
(cd .git/modules/deeper/submodule && (cd .git/modules/deeper/submodule &&
git log > ../../../../actual git log > ../../../../actual
) && ) &&
test_cmp actual expected test_cmp expected actual
) )
' '
@ -827,7 +827,7 @@ test_expect_success 'submodule add places git-dir in superprojects git-dir recur
git add deeper/submodule && git add deeper/submodule &&
git commit -m "update submodule" && git commit -m "update submodule" &&
git push origin : && git push origin : &&
test_cmp actual expected test_cmp expected actual
) )
' '
@ -874,7 +874,7 @@ test_expect_success 'submodule update places git-dir in superprojects git-dir re
(cd .git/modules/submodule/modules/subsubmodule && (cd .git/modules/submodule/modules/subsubmodule &&
git log > ../../../../../actual git log > ../../../../../actual
) && ) &&
test_cmp actual expected test_cmp expected actual
) )
' '

View File

@ -557,7 +557,7 @@ test_expect_success SYMLINKS 'difftool --dir-diff --symlink without unstaged cha
EOF EOF
git difftool --dir-diff --symlink \ git difftool --dir-diff --symlink \
--extcmd "./.git/CHECK_SYMLINKS" branch HEAD && --extcmd "./.git/CHECK_SYMLINKS" branch HEAD &&
test_cmp actual expect test_cmp expect actual
' '
write_script modify-right-file <<\EOF write_script modify-right-file <<\EOF

View File

@ -221,7 +221,7 @@ tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e
tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4 tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4
EOF EOF
test_expect_success POSIXPERM,SYMLINKS "$name" "test_cmp a expected" test_expect_success POSIXPERM,SYMLINKS "$name" "test_cmp expected a"
test_expect_success 'exit if remote refs are ambigious' ' test_expect_success 'exit if remote refs are ambigious' '
git config --add svn-remote.svn.fetch \ git config --add svn-remote.svn.fetch \

View File

@ -174,7 +174,8 @@ test_expect_success 'test create-ignore' "
cmp ./deeply/.gitignore create-ignore.expect && cmp ./deeply/.gitignore create-ignore.expect &&
cmp ./deeply/nested/.gitignore create-ignore.expect && cmp ./deeply/nested/.gitignore create-ignore.expect &&
cmp ./deeply/nested/directory/.gitignore create-ignore.expect && cmp ./deeply/nested/directory/.gitignore create-ignore.expect &&
git ls-files -s | grep gitignore | cmp - create-ignore-index.expect git ls-files -s >ls_files_result &&
grep gitignore ls_files_result | cmp - create-ignore-index.expect
" "
cat >prop.expect <<\EOF cat >prop.expect <<\EOF
@ -189,17 +190,21 @@ EOF
# This test can be improved: since all the svn:ignore contain the same # This test can be improved: since all the svn:ignore contain the same
# pattern, it can pass even though the propget did not execute on the # pattern, it can pass even though the propget did not execute on the
# right directory. # right directory.
test_expect_success 'test propget' " test_expect_success 'test propget' '
git svn propget svn:ignore . | cmp - prop.expect && test_propget () {
git svn propget $1 $2 >actual &&
cmp $3 actual
} &&
test_propget svn:ignore . prop.expect &&
cd deeply && cd deeply &&
git svn propget svn:ignore . | cmp - ../prop.expect && test_propget svn:ignore . ../prop.expect &&
git svn propget svn:entry:committed-rev nested/directory/.keep \ test_propget svn:entry:committed-rev nested/directory/.keep \
| cmp - ../prop2.expect && ../prop2.expect &&
git svn propget svn:ignore .. | cmp - ../prop.expect && test_propget svn:ignore .. ../prop.expect &&
git svn propget svn:ignore nested/ | cmp - ../prop.expect && test_propget svn:ignore nested/ ../prop.expect &&
git svn propget svn:ignore ./nested | cmp - ../prop.expect && test_propget svn:ignore ./nested ../prop.expect &&
git svn propget svn:ignore .././deeply/nested | cmp - ../prop.expect test_propget svn:ignore .././deeply/nested ../prop.expect
" '
cat >prop.expect <<\EOF cat >prop.expect <<\EOF
Properties on '.': Properties on '.':
@ -218,8 +223,11 @@ Properties on 'nested/directory/.keep':
EOF EOF
test_expect_success 'test proplist' " test_expect_success 'test proplist' "
git svn proplist . | cmp - prop.expect && git svn proplist . >actual &&
git svn proplist nested/directory/.keep | cmp - prop2.expect cmp prop.expect actual &&
git svn proplist nested/directory/.keep >actual &&
cmp prop2.expect actual
" "
test_done test_done

View File

@ -45,7 +45,7 @@ test_expect_success 'update git svn-cloned repo' '
git svn rebase && git svn rebase &&
echo a > expect && echo a > expect &&
echo b >> expect && echo b >> expect &&
test_cmp a expect && test_cmp expect a &&
rm expect rm expect
) )
' '
@ -69,7 +69,7 @@ test_expect_success 'update git svn-cloned repo' '
git svn rebase && git svn rebase &&
echo a > expect && echo a > expect &&
echo b >> expect && echo b >> expect &&
test_cmp a expect && test_cmp expect a &&
rm expect rm expect
) )
' '
@ -93,7 +93,7 @@ test_expect_success 'update git svn-cloned repo again' '
echo a > expect && echo a > expect &&
echo b >> expect && echo b >> expect &&
echo c >> expect && echo c >> expect &&
test_cmp a expect && test_cmp expect a &&
rm expect rm expect
) )
' '

View File

@ -148,7 +148,7 @@ test_expect_success PERL 'import from a CVS working tree' '
git cvsimport -a -z0 && git cvsimport -a -z0 &&
echo 1 >expect && echo 1 >expect &&
git log -1 --pretty=format:%s%n >actual && git log -1 --pretty=format:%s%n >actual &&
test_cmp actual expect test_cmp expect actual
) )
' '

View File

@ -29,11 +29,11 @@ test_expect_failure PERL 'import with criss cross times on revisions' '
Rev 3 Rev 3
Rev 2 Rev 2
Rev 1" > expect-master && Rev 1" > expect-master &&
test_cmp actual-master expect-master && test_cmp expect-master actual-master &&
echo "Rev 5 Branch A Wed Mar 11 19:09:10 2009 +0000 echo "Rev 5 Branch A Wed Mar 11 19:09:10 2009 +0000
Rev 4 Branch A Wed Mar 11 19:03:52 2009 +0000" > expect-A && Rev 4 Branch A Wed Mar 11 19:03:52 2009 +0000" > expect-A &&
test_cmp actual-A expect-A test_cmp expect-A actual-A
' '
test_done test_done

View File

@ -31,7 +31,7 @@ test_expect_success PERL 'check timestamps are UTC (TZ=CST6CDT)' '
Rev 2 2005-02-01 00:00:00 +0000 Rev 2 2005-02-01 00:00:00 +0000
Rev 1 2005-01-01 00:00:00 +0000 Rev 1 2005-01-01 00:00:00 +0000
EOF EOF
test_cmp actual-1 expect-1 test_cmp expect-1 actual-1
' '
test_expect_success PERL 'check timestamps with author-specific timezones' ' test_expect_success PERL 'check timestamps with author-specific timezones' '
@ -65,7 +65,7 @@ test_expect_success PERL 'check timestamps with author-specific timezones' '
Rev 2 2005-01-31 18:00:00 -0600 User Two Rev 2 2005-01-31 18:00:00 -0600 User Two
Rev 1 2005-01-01 00:00:00 +0000 User One Rev 1 2005-01-01 00:00:00 +0000 User One
EOF EOF
test_cmp actual-2 expect-2 test_cmp expect-2 actual-2
' '
test_done test_done