Browse Source

Merge branch 'dl/test-cleanup'

Test cleanup.

* dl/test-cleanup: (26 commits)
  t7700: stop losing return codes of git commands
  t7700: make references to SHA-1 generic
  t7700: replace egrep with grep
  t7700: consolidate code into test_has_duplicate_object()
  t7700: consolidate code into test_no_missing_in_packs()
  t7700: s/test -f/test_path_is_file/
  t7700: move keywords onto their own line
  t7700: remove spaces after redirect operators
  t7700: drop redirections to /dev/null
  t7501: stop losing return codes of git commands
  t7501: remove spaces after redirect operators
  t5703: stop losing return codes of git commands
  t5703: simplify one-time-sed generation logic
  t5317: use ! grep to check for no matching lines
  t5317: stop losing return codes of git commands
  t4138: stop losing return codes of git commands
  t4015: use test_write_lines()
  t4015: stop losing return codes of git commands
  t3600: comment on inducing SIGPIPE in `git rm`
  t3600: stop losing return codes of git commands
  ...
maint
Junio C Hamano 5 years ago
parent
commit
c9f5fc9114
  1. 6
      t/lib-bash.sh
  2. 8
      t/lib-httpd/apply-one-time-sed.sh
  3. 4
      t/t0014-alias.sh
  4. 5
      t/t0090-cache-tree.sh
  5. 230
      t/t3301-notes.sh
  6. 14
      t/t3600-rm.sh
  7. 123
      t/t4015-diff-whitespace.sh
  8. 16
      t/t4138-apply-ws-expansion.sh
  9. 34
      t/t5317-pack-objects-filter-objects.sh
  10. 53
      t/t5703-upload-pack-ref-in-want.sh
  11. 83
      t/t7501-commit-basic-functionality.sh
  12. 172
      t/t7700-repack.sh

6
t/lib-bash.sh

@ -2,10 +2,12 @@ @@ -2,10 +2,12 @@
# to run under Bash; primarily intended for tests of the completion
# script.

if test -n "$BASH" && test -z "$POSIXLY_CORRECT"; then
if test -n "$BASH" && test -z "$POSIXLY_CORRECT"
then
# we are in full-on bash mode
true
elif type bash >/dev/null 2>&1; then
elif type bash >/dev/null 2>&1
then
# execute in full-on bash mode
unset POSIXLY_CORRECT
exec bash "$0" "$@"

8
t/lib-httpd/apply-one-time-sed.sh

@ -7,11 +7,13 @@ @@ -7,11 +7,13 @@
#
# This can be used to simulate the effects of the repository changing in
# between HTTP request-response pairs.
if [ -e one-time-sed ]; then
if test -f one-time-sed
then
"$GIT_EXEC_PATH/git-http-backend" >out
sed "$(cat one-time-sed)" <out >out_modified
sed "$(cat one-time-sed)" out >out_modified

if diff out out_modified >/dev/null; then
if cmp -s out out_modified
then
cat out
else
cat out_modified

4
t/t0014-alias.sh

@ -38,8 +38,8 @@ test_expect_success 'looping aliases - internal execution' ' @@ -38,8 +38,8 @@ test_expect_success 'looping aliases - internal execution' '
#'

test_expect_success 'run-command formats empty args properly' '
GIT_TRACE=1 git frotz a "" b " " c 2>&1 |
sed -ne "/run_command:/s/.*trace: run_command: //p" >actual &&
test_must_fail env GIT_TRACE=1 git frotz a "" b " " c 2>actual.raw &&
sed -ne "/run_command:/s/.*trace: run_command: //p" actual.raw >actual &&
echo "git-frotz a '\'''\'' b '\'' '\'' c" >expect &&
test_cmp expect actual
'

5
t/t0090-cache-tree.sh

@ -21,9 +21,10 @@ generate_expected_cache_tree_rec () { @@ -21,9 +21,10 @@ generate_expected_cache_tree_rec () {
parent="$2" &&
# ls-files might have foo/bar, foo/bar/baz, and foo/bar/quux
# We want to count only foo because it's the only direct child
subtrees=$(git ls-files|grep /|cut -d / -f 1|uniq) &&
git ls-files >files &&
subtrees=$(grep / files|cut -d / -f 1|uniq) &&
subtree_count=$(echo "$subtrees"|awk -v c=0 '$1 != "" {++c} END {print c}') &&
entries=$(git ls-files|wc -l) &&
entries=$(wc -l <files) &&
printf "SHA $dir (%d entries, %d subtrees)\n" "$entries" "$subtree_count" &&
for subtree in $subtrees
do

230
t/t3301-notes.sh

@ -54,7 +54,9 @@ test_expect_success 'create notes' ' @@ -54,7 +54,9 @@ test_expect_success 'create notes' '
test_path_is_missing .git/NOTES_EDITMSG &&
git ls-tree -r refs/notes/commits >actual &&
test_line_count = 1 actual &&
test "b4" = "$(git notes show)" &&
echo b4 >expect &&
git notes show >actual &&
test_cmp expect actual &&
git show HEAD^ &&
test_must_fail git notes show HEAD^
'
@ -79,14 +81,21 @@ test_expect_success 'edit existing notes' ' @@ -79,14 +81,21 @@ test_expect_success 'edit existing notes' '
test_path_is_missing .git/NOTES_EDITMSG &&
git ls-tree -r refs/notes/commits >actual &&
test_line_count = 1 actual &&
test "b3" = "$(git notes show)" &&
echo b3 >expect &&
git notes show >actual &&
test_cmp expect actual &&
git show HEAD^ &&
test_must_fail git notes show HEAD^
'

test_expect_success 'show notes from treeish' '
test "b3" = "$(git notes --ref commits^{tree} show)" &&
test "b4" = "$(git notes --ref commits@{1} show)"
echo b3 >expect &&
git notes --ref commits^{tree} show >actual &&
test_cmp expect actual &&

echo b4 >expect &&
git notes --ref commits@{1} show >actual &&
test_cmp expect actual
'

test_expect_success 'cannot edit notes from non-ref' '
@ -99,7 +108,9 @@ test_expect_success 'cannot "git notes add -m" where notes already exists' ' @@ -99,7 +108,9 @@ test_expect_success 'cannot "git notes add -m" where notes already exists' '
test_path_is_missing .git/NOTES_EDITMSG &&
git ls-tree -r refs/notes/commits >actual &&
test_line_count = 1 actual &&
test "b3" = "$(git notes show)" &&
echo b3 >expect &&
git notes show >actual &&
test_cmp expect actual &&
git show HEAD^ &&
test_must_fail git notes show HEAD^
'
@ -109,7 +120,9 @@ test_expect_success 'can overwrite existing note with "git notes add -f -m"' ' @@ -109,7 +120,9 @@ test_expect_success 'can overwrite existing note with "git notes add -f -m"' '
test_path_is_missing .git/NOTES_EDITMSG &&
git ls-tree -r refs/notes/commits >actual &&
test_line_count = 1 actual &&
test "b1" = "$(git notes show)" &&
echo b1 >expect &&
git notes show >actual &&
test_cmp expect actual &&
git show HEAD^ &&
test_must_fail git notes show HEAD^
'
@ -119,7 +132,9 @@ test_expect_success 'add w/no options on existing note morphs into edit' ' @@ -119,7 +132,9 @@ test_expect_success 'add w/no options on existing note morphs into edit' '
test_path_is_missing .git/NOTES_EDITMSG &&
git ls-tree -r refs/notes/commits >actual &&
test_line_count = 1 actual &&
test "b2" = "$(git notes show)" &&
echo b2 >expect &&
git notes show >actual &&
test_cmp expect actual &&
git show HEAD^ &&
test_must_fail git notes show HEAD^
'
@ -129,7 +144,9 @@ test_expect_success 'can overwrite existing note with "git notes add -f"' ' @@ -129,7 +144,9 @@ test_expect_success 'can overwrite existing note with "git notes add -f"' '
test_path_is_missing .git/NOTES_EDITMSG &&
git ls-tree -r refs/notes/commits >actual &&
test_line_count = 1 actual &&
test "b1" = "$(git notes show)" &&
echo b1 >expect &&
git notes show >actual &&
test_cmp expect actual &&
git show HEAD^ &&
test_must_fail git notes show HEAD^
'
@ -146,7 +163,8 @@ test_expect_success 'show notes' ' @@ -146,7 +163,8 @@ test_expect_success 'show notes' '
Notes:
${indent}b1
EOF
! (git cat-file commit HEAD | grep b1) &&
git cat-file commit HEAD >commits &&
! grep b1 commits &&
git log -1 >actual &&
test_cmp expect actual
'
@ -472,9 +490,11 @@ test_expect_success 'removing with --stdin --ignore-missing' ' @@ -472,9 +490,11 @@ test_expect_success 'removing with --stdin --ignore-missing' '
test_expect_success 'list notes with "git notes list"' '
commit_2=$(git rev-parse 2nd) &&
commit_3=$(git rev-parse 3rd) &&
note_2=$(git rev-parse refs/notes/commits:$commit_2) &&
note_3=$(git rev-parse refs/notes/commits:$commit_3) &&
sort -t" " -k2 >expect <<-EOF &&
$(git rev-parse refs/notes/commits:$commit_2) $commit_2
$(git rev-parse refs/notes/commits:$commit_3) $commit_3
$note_2 $commit_2
$note_3 $commit_3
EOF
git notes list >actual &&
test_cmp expect actual
@ -486,9 +506,7 @@ test_expect_success 'list notes with "git notes"' ' @@ -486,9 +506,7 @@ test_expect_success 'list notes with "git notes"' '
'

test_expect_success 'list specific note with "git notes list <object>"' '
cat >expect <<-EOF &&
$(git rev-parse refs/notes/commits:$commit_3)
EOF
git rev-parse refs/notes/commits:$commit_3 >expect &&
git notes list HEAD^^ >actual &&
test_cmp expect actual
'
@ -512,10 +530,11 @@ test_expect_success 'append to existing note with "git notes append"' ' @@ -512,10 +530,11 @@ test_expect_success 'append to existing note with "git notes append"' '

test_expect_success '"git notes list" does not expand to "git notes list HEAD"' '
commit_5=$(git rev-parse 5th) &&
note_5=$(git rev-parse refs/notes/commits:$commit_5) &&
sort -t" " -k2 >expect_list <<-EOF &&
$(git rev-parse refs/notes/commits:$commit_2) $commit_2
$(git rev-parse refs/notes/commits:$commit_3) $commit_3
$(git rev-parse refs/notes/commits:$commit_5) $commit_5
$note_2 $commit_2
$note_3 $commit_3
$note_5 $commit_5
EOF
git notes list >actual &&
test_cmp expect_list actual
@ -721,7 +740,8 @@ test_expect_success 'Allow notes on non-commits (trees, blobs, tags)' ' @@ -721,7 +740,8 @@ test_expect_success 'Allow notes on non-commits (trees, blobs, tags)' '
git notes show HEAD: >actual &&
test_cmp expect actual &&
echo "Note on a blob" >expect &&
filename=$(git ls-tree --name-only HEAD | head -n1) &&
git ls-tree --name-only HEAD >files &&
filename=$(head -n1 files) &&
git notes add -m "Note on a blob" HEAD:$filename &&
git notes show HEAD:$filename >actual &&
test_cmp expect actual &&
@ -745,10 +765,13 @@ test_expect_success 'create note from other note with "git notes add -C"' ' @@ -745,10 +765,13 @@ test_expect_success 'create note from other note with "git notes add -C"' '
Notes:
${indent}order test
EOF
git notes add -C $(git notes list HEAD^) &&
note=$(git notes list HEAD^) &&
git notes add -C $note &&
git log -1 >actual &&
test_cmp expect actual &&
test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
git notes list HEAD^ >expect &&
git notes list HEAD >actual &&
test_cmp expect actual
'

test_expect_success 'create note from non-existing note with "git notes add -C" fails' '
@ -777,11 +800,12 @@ test_expect_success 'create note from blob with "git notes add -C" reuses blob i @@ -777,11 +800,12 @@ test_expect_success 'create note from blob with "git notes add -C" reuses blob i
Notes:
${indent}This is a blob object
EOF
blob=$(echo "This is a blob object" | git hash-object -w --stdin) &&
git notes add -C $blob &&
echo "This is a blob object" | git hash-object -w --stdin >blob &&
git notes add -C $(cat blob) &&
git log -1 >actual &&
test_cmp expect actual &&
test "$(git notes list HEAD)" = "$blob"
git notes list HEAD >actual &&
test_cmp blob actual
'

test_expect_success 'create note from other note with "git notes add -c"' '
@ -797,7 +821,8 @@ test_expect_success 'create note from other note with "git notes add -c"' ' @@ -797,7 +821,8 @@ test_expect_success 'create note from other note with "git notes add -c"' '
Notes:
${indent}yet another note
EOF
MSG="yet another note" git notes add -c $(git notes list HEAD^^) &&
note=$(git notes list HEAD^^) &&
MSG="yet another note" git notes add -c $note &&
git log -1 >actual &&
test_cmp expect actual
'
@ -822,7 +847,8 @@ test_expect_success 'append to note from other note with "git notes append -C"' @@ -822,7 +847,8 @@ test_expect_success 'append to note from other note with "git notes append -C"'
${indent}
${indent}yet another note
EOF
git notes append -C $(git notes list HEAD^) HEAD^ &&
note=$(git notes list HEAD^) &&
git notes append -C $note HEAD^ &&
git log -1 HEAD^ >actual &&
test_cmp expect actual
'
@ -839,7 +865,8 @@ test_expect_success 'create note from other note with "git notes append -c"' ' @@ -839,7 +865,8 @@ test_expect_success 'create note from other note with "git notes append -c"' '
Notes:
${indent}other note
EOF
MSG="other note" git notes append -c $(git notes list HEAD^) &&
note=$(git notes list HEAD^) &&
MSG="other note" git notes append -c $note &&
git log -1 >actual &&
test_cmp expect actual
'
@ -858,7 +885,8 @@ test_expect_success 'append to note from other note with "git notes append -c"' @@ -858,7 +885,8 @@ test_expect_success 'append to note from other note with "git notes append -c"'
${indent}
${indent}yet another note
EOF
MSG="yet another note" git notes append -c $(git notes list HEAD) &&
note=$(git notes list HEAD) &&
MSG="yet another note" git notes append -c $note &&
git log -1 >actual &&
test_cmp expect actual
'
@ -878,7 +906,9 @@ test_expect_success 'copy note with "git notes copy"' ' @@ -878,7 +906,9 @@ test_expect_success 'copy note with "git notes copy"' '
git notes copy 8th 4th &&
git log 3rd..4th >actual &&
test_cmp expect actual &&
test "$(git note list 4th)" = "$(git note list 8th)"
git notes list 4th >expect &&
git notes list 8th >actual &&
test_cmp expect actual
'

test_expect_success 'copy note with "git notes copy" with default' '
@ -899,14 +929,30 @@ test_expect_success 'copy note with "git notes copy" with default' ' @@ -899,14 +929,30 @@ test_expect_success 'copy note with "git notes copy" with default' '
git notes copy HEAD^ &&
git log -1 >actual &&
test_cmp expect actual &&
test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
git notes list HEAD^ >expect &&
git notes list HEAD >actual &&
test_cmp expect actual
'

test_expect_success 'prevent overwrite with "git notes copy"' '
test_must_fail git notes copy HEAD~2 HEAD &&
cat >expect <<-EOF &&
commit $commit
Author: A U Thor <author@example.com>
Date: Thu Apr 7 15:23:13 2005 -0700

${indent}11th

Notes:
${indent}other note
${indent}
${indent}yet another note
EOF
git log -1 >actual &&
test_cmp expect actual &&
test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
git notes list HEAD^ >expect &&
git notes list HEAD >actual &&
test_cmp expect actual
'

test_expect_success 'allow overwrite with "git notes copy -f"' '
@ -924,7 +970,9 @@ test_expect_success 'allow overwrite with "git notes copy -f"' ' @@ -924,7 +970,9 @@ test_expect_success 'allow overwrite with "git notes copy -f"' '
git notes copy -f HEAD~3 HEAD &&
git log -1 >actual &&
test_cmp expect actual &&
test "$(git notes list HEAD)" = "$(git notes list HEAD~3)"
git notes list HEAD~3 >expect &&
git notes list HEAD >actual &&
test_cmp expect actual
'

test_expect_success 'allow overwrite with "git notes copy -f" with default' '
@ -944,7 +992,9 @@ test_expect_success 'allow overwrite with "git notes copy -f" with default' ' @@ -944,7 +992,9 @@ test_expect_success 'allow overwrite with "git notes copy -f" with default' '
git notes copy -f HEAD~2 &&
git log -1 >actual &&
test_cmp expect actual &&
test "$(git notes list HEAD)" = "$(git notes list HEAD~2)"
git notes list HEAD~2 >expect &&
git notes list HEAD >actual &&
test_cmp expect actual
'

test_expect_success 'cannot copy note from object without notes' '
@ -979,13 +1029,21 @@ test_expect_success 'git notes copy --stdin' ' @@ -979,13 +1029,21 @@ test_expect_success 'git notes copy --stdin' '
${indent}
${indent}yet another note
EOF
(echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^) &&
echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
git notes copy --stdin &&
from=$(git rev-parse HEAD~3) &&
to=$(git rev-parse HEAD^) &&
echo "$from" "$to" >copy &&
from=$(git rev-parse HEAD~2) &&
to=$(git rev-parse HEAD) &&
echo "$from" "$to" >>copy &&
git notes copy --stdin <copy &&
git log -2 >actual &&
test_cmp expect actual &&
test "$(git notes list HEAD)" = "$(git notes list HEAD~2)" &&
test "$(git notes list HEAD^)" = "$(git notes list HEAD~3)"
git notes list HEAD~2 >expect &&
git notes list HEAD >actual &&
test_cmp expect actual &&
git notes list HEAD~3 >expect &&
git notes list HEAD^ >actual &&
test_cmp expect actual
'

test_expect_success 'git notes copy --for-rewrite (unconfigured)' '
@ -1006,9 +1064,13 @@ test_expect_success 'git notes copy --for-rewrite (unconfigured)' ' @@ -1006,9 +1064,13 @@ test_expect_success 'git notes copy --for-rewrite (unconfigured)' '

${indent}14th
EOF
(echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^) &&
echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
git notes copy --for-rewrite=foo &&
from=$(git rev-parse HEAD~3) &&
to=$(git rev-parse HEAD^) &&
echo "$from" "$to" >copy &&
from=$(git rev-parse HEAD~2) &&
to=$(git rev-parse HEAD) &&
echo "$from" "$to" >>copy &&
git notes copy --for-rewrite=foo <copy &&
git log -2 >actual &&
test_cmp expect actual
'
@ -1041,17 +1103,23 @@ test_expect_success 'git notes copy --for-rewrite (enabled)' ' @@ -1041,17 +1103,23 @@ test_expect_success 'git notes copy --for-rewrite (enabled)' '
EOF
test_config notes.rewriteMode overwrite &&
test_config notes.rewriteRef "refs/notes/*" &&
(echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^) &&
echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
git notes copy --for-rewrite=foo &&
from=$(git rev-parse HEAD~3) &&
to=$(git rev-parse HEAD^) &&
echo "$from" "$to" >copy &&
from=$(git rev-parse HEAD~2) &&
to=$(git rev-parse HEAD) &&
echo "$from" "$to" >>copy &&
git notes copy --for-rewrite=foo <copy &&
git log -2 >actual &&
test_cmp expect actual
'

test_expect_success 'git notes copy --for-rewrite (disabled)' '
test_config notes.rewrite.bar false &&
echo $(git rev-parse HEAD~3) $(git rev-parse HEAD) |
git notes copy --for-rewrite=bar &&
from=$(git rev-parse HEAD~3) &&
to=$(git rev-parse HEAD) &&
echo "$from" "$to" >copy &&
git notes copy --for-rewrite=bar <copy &&
git log -2 >actual &&
test_cmp expect actual
'
@ -1071,8 +1139,10 @@ test_expect_success 'git notes copy --for-rewrite (overwrite)' ' @@ -1071,8 +1139,10 @@ test_expect_success 'git notes copy --for-rewrite (overwrite)' '
git notes add -f -m"a fresh note" HEAD^ &&
test_config notes.rewriteMode overwrite &&
test_config notes.rewriteRef "refs/notes/*" &&
echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
git notes copy --for-rewrite=foo &&
from=$(git rev-parse HEAD^) &&
to=$(git rev-parse HEAD) &&
echo "$from" "$to" >copy &&
git notes copy --for-rewrite=foo <copy &&
git log -1 >actual &&
test_cmp expect actual
'
@ -1080,8 +1150,10 @@ test_expect_success 'git notes copy --for-rewrite (overwrite)' ' @@ -1080,8 +1150,10 @@ test_expect_success 'git notes copy --for-rewrite (overwrite)' '
test_expect_success 'git notes copy --for-rewrite (ignore)' '
test_config notes.rewriteMode ignore &&
test_config notes.rewriteRef "refs/notes/*" &&
echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
git notes copy --for-rewrite=foo &&
from=$(git rev-parse HEAD^) &&
to=$(git rev-parse HEAD) &&
echo "$from" "$to" >copy &&
git notes copy --for-rewrite=foo <copy &&
git log -1 >actual &&
test_cmp expect actual
'
@ -1103,8 +1175,10 @@ test_expect_success 'git notes copy --for-rewrite (append)' ' @@ -1103,8 +1175,10 @@ test_expect_success 'git notes copy --for-rewrite (append)' '
git notes add -f -m"another fresh note" HEAD^ &&
test_config notes.rewriteMode concatenate &&
test_config notes.rewriteRef "refs/notes/*" &&
echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
git notes copy --for-rewrite=foo &&
from=$(git rev-parse HEAD^) &&
to=$(git rev-parse HEAD) &&
echo "$from" "$to" >copy &&
git notes copy --for-rewrite=foo <copy &&
git log -1 >actual &&
test_cmp expect actual
'
@ -1131,9 +1205,13 @@ test_expect_success 'git notes copy --for-rewrite (append two to one)' ' @@ -1131,9 +1205,13 @@ test_expect_success 'git notes copy --for-rewrite (append two to one)' '
git notes add -f -m"append 2" HEAD^^ &&
test_config notes.rewriteMode concatenate &&
test_config notes.rewriteRef "refs/notes/*" &&
(echo $(git rev-parse HEAD^) $(git rev-parse HEAD) &&
echo $(git rev-parse HEAD^^) $(git rev-parse HEAD)) |
git notes copy --for-rewrite=foo &&
from=$(git rev-parse HEAD^) &&
to=$(git rev-parse HEAD) &&
echo "$from" "$to" >copy &&
from=$(git rev-parse HEAD^^) &&
to=$(git rev-parse HEAD) &&
echo "$from" "$to" >>copy &&
git notes copy --for-rewrite=foo <copy &&
git log -1 >actual &&
test_cmp expect actual
'
@ -1142,8 +1220,10 @@ test_expect_success 'git notes copy --for-rewrite (append empty)' ' @@ -1142,8 +1220,10 @@ test_expect_success 'git notes copy --for-rewrite (append empty)' '
git notes remove HEAD^ &&
test_config notes.rewriteMode concatenate &&
test_config notes.rewriteRef "refs/notes/*" &&
echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
git notes copy --for-rewrite=foo &&
from=$(git rev-parse HEAD^) &&
to=$(git rev-parse HEAD) &&
echo "$from" "$to" >copy &&
git notes copy --for-rewrite=foo <copy &&
git log -1 >actual &&
test_cmp expect actual
'
@ -1163,8 +1243,10 @@ test_expect_success 'GIT_NOTES_REWRITE_MODE works' ' @@ -1163,8 +1243,10 @@ test_expect_success 'GIT_NOTES_REWRITE_MODE works' '
test_config notes.rewriteMode concatenate &&
test_config notes.rewriteRef "refs/notes/*" &&
git notes add -f -m"replacement note 1" HEAD^ &&
echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
GIT_NOTES_REWRITE_MODE=overwrite git notes copy --for-rewrite=foo &&
from=$(git rev-parse HEAD^) &&
to=$(git rev-parse HEAD) &&
echo "$from" "$to" >copy &&
GIT_NOTES_REWRITE_MODE=overwrite git notes copy --for-rewrite=foo <copy &&
git log -1 >actual &&
test_cmp expect actual
'
@ -1184,9 +1266,11 @@ test_expect_success 'GIT_NOTES_REWRITE_REF works' ' @@ -1184,9 +1266,11 @@ test_expect_success 'GIT_NOTES_REWRITE_REF works' '
git notes add -f -m"replacement note 2" HEAD^ &&
test_config notes.rewriteMode overwrite &&
test_unconfig notes.rewriteRef &&
echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
from=$(git rev-parse HEAD^) &&
to=$(git rev-parse HEAD) &&
echo "$from" "$to" >copy &&
GIT_NOTES_REWRITE_REF=refs/notes/commits:refs/notes/other \
git notes copy --for-rewrite=foo &&
git notes copy --for-rewrite=foo <copy &&
git log -1 >actual &&
test_cmp expect actual
'
@ -1195,9 +1279,11 @@ test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' ' @@ -1195,9 +1279,11 @@ test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' '
git notes add -f -m"replacement note 3" HEAD^ &&
test_config notes.rewriteMode overwrite &&
test_config notes.rewriteRef refs/notes/other &&
echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
from=$(git rev-parse HEAD^) &&
to=$(git rev-parse HEAD) &&
echo "$from" "$to" >copy &&
GIT_NOTES_REWRITE_REF=refs/notes/commits \
git notes copy --for-rewrite=foo &&
git notes copy --for-rewrite=foo <copy &&
git log -1 >actual &&
grep "replacement note 3" actual
'
@ -1212,26 +1298,36 @@ test_expect_success 'git notes copy diagnoses too many or too few parameters' ' @@ -1212,26 +1298,36 @@ test_expect_success 'git notes copy diagnoses too many or too few parameters' '
test_expect_success 'git notes get-ref expands refs/heads/master to refs/notes/refs/heads/master' '
test_unconfig core.notesRef &&
sane_unset GIT_NOTES_REF &&
test "$(git notes --ref=refs/heads/master get-ref)" = "refs/notes/refs/heads/master"
echo refs/notes/refs/heads/master >expect &&
git notes --ref=refs/heads/master get-ref >actual &&
test_cmp expect actual
'

test_expect_success 'git notes get-ref (no overrides)' '
test_unconfig core.notesRef &&
sane_unset GIT_NOTES_REF &&
test "$(git notes get-ref)" = "refs/notes/commits"
echo refs/notes/commits >expect &&
git notes get-ref >actual &&
test_cmp expect actual
'

test_expect_success 'git notes get-ref (core.notesRef)' '
test_config core.notesRef refs/notes/foo &&
test "$(git notes get-ref)" = "refs/notes/foo"
echo refs/notes/foo >expect &&
git notes get-ref >actual &&
test_cmp expect actual
'

test_expect_success 'git notes get-ref (GIT_NOTES_REF)' '
test "$(GIT_NOTES_REF=refs/notes/bar git notes get-ref)" = "refs/notes/bar"
echo refs/notes/bar >expect &&
GIT_NOTES_REF=refs/notes/bar git notes get-ref >actual &&
test_cmp expect actual
'

test_expect_success 'git notes get-ref (--ref)' '
test "$(GIT_NOTES_REF=refs/notes/bar git notes --ref=baz get-ref)" = "refs/notes/baz"
echo refs/notes/baz >expect &&
GIT_NOTES_REF=refs/notes/bar git notes --ref=baz get-ref >actual &&
test_cmp expect actual
'

test_expect_success 'setup testing of empty notes' '

14
t/t3600-rm.sh

@ -113,9 +113,10 @@ test_expect_success '"rm" command printed' ' @@ -113,9 +113,10 @@ test_expect_success '"rm" command printed' '
echo frotz >test-file &&
git add test-file &&
git commit -m "add file for rm test" &&
git rm test-file >rm-output &&
test $(grep "^rm " rm-output | wc -l) = 1 &&
rm -f test-file rm-output &&
git rm test-file >rm-output.raw &&
grep "^rm " rm-output.raw >rm-output &&
test_line_count = 1 rm-output &&
rm -f test-file rm-output.raw rm-output &&
git commit -m "remove file from rm test"
'

@ -250,6 +251,7 @@ test_expect_success 'choking "git rm" should not let it die with cruft' ' @@ -250,6 +251,7 @@ test_expect_success 'choking "git rm" should not let it die with cruft' '
echo "100644 $hash 0 some-file-$i"
i=$(( $i + 1 ))
done | git update-index --index-info &&
# git command is intentionally placed upstream of pipe to induce SIGPIPE
git rm -n "some-file-*" | : &&
test_path_is_missing .git/index.lock
'
@ -303,7 +305,8 @@ EOF @@ -303,7 +305,8 @@ EOF

test_expect_success 'rm removes empty submodules from work tree' '
mkdir submod &&
git update-index --add --cacheinfo 160000 $(git rev-parse HEAD) submod &&
hash=$(git rev-parse HEAD) &&
git update-index --add --cacheinfo 160000 "$hash" submod &&
git config -f .gitmodules submodule.sub.url ./. &&
git config -f .gitmodules submodule.sub.path submod &&
git submodule init &&
@ -622,7 +625,8 @@ test_expect_success 'setup subsubmodule' ' @@ -622,7 +625,8 @@ test_expect_success 'setup subsubmodule' '
git submodule update &&
(
cd submod &&
git update-index --add --cacheinfo 160000 $(git rev-parse HEAD) subsubmod &&
hash=$(git rev-parse HEAD) &&
git update-index --add --cacheinfo 160000 "$hash" subsubmod &&
git config -f .gitmodules submodule.sub.url ../. &&
git config -f .gitmodules submodule.sub.path subsubmod &&
git submodule init &&

123
t/t4015-diff-whitespace.sh

@ -16,7 +16,8 @@ test_expect_success "Ray Lehtiniemi's example" ' @@ -16,7 +16,8 @@ test_expect_success "Ray Lehtiniemi's example" '
} while (0);
EOF
git update-index --add x &&
before=$(git rev-parse --short $(git hash-object x)) &&
old_hash_x=$(git hash-object x) &&
before=$(git rev-parse --short "$old_hash_x") &&

cat <<-\EOF >x &&
do
@ -25,7 +26,8 @@ test_expect_success "Ray Lehtiniemi's example" ' @@ -25,7 +26,8 @@ test_expect_success "Ray Lehtiniemi's example" '
}
while (0);
EOF
after=$(git rev-parse --short $(git hash-object x)) &&
new_hash_x=$(git hash-object x) &&
after=$(git rev-parse --short "$new_hash_x") &&

cat <<-EOF >expect &&
diff --git a/x b/x
@ -63,7 +65,8 @@ test_expect_success 'another test, without options' ' @@ -63,7 +65,8 @@ test_expect_success 'another test, without options' '
EOF

git update-index x &&
before=$(git rev-parse --short $(git hash-object x)) &&
old_hash_x=$(git hash-object x) &&
before=$(git rev-parse --short "$old_hash_x") &&

tr "_" " " <<-\EOF >x &&
_ whitespace at beginning
@ -73,7 +76,8 @@ test_expect_success 'another test, without options' ' @@ -73,7 +76,8 @@ test_expect_success 'another test, without options' '
unchanged line
CR at end
EOF
after=$(git rev-parse --short $(git hash-object x)) &&
new_hash_x=$(git hash-object x) &&
after=$(git rev-parse --short "$new_hash_x") &&

tr "Q_" "\015 " <<-EOF >expect &&
diff --git a/x b/x
@ -526,13 +530,15 @@ test_expect_success 'ignore-blank-lines: mix changes and blank lines' ' @@ -526,13 +530,15 @@ test_expect_success 'ignore-blank-lines: mix changes and blank lines' '
test_expect_success 'check mixed spaces and tabs in indent' '
# This is indented with SP HT SP.
echo " foo();" >x &&
git diff --check | grep "space before tab in indent"
test_must_fail git diff --check >check &&
grep "space before tab in indent" check
'

test_expect_success 'check mixed tabs and spaces in indent' '
# This is indented with HT SP HT.
echo " foo();" >x &&
git diff --check | grep "space before tab in indent"
test_must_fail git diff --check >check &&
grep "space before tab in indent" check
'

test_expect_success 'check with no whitespace errors' '
@ -753,20 +759,23 @@ test_expect_success 'check tab-in-indent excluded from wildcard whitespace attri @@ -753,20 +759,23 @@ test_expect_success 'check tab-in-indent excluded from wildcard whitespace attri
test_expect_success 'line numbers in --check output are correct' '
echo "" >x &&
echo "foo(); " >>x &&
git diff --check | grep "x:2:"
test_must_fail git diff --check >check &&
grep "x:2:" check
'

test_expect_success 'checkdiff detects new trailing blank lines (1)' '
echo "foo();" >x &&
echo "" >>x &&
git diff --check | grep "new blank line"
test_must_fail git diff --check >check &&
grep "new blank line" check
'

test_expect_success 'checkdiff detects new trailing blank lines (2)' '
{ echo a; echo b; echo; echo; } >x &&
test_write_lines a b "" "" >x &&
git add x &&
{ echo a; echo; echo; echo; echo; } >x &&
git diff --check | grep "new blank line"
test_write_lines a "" "" "" "" >x &&
test_must_fail git diff --check >check &&
grep "new blank line" check
'

test_expect_success 'checkdiff allows new blank lines' '
@ -794,14 +803,16 @@ test_expect_success 'whitespace-only changes reported across renames' ' @@ -794,14 +803,16 @@ test_expect_success 'whitespace-only changes reported across renames' '
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 &&
git add x &&
before=$(git rev-parse --short $(git hash-object x)) &&
hash_x=$(git hash-object x) &&
before=$(git rev-parse --short "$hash_x") &&
git commit -m "base" &&
sed -e "5s/^/ /" x >z &&
git rm x &&
git add z &&
after=$(git rev-parse --short $(git hash-object z)) &&
git diff -w -M --cached |
sed -e "/^similarity index /s/[0-9][0-9]*/NUM/" >actual &&
hash_z=$(git hash-object z) &&
after=$(git rev-parse --short "$hash_z") &&
git diff -w -M --cached >actual.raw &&
sed -e "/^similarity index /s/[0-9][0-9]*/NUM/" actual.raw >actual &&
cat <<-EOF >expect &&
diff --git a/x b/z
similarity index NUM%
@ -840,7 +851,8 @@ test_expect_success 'combined diff with autocrlf conversion' ' @@ -840,7 +851,8 @@ test_expect_success 'combined diff with autocrlf conversion' '
git config core.autocrlf true &&
test_must_fail git merge master &&

git diff | sed -e "1,/^@@@/d" >actual &&
git diff >actual.raw &&
sed -e "1,/^@@@/d" actual.raw >actual &&
! grep "^-" actual

'
@ -864,11 +876,14 @@ test_expect_success 'diff that introduces a line with only tabs' ' @@ -864,11 +876,14 @@ test_expect_success 'diff that introduces a line with only tabs' '
git config core.whitespace blank-at-eol &&
git reset --hard &&
echo "test" >x &&
before=$(git rev-parse --short $(git hash-object x)) &&
old_hash_x=$(git hash-object x) &&
before=$(git rev-parse --short "$old_hash_x") &&
git commit -m "initial" x &&
echo "{NTN}" | tr "NT" "\n\t" >>x &&
after=$(git rev-parse --short $(git hash-object x)) &&
git diff --color | test_decode_color >current &&
new_hash_x=$(git hash-object x) &&
after=$(git rev-parse --short "$new_hash_x") &&
git diff --color >current.raw &&
test_decode_color <current.raw >current &&

cat >expected <<-EOF &&
<BOLD>diff --git a/x b/x<RESET>
@ -891,17 +906,19 @@ test_expect_success 'diff that introduces and removes ws breakages' ' @@ -891,17 +906,19 @@ test_expect_success 'diff that introduces and removes ws breakages' '
echo "0. blank-at-eol " &&
echo "1. blank-at-eol "
} >x &&
before=$(git rev-parse --short $(git hash-object x)) &&
old_hash_x=$(git hash-object x) &&
before=$(git rev-parse --short "$old_hash_x") &&
git commit -a --allow-empty -m preimage &&
{
echo "0. blank-at-eol " &&
echo "1. still-blank-at-eol " &&
echo "2. and a new line "
} >x &&
after=$(git rev-parse --short $(git hash-object x)) &&
new_hash_x=$(git hash-object x) &&
after=$(git rev-parse --short "$new_hash_x") &&

git diff --color |
test_decode_color >current &&
git diff --color >current.raw &&
test_decode_color <current.raw >current &&

cat >expected <<-EOF &&
<BOLD>diff --git a/x b/x<RESET>
@ -925,14 +942,16 @@ test_expect_success 'ws-error-highlight test setup' ' @@ -925,14 +942,16 @@ test_expect_success 'ws-error-highlight test setup' '
echo "0. blank-at-eol " &&
echo "1. blank-at-eol "
} >x &&
before=$(git rev-parse --short $(git hash-object x)) &&
old_hash_x=$(git hash-object x) &&
before=$(git rev-parse --short "$old_hash_x") &&
git commit -a --allow-empty -m preimage &&
{
echo "0. blank-at-eol " &&
echo "1. still-blank-at-eol " &&
echo "2. and a new line "
} >x &&
after=$(git rev-parse --short $(git hash-object x)) &&
new_hash_x=$(git hash-object x) &&
after=$(git rev-parse --short "$new_hash_x") &&

cat >expect.default-old <<-EOF &&
<BOLD>diff --git a/x b/x<RESET>
@ -974,32 +993,32 @@ test_expect_success 'ws-error-highlight test setup' ' @@ -974,32 +993,32 @@ test_expect_success 'ws-error-highlight test setup' '

test_expect_success 'test --ws-error-highlight option' '

git diff --color --ws-error-highlight=default,old |
test_decode_color >current &&
git diff --color --ws-error-highlight=default,old >current.raw &&
test_decode_color <current.raw >current &&
test_cmp expect.default-old current &&

git diff --color --ws-error-highlight=all |
test_decode_color >current &&
git diff --color --ws-error-highlight=all >current.raw &&
test_decode_color <current.raw >current &&
test_cmp expect.all current &&

git diff --color --ws-error-highlight=none |
test_decode_color >current &&
git diff --color --ws-error-highlight=none >current.raw &&
test_decode_color <current.raw >current &&
test_cmp expect.none current

'

test_expect_success 'test diff.wsErrorHighlight config' '

git -c diff.wsErrorHighlight=default,old diff --color |
test_decode_color >current &&
git -c diff.wsErrorHighlight=default,old diff --color >current.raw &&
test_decode_color <current.raw >current &&
test_cmp expect.default-old current &&

git -c diff.wsErrorHighlight=all diff --color |
test_decode_color >current &&
git -c diff.wsErrorHighlight=all diff --color >current.raw &&
test_decode_color <current.raw >current &&
test_cmp expect.all current &&

git -c diff.wsErrorHighlight=none diff --color |
test_decode_color >current &&
git -c diff.wsErrorHighlight=none diff --color >current.raw &&
test_decode_color <current.raw >current &&
test_cmp expect.none current

'
@ -1007,18 +1026,18 @@ test_expect_success 'test diff.wsErrorHighlight config' ' @@ -1007,18 +1026,18 @@ test_expect_success 'test diff.wsErrorHighlight config' '
test_expect_success 'option overrides diff.wsErrorHighlight' '

git -c diff.wsErrorHighlight=none \
diff --color --ws-error-highlight=default,old |
test_decode_color >current &&
diff --color --ws-error-highlight=default,old >current.raw &&
test_decode_color <current.raw >current &&
test_cmp expect.default-old current &&

git -c diff.wsErrorHighlight=default \
diff --color --ws-error-highlight=all |
test_decode_color >current &&
diff --color --ws-error-highlight=all >current.raw &&
test_decode_color <current.raw >current &&
test_cmp expect.all current &&

git -c diff.wsErrorHighlight=all \
diff --color --ws-error-highlight=none |
test_decode_color >current &&
diff --color --ws-error-highlight=none >current.raw &&
test_decode_color <current.raw >current &&
test_cmp expect.none current

'
@ -1038,7 +1057,8 @@ test_expect_success 'detect moved code, complete file' ' @@ -1038,7 +1057,8 @@ test_expect_success 'detect moved code, complete file' '
git mv test.c main.c &&
test_config color.diff.oldMoved "normal red" &&
test_config color.diff.newMoved "normal green" &&
git diff HEAD --color-moved=zebra --color --no-renames | test_decode_color >actual &&
git diff HEAD --color-moved=zebra --color --no-renames >actual.raw &&
test_decode_color <actual.raw >actual &&
cat >expected <<-EOF &&
<BOLD>diff --git a/main.c b/main.c<RESET>
<BOLD>new file mode 100644<RESET>
@ -1141,9 +1161,12 @@ test_expect_success 'detect malicious moved code, inside file' ' @@ -1141,9 +1161,12 @@ test_expect_success 'detect malicious moved code, inside file' '
bar();
}
EOF
after_main=$(git rev-parse --short $(git hash-object main.c)) &&
after_test=$(git rev-parse --short $(git hash-object test.c)) &&
git diff HEAD --no-renames --color-moved=zebra --color | test_decode_color >actual &&
hash_main=$(git hash-object main.c) &&
after_main=$(git rev-parse --short "$hash_main") &&
hash_test=$(git hash-object test.c) &&
after_test=$(git rev-parse --short "$hash_test") &&
git diff HEAD --no-renames --color-moved=zebra --color >actual.raw &&
test_decode_color <actual.raw >actual &&
cat <<-EOF >expected &&
<BOLD>diff --git a/main.c b/main.c<RESET>
<BOLD>index $before_main..$after_main 100644<RESET>
@ -1192,7 +1215,8 @@ test_expect_success 'plain moved code, inside file' ' @@ -1192,7 +1215,8 @@ test_expect_success 'plain moved code, inside file' '
test_config color.diff.oldMovedAlternative "blue" &&
test_config color.diff.newMovedAlternative "yellow" &&
# needs previous test as setup
git diff HEAD --no-renames --color-moved=plain --color | test_decode_color >actual &&
git diff HEAD --no-renames --color-moved=plain --color >actual.raw &&
test_decode_color <actual.raw >actual &&
cat <<-EOF >expected &&
<BOLD>diff --git a/main.c b/main.c<RESET>
<BOLD>index $before_main..$after_main 100644<RESET>
@ -1771,7 +1795,8 @@ test_expect_success 'move detection with submodules' ' @@ -1771,7 +1795,8 @@ test_expect_success 'move detection with submodules' '
! grep BRED decoded_actual &&

# nor did we mess with it another way
git diff --submodule=diff --color | test_decode_color >expect &&
git diff --submodule=diff --color >expect.raw &&
test_decode_color <expect.raw >expect &&
test_cmp expect decoded_actual &&
rm -rf bananas &&
git submodule deinit bananas

16
t/t4138-apply-ws-expansion.sh

@ -17,8 +17,8 @@ test_expect_success setup ' @@ -17,8 +17,8 @@ test_expect_success setup '
printf "\t%s\n" 1 2 3 >after &&
printf "%64s\n" a b c >>after &&
printf "\t%s\n" 4 5 6 >>after &&
git diff --no-index before after |
sed -e "s/before/test-1/" -e "s/after/test-1/" >patch1.patch &&
test_expect_code 1 git diff --no-index before after >patch1.patch.raw &&
sed -e "s/before/test-1/" -e "s/after/test-1/" patch1.patch.raw >patch1.patch &&
printf "%64s\n" 1 2 3 4 5 6 >test-1 &&
printf "%64s\n" 1 2 3 a b c 4 5 6 >expect-1 &&

@ -33,8 +33,8 @@ test_expect_success setup ' @@ -33,8 +33,8 @@ test_expect_success setup '
x=$(( $x + 1 ))
done &&
printf "\t%s\n" d e f >>after &&
git diff --no-index before after |
sed -e "s/before/test-2/" -e "s/after/test-2/" >patch2.patch &&
test_expect_code 1 git diff --no-index before after >patch2.patch.raw &&
sed -e "s/before/test-2/" -e "s/after/test-2/" patch2.patch.raw >patch2.patch &&
printf "%64s\n" a b c d e f >test-2 &&
printf "%64s\n" a b c >expect-2 &&
x=1 &&
@ -56,8 +56,8 @@ test_expect_success setup ' @@ -56,8 +56,8 @@ test_expect_success setup '
x=$(( $x + 1 ))
done &&
printf "\t%s\n" d e f >>after &&
git diff --no-index before after |
sed -e "s/before/test-3/" -e "s/after/test-3/" >patch3.patch &&
test_expect_code 1 git diff --no-index before after >patch3.patch.raw &&
sed -e "s/before/test-3/" -e "s/after/test-3/" patch3.patch.raw >patch3.patch &&
printf "%64s\n" a b c d e f >test-3 &&
printf "%64s\n" a b c >expect-3 &&
x=0 &&
@ -84,8 +84,8 @@ test_expect_success setup ' @@ -84,8 +84,8 @@ test_expect_success setup '
printf "\t%02d\n" $x >>after
x=$(( $x + 1 ))
done &&
git diff --no-index before after |
sed -e "s/before/test-4/" -e "s/after/test-4/" >patch4.patch &&
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 &&
>test-4 &&
x=0 &&
while test $x -lt 50

34
t/t5317-pack-objects-filter-objects.sh

@ -45,12 +45,7 @@ test_expect_success 'verify blob:none packfile has no blobs' ' @@ -45,12 +45,7 @@ test_expect_success 'verify blob:none packfile has no blobs' '
git -C r1 index-pack ../filter.pack &&

git -C r1 verify-pack -v ../filter.pack >verify_result &&
grep blob verify_result |
awk -f print_1.awk |
sort >observed &&

nr=$(wc -l <observed) &&
test 0 -eq $nr
! grep blob verify_result
'

test_expect_success 'verify normal and blob:none packfiles have same commits/trees' '
@ -72,7 +67,8 @@ test_expect_success 'get an error for missing tree object' ' @@ -72,7 +67,8 @@ test_expect_success 'get an error for missing tree object' '
echo foo >r5/foo &&
git -C r5 add foo &&
git -C r5 commit -m "foo" &&
del=$(git -C r5 rev-parse HEAD^{tree} | sed "s|..|&/|") &&
git -C r5 rev-parse HEAD^{tree} >tree &&
del=$(sed "s|..|&/|" tree) &&
rm r5/.git/objects/$del &&
test_must_fail git -C r5 pack-objects --revs --stdout 2>bad_tree <<-EOF &&
HEAD
@ -148,12 +144,7 @@ test_expect_success 'verify blob:limit=500 omits all blobs' ' @@ -148,12 +144,7 @@ test_expect_success 'verify blob:limit=500 omits all blobs' '
git -C r2 index-pack ../filter.pack &&

git -C r2 verify-pack -v ../filter.pack >verify_result &&
grep blob verify_result |
awk -f print_1.awk |
sort >observed &&

nr=$(wc -l <observed) &&
test 0 -eq $nr
! grep blob verify_result
'

test_expect_success 'verify blob:limit=1000' '
@ -163,12 +154,7 @@ test_expect_success 'verify blob:limit=1000' ' @@ -163,12 +154,7 @@ test_expect_success 'verify blob:limit=1000' '
git -C r2 index-pack ../filter.pack &&

git -C r2 verify-pack -v ../filter.pack >verify_result &&
grep blob verify_result |
awk -f print_1.awk |
sort >observed &&

nr=$(wc -l <observed) &&
test 0 -eq $nr
! grep blob verify_result
'

test_expect_success 'verify blob:limit=1001' '
@ -230,10 +216,9 @@ test_expect_success 'verify explicitly specifying oversized blob in input' ' @@ -230,10 +216,9 @@ test_expect_success 'verify explicitly specifying oversized blob in input' '
awk -f print_2.awk ls_files_result |
sort >expected &&

git -C r2 pack-objects --revs --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
HEAD
$(git -C r2 rev-parse HEAD:large.10000)
EOF
echo HEAD >objects &&
git -C r2 rev-parse HEAD:large.10000 >>objects &&
git -C r2 pack-objects --revs --stdout --filter=blob:limit=1k <objects >filter.pack &&
git -C r2 index-pack ../filter.pack &&

git -C r2 verify-pack -v ../filter.pack >verify_result &&
@ -377,7 +362,8 @@ test_expect_success 'verify sparse:oid=OID' ' @@ -377,7 +362,8 @@ test_expect_success 'verify sparse:oid=OID' '
awk -f print_2.awk ls_files_result |
sort >expected &&

oid=$(git -C r4 ls-files -s pattern | awk -f print_2.awk) &&
git -C r4 ls-files -s pattern >staged &&
oid=$(awk -f print_2.awk staged) &&
git -C r4 pack-objects --revs --stdout --filter=sparse:oid=$oid >filter.pack <<-EOF &&
HEAD
EOF

53
t/t5703-upload-pack-ref-in-want.sh

@ -18,14 +18,16 @@ get_actual_commits () { @@ -18,14 +18,16 @@ get_actual_commits () {
p
}' <out | test-tool pkt-line unpack-sideband >o.pack &&
git index-pack o.pack &&
git verify-pack -v o.idx | grep commit | cut -c-40 | sort >actual_commits
git verify-pack -v o.idx >objs &&
grep commit objs | cut -c-40 | sort >actual_commits
}

check_output () {
get_actual_refs &&
test_cmp expected_refs actual_refs &&
get_actual_commits &&
test_cmp expected_commits actual_commits
sort expected_commits >sorted_commits &&
test_cmp sorted_commits actual_commits
}

# c(o/foo) d(o/bar)
@ -75,17 +77,19 @@ test_expect_success 'invalid want-ref line' ' @@ -75,17 +77,19 @@ test_expect_success 'invalid want-ref line' '
'

test_expect_success 'basic want-ref' '
oid=$(git rev-parse f) &&
cat >expected_refs <<-EOF &&
$(git rev-parse f) refs/heads/master
$oid refs/heads/master
EOF
git rev-parse f | sort >expected_commits &&
git rev-parse f >expected_commits &&

oid=$(git rev-parse a) &&
test-tool pkt-line pack >in <<-EOF &&
command=fetch
0001
no-progress
want-ref refs/heads/master
have $(git rev-parse a)
have $oid
done
0000
EOF
@ -95,19 +99,22 @@ test_expect_success 'basic want-ref' ' @@ -95,19 +99,22 @@ test_expect_success 'basic want-ref' '
'

test_expect_success 'multiple want-ref lines' '
oid_c=$(git rev-parse c) &&
oid_d=$(git rev-parse d) &&
cat >expected_refs <<-EOF &&
$(git rev-parse c) refs/heads/o/foo
$(git rev-parse d) refs/heads/o/bar
$oid_c refs/heads/o/foo
$oid_d refs/heads/o/bar
EOF
git rev-parse c d | sort >expected_commits &&
git rev-parse c d >expected_commits &&

oid=$(git rev-parse b) &&
test-tool pkt-line pack >in <<-EOF &&
command=fetch
0001
no-progress
want-ref refs/heads/o/foo
want-ref refs/heads/o/bar
have $(git rev-parse b)
have $oid
done
0000
EOF
@ -117,10 +124,11 @@ test_expect_success 'multiple want-ref lines' ' @@ -117,10 +124,11 @@ test_expect_success 'multiple want-ref lines' '
'

test_expect_success 'mix want and want-ref' '
oid=$(git rev-parse f) &&
cat >expected_refs <<-EOF &&
$(git rev-parse f) refs/heads/master
$oid refs/heads/master
EOF
git rev-parse e f | sort >expected_commits &&
git rev-parse e f >expected_commits &&

test-tool pkt-line pack >in <<-EOF &&
command=fetch
@ -138,17 +146,19 @@ test_expect_success 'mix want and want-ref' ' @@ -138,17 +146,19 @@ test_expect_success 'mix want and want-ref' '
'

test_expect_success 'want-ref with ref we already have commit for' '
oid=$(git rev-parse c) &&
cat >expected_refs <<-EOF &&
$(git rev-parse c) refs/heads/o/foo
$oid refs/heads/o/foo
EOF
>expected_commits &&

oid=$(git rev-parse c) &&
test-tool pkt-line pack >in <<-EOF &&
command=fetch
0001
no-progress
want-ref refs/heads/o/foo
have $(git rev-parse c)
have $oid
done
0000
EOF
@ -211,13 +221,14 @@ test_expect_success 'fetching with exact OID' ' @@ -211,13 +221,14 @@ test_expect_success 'fetching with exact OID' '

rm -rf local &&
cp -r "$LOCAL_PRISTINE" local &&
oid=$(git -C "$REPO" rev-parse d) &&
GIT_TRACE_PACKET="$(pwd)/log" git -C local fetch origin \
$(git -C "$REPO" rev-parse d):refs/heads/actual &&
"$oid":refs/heads/actual &&

git -C "$REPO" rev-parse "d" >expected &&
git -C local rev-parse refs/heads/actual >actual &&
test_cmp expected actual &&
grep "want $(git -C "$REPO" rev-parse d)" log
grep "want $oid" log
'

test_expect_success 'fetching multiple refs' '
@ -239,13 +250,14 @@ test_expect_success 'fetching ref and exact OID' ' @@ -239,13 +250,14 @@ test_expect_success 'fetching ref and exact OID' '

rm -rf local &&
cp -r "$LOCAL_PRISTINE" local &&
oid=$(git -C "$REPO" rev-parse b) &&
GIT_TRACE_PACKET="$(pwd)/log" git -C local fetch origin \
master $(git -C "$REPO" rev-parse b):refs/heads/actual &&
master "$oid":refs/heads/actual &&

git -C "$REPO" rev-parse "master" "b" >expected &&
git -C local rev-parse refs/remotes/origin/master refs/heads/actual >actual &&
test_cmp expected actual &&
grep "want $(git -C "$REPO" rev-parse b)" log &&
grep "want $oid" log &&
grep "want-ref refs/heads/master" log
'

@ -312,10 +324,9 @@ inconsistency () { @@ -312,10 +324,9 @@ inconsistency () {
# repository appears to change during negotiation, for example, when
# different servers in a load-balancing arrangement serve (stateless)
# RPCs during a single negotiation.
printf "s/%s/%s/" \
$(git -C "$REPO" rev-parse $1 | tr -d "\n") \
$(git -C "$REPO" rev-parse $2 | tr -d "\n") \
>"$HTTPD_ROOT_PATH/one-time-sed"
oid1=$(git -C "$REPO" rev-parse $1) &&
oid2=$(git -C "$REPO" rev-parse $2) &&
echo "s/$oid1/$oid2/" >"$HTTPD_ROOT_PATH/one-time-sed"
}

test_expect_success 'server is initially ahead - no ref in want' '

83
t/t7501-commit-basic-functionality.sh

@ -150,7 +150,7 @@ test_expect_success 'setup: commit message from file' ' @@ -150,7 +150,7 @@ test_expect_success 'setup: commit message from file' '
test_expect_success 'amend commit' '
cat >editor <<-\EOF &&
#!/bin/sh
sed -e "s/a file/an amend commit/g" < "$1" > "$1-"
sed -e "s/a file/an amend commit/g" <"$1" >"$1-"
mv "$1-" "$1"
EOF
chmod 755 editor &&
@ -263,7 +263,7 @@ test_expect_success 'using message from other commit' ' @@ -263,7 +263,7 @@ test_expect_success 'using message from other commit' '
test_expect_success 'editing message from other commit' '
cat >editor <<-\EOF &&
#!/bin/sh
sed -e "s/amend/older/g" < "$1" > "$1-"
sed -e "s/amend/older/g" <"$1" >"$1-"
mv "$1-" "$1"
EOF
chmod 755 editor &&
@ -285,9 +285,8 @@ test_expect_success 'overriding author from command line' ' @@ -285,9 +285,8 @@ test_expect_success 'overriding author from command line' '
'

test_expect_success PERL 'interactive add' '
echo 7 |
git commit --interactive |
grep "What now"
echo 7 | test_must_fail git commit --interactive >out &&
grep "What now" out
'

test_expect_success PERL "commit --interactive doesn't change index if editor aborts" '
@ -362,12 +361,12 @@ test_expect_success 'amend commit to fix author' ' @@ -362,12 +361,12 @@ test_expect_success 'amend commit to fix author' '
oldtick=$GIT_AUTHOR_DATE &&
test_tick &&
git reset --hard &&
git cat-file -p HEAD |
git cat-file -p HEAD >commit &&
sed -e "s/author.*/author $author $oldtick/" \
-e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" > \
expected &&
-e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" \
commit >expected &&
git commit --amend --author="$author" &&
git cat-file -p HEAD > current &&
git cat-file -p HEAD >current &&
test_cmp expected current

'
@ -377,12 +376,12 @@ test_expect_success 'amend commit to fix date' ' @@ -377,12 +376,12 @@ test_expect_success 'amend commit to fix date' '
test_tick &&
newtick=$GIT_AUTHOR_DATE &&
git reset --hard &&
git cat-file -p HEAD |
git cat-file -p HEAD >commit &&
sed -e "s/author.*/author $author $newtick/" \
-e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" > \
expected &&
-e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" \
commit >expected &&
git commit --amend --date="$newtick" &&
git cat-file -p HEAD > current &&
git cat-file -p HEAD >current &&
test_cmp expected current

'
@ -409,12 +408,13 @@ test_expect_success 'sign off (1)' ' @@ -409,12 +408,13 @@ test_expect_success 'sign off (1)' '
echo 1 >positive &&
git add positive &&
git commit -s -m "thank you" &&
git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
git cat-file commit HEAD >commit &&
sed -e "1,/^\$/d" commit >actual &&
(
echo thank you &&
echo &&
git var GIT_COMMITTER_IDENT |
sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
git var GIT_COMMITTER_IDENT >ident &&
sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident
) >expected &&
test_cmp expected actual

@ -428,13 +428,14 @@ test_expect_success 'sign off (2)' ' @@ -428,13 +428,14 @@ test_expect_success 'sign off (2)' '
git commit -s -m "thank you

$existing" &&
git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
git cat-file commit HEAD >commit &&
sed -e "1,/^\$/d" commit >actual &&
(
echo thank you &&
echo &&
echo $existing &&
git var GIT_COMMITTER_IDENT |
sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
git var GIT_COMMITTER_IDENT >ident &&
sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident
) >expected &&
test_cmp expected actual

@ -448,13 +449,14 @@ test_expect_success 'signoff gap' ' @@ -448,13 +449,14 @@ test_expect_success 'signoff gap' '
git commit -s -m "welcome

$alt" &&
git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
git cat-file commit HEAD >commit &&
sed -e "1,/^\$/d" commit >actual &&
(
echo welcome &&
echo &&
echo $alt &&
git var GIT_COMMITTER_IDENT |
sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
git var GIT_COMMITTER_IDENT >ident &&
sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident
) >expected &&
test_cmp expected actual
'
@ -468,15 +470,16 @@ test_expect_success 'signoff gap 2' ' @@ -468,15 +470,16 @@ test_expect_success 'signoff gap 2' '

We have now
$alt" &&
git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
git cat-file commit HEAD >commit &&
sed -e "1,/^\$/d" commit >actual &&
(
echo welcome &&
echo &&
echo We have now &&
echo $alt &&
echo &&
git var GIT_COMMITTER_IDENT |
sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
git var GIT_COMMITTER_IDENT >ident &&
sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident
) >expected &&
test_cmp expected actual
'
@ -489,7 +492,8 @@ test_expect_success 'signoff respects trailer config' ' @@ -489,7 +492,8 @@ test_expect_success 'signoff respects trailer config' '

non-trailer line
Myfooter: x" &&
git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
git cat-file commit HEAD >commit &&
sed -e "1,/^\$/d" commit >actual &&
(
echo subject &&
echo &&
@ -506,7 +510,8 @@ Myfooter: x" && @@ -506,7 +510,8 @@ Myfooter: x" &&

non-trailer line
Myfooter: x" &&
git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
git cat-file commit HEAD >commit &&
sed -e "1,/^\$/d" commit >actual &&
(
echo subject &&
echo &&
@ -538,7 +543,8 @@ test_expect_success 'multiple -m' ' @@ -538,7 +543,8 @@ test_expect_success 'multiple -m' '
>negative &&
git add negative &&
git commit -m "one" -m "two" -m "three" &&
git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
git cat-file commit HEAD >commit &&
sed -e "1,/^\$/d" commit >actual &&
(
echo one &&
echo &&
@ -555,23 +561,25 @@ test_expect_success 'amend commit to fix author' ' @@ -555,23 +561,25 @@ test_expect_success 'amend commit to fix author' '
oldtick=$GIT_AUTHOR_DATE &&
test_tick &&
git reset --hard &&
git cat-file -p HEAD |
git cat-file -p HEAD >commit &&
sed -e "s/author.*/author $author $oldtick/" \
-e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" > \
expected &&
-e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" \
commit >expected &&
git commit --amend --author="$author" &&
git cat-file -p HEAD > current &&
git cat-file -p HEAD >current &&
test_cmp expected current

'

test_expect_success 'git commit <file> with dirty index' '
echo tacocat > elif &&
echo tehlulz > chz &&
echo tacocat >elif &&
echo tehlulz >chz &&
git add chz &&
git commit elif -m "tacocat is a palindrome" &&
git show --stat | grep elif &&
git diff --cached | grep chz
git show --stat >stat &&
grep elif stat &&
git diff --cached >diff &&
grep chz diff
'

test_expect_success 'same tree (single parent)' '
@ -584,7 +592,8 @@ test_expect_success 'same tree (single parent)' ' @@ -584,7 +592,8 @@ test_expect_success 'same tree (single parent)' '
test_expect_success 'same tree (single parent) --allow-empty' '

git commit --allow-empty -m "forced empty" &&
git cat-file commit HEAD | grep forced
git cat-file commit HEAD >commit &&
grep forced commit

'


172
t/t7700-repack.sh

@ -4,129 +4,104 @@ test_description='git repack works correctly' @@ -4,129 +4,104 @@ test_description='git repack works correctly'

. ./test-lib.sh

commit_and_pack() {
test_commit "$@" >/dev/null &&
SHA1=$(git pack-objects --all --unpacked --incremental .git/objects/pack/pack </dev/null) &&
echo pack-${SHA1}.pack
commit_and_pack () {
test_commit "$@" 1>&2 &&
incrpackid=$(git pack-objects --all --unpacked --incremental .git/objects/pack/pack </dev/null) &&
echo pack-${incrpackid}.pack
}

test_no_missing_in_packs () {
myidx=$(ls -1 .git/objects/pack/*.idx) &&
test_path_is_file "$myidx" &&
git verify-pack -v alt_objects/pack/*.idx >orig.raw &&
sed -n -e "s/^\($OID_REGEX\).*/\1/p" orig.raw | sort >orig &&
git verify-pack -v $myidx >dest.raw &&
cut -d" " -f1 dest.raw | sort >dest &&
comm -23 orig dest >missing &&
test_must_be_empty missing
}

# we expect $packid and $oid to be defined
test_has_duplicate_object () {
want_duplicate_object="$1"
found_duplicate_object=false
for p in .git/objects/pack/*.idx
do
idx=$(basename $p)
test "pack-$packid.idx" = "$idx" && continue
git verify-pack -v $p >packlist || return $?
if grep "^$oid" packlist
then
found_duplicate_object=true
echo "DUPLICATE OBJECT FOUND"
break
fi
done &&
test "$want_duplicate_object" = "$found_duplicate_object"
}

test_expect_success 'objects in packs marked .keep are not repacked' '
echo content1 > file1 &&
echo content2 > file2 &&
echo content1 >file1 &&
echo content2 >file2 &&
git add . &&
test_tick &&
git commit -m initial_commit &&
# Create two packs
# The first pack will contain all of the objects except one
git rev-list --objects --all | grep -v file2 |
git pack-objects pack > /dev/null &&
git rev-list --objects --all >objs &&
grep -v file2 objs | git pack-objects pack &&
# The second pack will contain the excluded object
packsha1=$(git rev-list --objects --all | grep file2 |
git pack-objects pack) &&
>pack-$packsha1.keep &&
objsha1=$(git verify-pack -v pack-$packsha1.idx | head -n 1 |
sed -e "s/^\([0-9a-f]\{40\}\).*/\1/") &&
packid=$(grep file2 objs | git pack-objects pack) &&
>pack-$packid.keep &&
git verify-pack -v pack-$packid.idx >packlist &&
oid=$(head -n 1 packlist | sed -e "s/^\($OID_REGEX\).*/\1/") &&
mv pack-* .git/objects/pack/ &&
git repack -A -d -l &&
git prune-packed &&
for p in .git/objects/pack/*.idx; do
idx=$(basename $p)
test "pack-$packsha1.idx" = "$idx" && continue
if git verify-pack -v $p | egrep "^$objsha1"; then
found_duplicate_object=1
echo "DUPLICATE OBJECT FOUND"
break
fi
done &&
test -z "$found_duplicate_object"
test_has_duplicate_object false
'

test_expect_success 'writing bitmaps via command-line can duplicate .keep objects' '
# build on $objsha1, $packsha1, and .keep state from previous
# build on $oid, $packid, and .keep state from previous
git repack -Adbl &&
test_when_finished "found_duplicate_object=" &&
for p in .git/objects/pack/*.idx; do
idx=$(basename $p)
test "pack-$packsha1.idx" = "$idx" && continue
if git verify-pack -v $p | egrep "^$objsha1"; then
found_duplicate_object=1
echo "DUPLICATE OBJECT FOUND"
break
fi
done &&
test "$found_duplicate_object" = 1
test_has_duplicate_object true
'

test_expect_success 'writing bitmaps via config can duplicate .keep objects' '
# build on $objsha1, $packsha1, and .keep state from previous
# build on $oid, $packid, and .keep state from previous
git -c repack.writebitmaps=true repack -Adl &&
test_when_finished "found_duplicate_object=" &&
for p in .git/objects/pack/*.idx; do
idx=$(basename $p)
test "pack-$packsha1.idx" = "$idx" && continue
if git verify-pack -v $p | egrep "^$objsha1"; then
found_duplicate_object=1
echo "DUPLICATE OBJECT FOUND"
break
fi
done &&
test "$found_duplicate_object" = 1
test_has_duplicate_object true
'

test_expect_success 'loose objects in alternate ODB are not repacked' '
mkdir alt_objects &&
echo $(pwd)/alt_objects > .git/objects/info/alternates &&
echo content3 > file3 &&
objsha1=$(GIT_OBJECT_DIRECTORY=alt_objects git hash-object -w file3) &&
echo $(pwd)/alt_objects >.git/objects/info/alternates &&
echo content3 >file3 &&
oid=$(GIT_OBJECT_DIRECTORY=alt_objects git hash-object -w file3) &&
git add file3 &&
test_tick &&
git commit -m commit_file3 &&
git repack -a -d -l &&
git prune-packed &&
for p in .git/objects/pack/*.idx; do
if git verify-pack -v $p | egrep "^$objsha1"; then
found_duplicate_object=1
echo "DUPLICATE OBJECT FOUND"
break
fi
done &&
test -z "$found_duplicate_object"
test_has_duplicate_object false
'

test_expect_success 'packed obs in alt ODB are repacked even when local repo is packless' '
mkdir alt_objects/pack &&
mv .git/objects/pack/* alt_objects/pack &&
git repack -a &&
myidx=$(ls -1 .git/objects/pack/*.idx) &&
test -f "$myidx" &&
for p in alt_objects/pack/*.idx; do
git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p"
done | while read sha1 rest; do
if ! ( git verify-pack -v $myidx | grep "^$sha1" ); then
echo "Missing object in local pack: $sha1"
return 1
fi
done
test_no_missing_in_packs
'

test_expect_success 'packed obs in alt ODB are repacked when local repo has packs' '
rm -f .git/objects/pack/* &&
echo new_content >> file1 &&
echo new_content >>file1 &&
git add file1 &&
test_tick &&
git commit -m more_content &&
git repack &&
git repack -a -d &&
myidx=$(ls -1 .git/objects/pack/*.idx) &&
test -f "$myidx" &&
for p in alt_objects/pack/*.idx; do
git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p"
done | while read sha1 rest; do
if ! ( git verify-pack -v $myidx | grep "^$sha1" ); then
echo "Missing object in local pack: $sha1"
return 1
fi
done
test_no_missing_in_packs
'

test_expect_success 'packed obs in alternate ODB kept pack are repacked' '
@ -134,7 +109,7 @@ test_expect_success 'packed obs in alternate ODB kept pack are repacked' ' @@ -134,7 +109,7 @@ test_expect_success 'packed obs in alternate ODB kept pack are repacked' '
for p in alt_objects/pack/*.pack
do
base_name=$(basename $p .pack) &&
if test -f alt_objects/pack/$base_name.keep
if test_path_is_file alt_objects/pack/$base_name.keep
then
rm alt_objects/pack/$base_name.keep
else
@ -142,22 +117,13 @@ test_expect_success 'packed obs in alternate ODB kept pack are repacked' ' @@ -142,22 +117,13 @@ test_expect_success 'packed obs in alternate ODB kept pack are repacked' '
fi
done &&
git repack -a -d &&
myidx=$(ls -1 .git/objects/pack/*.idx) &&
test -f "$myidx" &&
for p in alt_objects/pack/*.idx; do
git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p"
done | while read sha1 rest; do
if ! ( git verify-pack -v $myidx | grep "^$sha1" ); then
echo "Missing object in local pack: $sha1"
return 1
fi
done
test_no_missing_in_packs
'

test_expect_success 'packed unreachable obs in alternate ODB are not loosened' '
rm -f alt_objects/pack/*.keep &&
mv .git/objects/pack/* alt_objects/pack/ &&
csha1=$(git rev-parse HEAD^{commit}) &&
coid=$(git rev-parse HEAD^{commit}) &&
git reset --hard HEAD^ &&
test_tick &&
git reflog expire --expire=$test_tick --expire-unreachable=$test_tick --all &&
@ -167,15 +133,15 @@ test_expect_success 'packed unreachable obs in alternate ODB are not loosened' ' @@ -167,15 +133,15 @@ test_expect_success 'packed unreachable obs in alternate ODB are not loosened' '
--unpack-unreachable </dev/null pack &&
rm -f .git/objects/pack/* &&
mv pack-* .git/objects/pack/ &&
test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx |
egrep "^$csha1 " | sort | uniq | wc -l) &&
echo > .git/objects/info/alternates &&
test_must_fail git show $csha1
git verify-pack -v -- .git/objects/pack/*.idx >packlist &&
! grep "^$coid " packlist &&
echo >.git/objects/info/alternates &&
test_must_fail git show $coid
'

test_expect_success 'local packed unreachable obs that exist in alternate ODB are not loosened' '
echo $(pwd)/alt_objects > .git/objects/info/alternates &&
echo "$csha1" | git pack-objects --non-empty --all --reflog pack &&
echo $(pwd)/alt_objects >.git/objects/info/alternates &&
echo "$coid" | git pack-objects --non-empty --all --reflog pack &&
rm -f .git/objects/pack/* &&
mv pack-* .git/objects/pack/ &&
# The pack-objects call on the next line is equivalent to
@ -184,10 +150,10 @@ test_expect_success 'local packed unreachable obs that exist in alternate ODB ar @@ -184,10 +150,10 @@ test_expect_success 'local packed unreachable obs that exist in alternate ODB ar
--unpack-unreachable </dev/null pack &&
rm -f .git/objects/pack/* &&
mv pack-* .git/objects/pack/ &&
test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx |
egrep "^$csha1 " | sort | uniq | wc -l) &&
echo > .git/objects/info/alternates &&
test_must_fail git show $csha1
git verify-pack -v -- .git/objects/pack/*.idx >packlist &&
! grep "^$coid " &&
echo >.git/objects/info/alternates &&
test_must_fail git show $coid
'

test_expect_success 'objects made unreachable by grafts only are kept' '
@ -196,7 +162,7 @@ test_expect_success 'objects made unreachable by grafts only are kept' ' @@ -196,7 +162,7 @@ test_expect_success 'objects made unreachable by grafts only are kept' '
H0=$(git rev-parse HEAD) &&
H1=$(git rev-parse HEAD^) &&
H2=$(git rev-parse HEAD^^) &&
echo "$H0 $H2" > .git/info/grafts &&
echo "$H0 $H2" >.git/info/grafts &&
git reflog expire --expire=$test_tick --expire-unreachable=$test_tick --all &&
git repack -a -d &&
git cat-file -t $H1
@ -235,7 +201,7 @@ test_expect_success 'incremental repack does not complain' ' @@ -235,7 +201,7 @@ test_expect_success 'incremental repack does not complain' '

test_expect_success 'bitmaps can be disabled on bare repos' '
git -c repack.writeBitmaps=false -C bare.git repack -ad &&
bitmap=$(ls bare.git/objects/pack/*.bitmap 2>/dev/null || :) &&
bitmap=$(ls bare.git/objects/pack/*.bitmap || :) &&
test -z "$bitmap"
'


Loading…
Cancel
Save