diff options
Diffstat (limited to 't')
27 files changed, 649 insertions, 298 deletions
diff --git a/t/helper/meson.build b/t/helper/meson.build index d4e8b26df8..675e64c010 100644 --- a/t/helper/meson.build +++ b/t/helper/meson.build @@ -77,6 +77,7 @@ test_tool_sources = [ 'test-windows-named-pipe.c', 'test-write-cache.c', 'test-xml-encode.c', + 'test-zlib.c', ] test_tool = executable('test-tool', diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c index 74812ed86d..a7abc618b3 100644 --- a/t/helper/test-tool.c +++ b/t/helper/test-tool.c @@ -91,6 +91,7 @@ static struct test_cmd cmds[] = { { "windows-named-pipe", cmd__windows_named_pipe }, #endif { "write-cache", cmd__write_cache }, + { "zlib", cmd__zlib }, }; static NORETURN void die_usage(void) diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h index 2571a3ccfe..7f150fa1eb 100644 --- a/t/helper/test-tool.h +++ b/t/helper/test-tool.h @@ -84,6 +84,7 @@ int cmd__wildmatch(int argc, const char **argv); int cmd__windows_named_pipe(int argc, const char **argv); #endif int cmd__write_cache(int argc, const char **argv); +int cmd__zlib(int argc, const char **argv); int cmd_hash_impl(int ac, const char **av, int algo, int unsafe); diff --git a/t/helper/test-zlib.c b/t/helper/test-zlib.c new file mode 100644 index 0000000000..de7e9edee1 --- /dev/null +++ b/t/helper/test-zlib.c @@ -0,0 +1,62 @@ +#include "test-tool.h" +#include "git-zlib.h" +#include "strbuf.h" + +static const char *zlib_usage = "test-tool zlib [inflate|deflate]"; + +static void do_zlib(struct git_zstream *stream, + int (*zlib_func)(git_zstream *, int), + int fd_in, int fd_out) +{ + struct strbuf buf_in = STRBUF_INIT; + int status = Z_OK; + + if (strbuf_read(&buf_in, fd_in, 0) < 0) + die_errno("read error"); + + stream->next_in = (unsigned char *)buf_in.buf; + stream->avail_in = buf_in.len; + + while (status == Z_OK || + (status == Z_BUF_ERROR && !stream->avail_out)) { + unsigned char buf_out[4096]; + + stream->next_out = buf_out; + stream->avail_out = sizeof(buf_out); + + status = zlib_func(stream, Z_FINISH); + if (write_in_full(fd_out, buf_out, + sizeof(buf_out) - stream->avail_out) < 0) + die_errno("write error"); + } + + if (status != Z_STREAM_END) + die("zlib error %d", status); + + strbuf_release(&buf_in); +} + +int cmd__zlib(int argc, const char **argv) +{ + git_zstream stream; + + if (argc != 2) + usage(zlib_usage); + + memset(&stream, 0, sizeof(stream)); + + if (!strcmp(argv[1], "inflate")) { + git_inflate_init(&stream); + do_zlib(&stream, git_inflate, 0, 1); + git_inflate_end(&stream); + } else if (!strcmp(argv[1], "deflate")) { + git_deflate_init(&stream, Z_DEFAULT_COMPRESSION); + do_zlib(&stream, git_deflate, 0, 1); + git_deflate_end(&stream); + } else { + error("unknown mode: %s", argv[1]); + usage(zlib_usage); + } + + return 0; +} diff --git a/t/lib-loose.sh b/t/lib-loose.sh new file mode 100644 index 0000000000..3613631eaf --- /dev/null +++ b/t/lib-loose.sh @@ -0,0 +1,30 @@ +# Support routines for hand-crafting loose objects. + +# Write a loose object into the odb at $1, with object type $2 and contents +# from stdin. Writes the oid to stdout. Example: +# +# oid=$(echo foo | loose_obj .git/objects blob) +# +loose_obj () { + cat >tmp_loose.content && + size=$(wc -c <tmp_loose.content) && + { + # Do not quote $size here; we want the shell + # to strip whitespace that "wc" adds on some platforms. + printf "%s %s\0" "$2" $size && + cat tmp_loose.content + } >tmp_loose.raw && + + oid=$(test-tool $test_hash_algo <tmp_loose.raw) && + suffix=${oid#??} && + prefix=${oid%$suffix} && + dir=$1/$prefix && + file=$dir/$suffix && + + test-tool zlib deflate <tmp_loose.raw >tmp_loose.zlib && + mkdir -p "$dir" && + mv tmp_loose.zlib "$file" && + + rm tmp_loose.raw tmp_loose.content && + echo "$oid" +} diff --git a/t/perf/p2000-sparse-operations.sh b/t/perf/p2000-sparse-operations.sh index 39e92b0841..aadf22bc2f 100755 --- a/t/perf/p2000-sparse-operations.sh +++ b/t/perf/p2000-sparse-operations.sh @@ -135,5 +135,8 @@ test_perf_on_all git diff-tree HEAD test_perf_on_all git diff-tree HEAD -- $SPARSE_CONE/a test_perf_on_all "git worktree add ../temp && git worktree remove ../temp" test_perf_on_all git check-attr -a -- $SPARSE_CONE/a +test_perf_on_all 'echo >>a && test_write_lines y | git add -p' +test_perf_on_all 'test_write_lines y y y | git checkout --patch -' +test_perf_on_all 'echo >>a && git add a && test_write_lines y | git reset --patch' test_done diff --git a/t/t0602-reffiles-fsck.sh b/t/t0602-reffiles-fsck.sh index 9d1dc2144c..f671ac4d3a 100755 --- a/t/t0602-reffiles-fsck.sh +++ b/t/t0602-reffiles-fsck.sh @@ -647,6 +647,23 @@ test_expect_success SYMLINKS 'the filetype of packed-refs should be checked' ' ) ' +test_expect_success 'empty packed-refs should be reported' ' + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + test_commit default && + + >.git/packed-refs && + git refs verify 2>err && + cat >expect <<-EOF && + warning: packed-refs: emptyPackedRefsFile: file is empty + EOF + rm .git/packed-refs && + test_cmp expect err + ) +' + test_expect_success 'packed-refs header should be checked' ' test_when_finished "rm -rf repo" && git init repo && diff --git a/t/t1001-read-tree-m-2way.sh b/t/t1001-read-tree-m-2way.sh index 4a88bb9ef0..2e8d9384e1 100755 --- a/t/t1001-read-tree-m-2way.sh +++ b/t/t1001-read-tree-m-2way.sh @@ -362,7 +362,7 @@ test_expect_success 'a/b (untracked) vs a case setup.' ' test_expect_success 'a/b (untracked) vs a, plus c/d case test.' ' read_tree_u_must_fail -u -m "$treeH" "$treeM" && git ls-files --stage && - test -f a/b + test_path_is_file a/b ' test_expect_success 'read-tree supports the super-prefix' ' diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh index ce8b27bf54..317da6869c 100755 --- a/t/t1006-cat-file.sh +++ b/t/t1006-cat-file.sh @@ -3,6 +3,7 @@ test_description='git cat-file' . ./test-lib.sh +. "$TEST_DIRECTORY/lib-loose.sh" test_cmdmode_usage () { test_expect_code 129 "$@" 2>err && @@ -136,18 +137,6 @@ $content" test_cmp expect actual ' - test_expect_success "Type of $type is correct using --allow-unknown-type" ' - echo $type >expect && - git cat-file -t --allow-unknown-type $oid >actual && - test_cmp expect actual - ' - - test_expect_success "Size of $type is correct using --allow-unknown-type" ' - echo $size >expect && - git cat-file -s --allow-unknown-type $oid >actual && - test_cmp expect actual - ' - test -z "$content" || test_expect_success "Content of $type is correct" ' echo_without_newline "$content" >expect && @@ -669,103 +658,75 @@ test_expect_success 'setup bogus data' ' bogus_short_type="bogus" && bogus_short_content="bogus" && bogus_short_size=$(strlen "$bogus_short_content") && - bogus_short_oid=$(echo_without_newline "$bogus_short_content" | git hash-object -t $bogus_short_type --literally -w --stdin) && + bogus_short_oid=$(echo_without_newline "$bogus_short_content" | loose_obj .git/objects $bogus_short_type) && bogus_long_type="abcdefghijklmnopqrstuvwxyz1234679" && bogus_long_content="bogus" && bogus_long_size=$(strlen "$bogus_long_content") && - bogus_long_oid=$(echo_without_newline "$bogus_long_content" | git hash-object -t $bogus_long_type --literally -w --stdin) + bogus_long_oid=$(echo_without_newline "$bogus_long_content" | loose_obj .git/objects $bogus_long_type) ' -for arg1 in '' --allow-unknown-type +for arg1 in -s -t -p do - for arg2 in -s -t -p - do - if test "$arg1" = "--allow-unknown-type" && test "$arg2" = "-p" - then - continue - fi + test_expect_success "cat-file $arg1 error on bogus short OID" ' + cat >expect <<-\EOF && + fatal: invalid object type + EOF + test_must_fail git cat-file $arg1 $bogus_short_oid >out 2>actual && + test_must_be_empty out && + test_cmp expect actual + ' - test_expect_success "cat-file $arg1 $arg2 error on bogus short OID" ' - cat >expect <<-\EOF && - fatal: invalid object type + test_expect_success "cat-file $arg1 error on bogus full OID" ' + if test "$arg1" = "-p" + then + cat >expect <<-EOF + error: header for $bogus_long_oid too long, exceeds 32 bytes + fatal: Not a valid object name $bogus_long_oid + EOF + else + cat >expect <<-EOF + error: header for $bogus_long_oid too long, exceeds 32 bytes + fatal: git cat-file: could not get object info EOF + fi && - if test "$arg1" = "--allow-unknown-type" - then - git cat-file $arg1 $arg2 $bogus_short_oid - else - test_must_fail git cat-file $arg1 $arg2 $bogus_short_oid >out 2>actual && - test_must_be_empty out && - test_cmp expect actual - fi - ' + test_must_fail git cat-file $arg1 $bogus_long_oid >out 2>actual && + test_must_be_empty out && + test_cmp expect actual + ' - test_expect_success "cat-file $arg1 $arg2 error on bogus full OID" ' - if test "$arg2" = "-p" - then - cat >expect <<-EOF - error: header for $bogus_long_oid too long, exceeds 32 bytes - fatal: Not a valid object name $bogus_long_oid - EOF - else - cat >expect <<-EOF - error: header for $bogus_long_oid too long, exceeds 32 bytes - fatal: git cat-file: could not get object info - EOF - fi && - - if test "$arg1" = "--allow-unknown-type" - then - git cat-file $arg1 $arg2 $bogus_short_oid - else - test_must_fail git cat-file $arg1 $arg2 $bogus_long_oid >out 2>actual && - test_must_be_empty out && - test_cmp expect actual - fi - ' + test_expect_success "cat-file $arg1 error on missing short OID" ' + cat >expect.err <<-EOF && + fatal: Not a valid object name $(test_oid deadbeef_short) + EOF + test_must_fail git cat-file $arg1 $(test_oid deadbeef_short) >out 2>err.actual && + test_must_be_empty out && + test_cmp expect.err err.actual + ' - test_expect_success "cat-file $arg1 $arg2 error on missing short OID" ' - cat >expect.err <<-EOF && - fatal: Not a valid object name $(test_oid deadbeef_short) + test_expect_success "cat-file $arg1 error on missing full OID" ' + if test "$arg1" = "-p" + then + cat >expect.err <<-EOF + fatal: Not a valid object name $(test_oid deadbeef) EOF - test_must_fail git cat-file $arg1 $arg2 $(test_oid deadbeef_short) >out 2>err.actual && - test_must_be_empty out && - test_cmp expect.err err.actual - ' - - test_expect_success "cat-file $arg1 $arg2 error on missing full OID" ' - if test "$arg2" = "-p" - then - cat >expect.err <<-EOF - fatal: Not a valid object name $(test_oid deadbeef) - EOF - else - cat >expect.err <<-\EOF - fatal: git cat-file: could not get object info - EOF - fi && - test_must_fail git cat-file $arg1 $arg2 $(test_oid deadbeef) >out 2>err.actual && - test_must_be_empty out && - test_cmp expect.err err.actual - ' - done + else + cat >expect.err <<-\EOF + fatal: git cat-file: could not get object info + EOF + fi && + test_must_fail git cat-file $arg1 $(test_oid deadbeef) >out 2>err.actual && + test_must_be_empty out && + test_cmp expect.err err.actual + ' done -test_expect_success '-e is OK with a broken object without --allow-unknown-type' ' +test_expect_success '-e is OK with a broken object' ' git cat-file -e $bogus_short_oid ' -test_expect_success '-e can not be combined with --allow-unknown-type' ' - test_expect_code 128 git cat-file -e --allow-unknown-type $bogus_short_oid -' - -test_expect_success '-p cannot print a broken object even with --allow-unknown-type' ' - test_must_fail git cat-file -p $bogus_short_oid && - test_expect_code 128 git cat-file -p --allow-unknown-type $bogus_short_oid -' - test_expect_success '<type> <hash> does not work with objects of broken types' ' cat >err.expect <<-\EOF && fatal: invalid object type "bogus" @@ -788,60 +749,8 @@ test_expect_success 'broken types combined with --batch and --batch-check' ' test_cmp err.expect err.actual ' -test_expect_success 'the --batch and --batch-check options do not combine with --allow-unknown-type' ' - test_expect_code 128 git cat-file --batch --allow-unknown-type <bogus-oid && - test_expect_code 128 git cat-file --batch-check --allow-unknown-type <bogus-oid -' - -test_expect_success 'the --allow-unknown-type option does not consider replacement refs' ' - cat >expect <<-EOF && - $bogus_short_type - EOF - git cat-file -t --allow-unknown-type $bogus_short_oid >actual && - test_cmp expect actual && - - # Create it manually, as "git replace" will die on bogus - # types. - head=$(git rev-parse --verify HEAD) && - test_when_finished "test-tool ref-store main delete-refs 0 msg refs/replace/$bogus_short_oid" && - test-tool ref-store main update-ref msg "refs/replace/$bogus_short_oid" $head $ZERO_OID REF_SKIP_OID_VERIFICATION && - - cat >expect <<-EOF && - commit - EOF - git cat-file -t --allow-unknown-type $bogus_short_oid >actual && - test_cmp expect actual -' - -test_expect_success "Type of broken object is correct" ' - echo $bogus_short_type >expect && - git cat-file -t --allow-unknown-type $bogus_short_oid >actual && - test_cmp expect actual -' - -test_expect_success "Size of broken object is correct" ' - echo $bogus_short_size >expect && - git cat-file -s --allow-unknown-type $bogus_short_oid >actual && - test_cmp expect actual -' - -test_expect_success 'clean up broken object' ' - rm .git/objects/$(test_oid_to_path $bogus_short_oid) -' - -test_expect_success "Type of broken object is correct when type is large" ' - echo $bogus_long_type >expect && - git cat-file -t --allow-unknown-type $bogus_long_oid >actual && - test_cmp expect actual -' - -test_expect_success "Size of large broken object is correct when type is large" ' - echo $bogus_long_size >expect && - git cat-file -s --allow-unknown-type $bogus_long_oid >actual && - test_cmp expect actual -' - -test_expect_success 'clean up broken object' ' +test_expect_success 'clean up broken objects' ' + rm .git/objects/$(test_oid_to_path $bogus_short_oid) && rm .git/objects/$(test_oid_to_path $bogus_long_oid) ' @@ -903,25 +812,6 @@ test_expect_success 'cat-file -t and -s on corrupt loose object' ' ) ' -test_expect_success 'truncated object with --allow-unknown-type' - <<\EOT - objtype='a really long type name that exceeds the 32-byte limit' && - blob=$(git hash-object -w --literally -t "$objtype" /dev/null) && - objpath=.git/objects/$(test_oid_to_path "$blob") && - - # We want to truncate the object far enough in that we don't hit the - # end while inflating the first 32 bytes (since we want to have to dig - # for the trailing NUL of the header). But we don't want to go too far, - # since our header isn't very big. And of course we are counting - # deflated zlib bytes in the on-disk file, so it's a bit of a guess. - # Empirically 50 seems to work. - mv "$objpath" obj.bak && - test_when_finished 'mv obj.bak "$objpath"' && - test_copy_bytes 50 <obj.bak >"$objpath" && - - test_must_fail git cat-file --allow-unknown-type -t $blob 2>err && - test_grep "unable to unpack $blob header" err -EOT - test_expect_success 'object reading handles zlib dictionary' - <<\EOT echo 'content that will be recompressed' >file && blob=$(git hash-object -w file) && diff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh index b3cf53ff8c..dbbe9fb0d4 100755 --- a/t/t1007-hash-object.sh +++ b/t/t1007-hash-object.sh @@ -248,15 +248,8 @@ test_expect_success 'hash-object complains about truncated type name' ' test_must_fail git hash-object -t bl --stdin </dev/null ' -test_expect_success '--literally' ' - t=1234567890 && - echo example | git hash-object -t $t --literally --stdin -' - -test_expect_success '--literally with extra-long type' ' - t=12345678901234567890123456789012345678901234567890 && - t="$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t" && - echo example | git hash-object -t $t --literally --stdin +test_expect_success '--literally complains about non-standard types' ' + test_must_fail git hash-object -t bogus --literally --stdin ' test_expect_success '--stdin outside of repository (uses SHA-1)' ' diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh index f9b448792c..d8101139b4 100755 --- a/t/t1092-sparse-checkout-compatibility.sh +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -384,6 +384,44 @@ test_expect_success 'add, commit, checkout' ' test_all_match git checkout - ' +test_expect_success 'git add, checkout, and reset with -p' ' + init_repos && + + write_script edit-contents <<-\EOF && + echo text >>$1 + EOF + + # Does not expand when edits are within sparse checkout. + run_on_all ../edit-contents deep/a && + run_on_all ../edit-contents deep/deeper1/a && + + test_write_lines y n >in && + run_on_all git add -p <in && + test_all_match git status --porcelain=v2 && + test_all_match git reset -p <in && + + test_write_lines u 1 "" q >in && + run_on_all git add -i <in && + test_all_match git status --porcelain=v2 && + test_all_match git reset --hard && + + run_on_sparse mkdir -p folder1 && + run_on_all ../edit-contents folder1/a && + test_write_lines y n y >in && + run_on_all git add -p <in && + test_sparse_match git status --porcelain=v2 && + test_sparse_match git reset && + test_write_lines u 2 3 "" q >in && + run_on_all git add -i <in && + test_sparse_match git status --porcelain=v2 && + + run_on_all git add --sparse folder1 && + run_on_all git commit -m "take changes" && + test_write_lines y n y >in && + test_sparse_match git checkout HEAD~1 --patch <in && + test_sparse_match git status --porcelain=v2 +' + test_expect_success 'deep changes during checkout' ' init_repos && @@ -1340,6 +1378,30 @@ test_expect_success 'submodule handling' ' grep "160000 $(git -C initial-repo rev-parse HEAD) 0 modules/sub" cache ' +test_expect_success 'git apply functionality' ' + init_repos && + + test_all_match git checkout base && + + git -C full-checkout diff base..merge-right -- deep >patch-in-sparse && + git -C full-checkout diff base..merge-right -- folder2 >patch-outside && + + # Apply a patch to a file inside the sparse definition + test_all_match git apply --index --stat ../patch-in-sparse && + test_all_match git status --porcelain=v2 && + + # Apply a patch to a file outside the sparse definition + test_sparse_match test_must_fail git apply ../patch-outside && + grep "No such file or directory" sparse-checkout-err && + + # But it works with --index and --cached + test_all_match git apply --index --stat ../patch-outside && + test_all_match git status --porcelain=v2 && + test_all_match git reset --hard && + test_all_match git apply --cached --stat ../patch-outside && + test_all_match git status --porcelain=v2 +' + # When working with a sparse index, some commands will need to expand the # index to operate properly. If those commands also write the index back # to disk, they need to convert the index to sparse before writing. @@ -2345,6 +2407,95 @@ test_expect_success 'sparse-index is not expanded: check-attr' ' ensure_not_expanded check-attr -a --cached -- folder1/a ' +test_expect_success 'sparse-index is not expanded: git apply' ' + init_repos && + + git -C sparse-index checkout base && + git -C full-checkout diff base..merge-right -- deep >patch-in-sparse && + git -C full-checkout diff base..merge-right -- folder2 >patch-outside && + + # Apply a patch to a file inside the sparse definition + ensure_not_expanded apply --index --stat ../patch-in-sparse && + + # Apply a patch to a file outside the sparse definition + # Fails when caring about the worktree. + ensure_not_expanded ! apply ../patch-outside && + + # Expands when using --index. + ensure_expanded apply --index ../patch-outside && + + # Does not when index is partially expanded. + git -C sparse-index reset --hard && + ensure_not_expanded apply --cached ../patch-outside && + + # Try again with a reset and collapsed index. + git -C sparse-index reset --hard && + git -C sparse-index sparse-checkout reapply && + + # Expands when index is collapsed. + ensure_expanded apply --cached ../patch-outside +' + +test_expect_success 'sparse-index is not expanded: git add -p' ' + init_repos && + + # Does not expand when edits are within sparse checkout. + echo "new content" >sparse-index/deep/a && + echo "new content" >sparse-index/deep/deeper1/a && + test_write_lines y n >in && + ensure_not_expanded add -p <in && + git -C sparse-index reset && + ensure_not_expanded add -i <in && + + # -p does expand when edits are outside sparse checkout. + mkdir -p sparse-index/folder1 && + echo "new content" >sparse-index/folder1/a && + test_write_lines y n y >in && + ensure_expanded add -p <in && + + # Fully reset the index. + git -C sparse-index reset --hard && + git -C sparse-index sparse-checkout reapply && + + # -i does expand when edits are outside sparse checkout. + mkdir -p sparse-index/folder1 && + echo "new content" >sparse-index/folder1/a && + test_write_lines u 2 3 "" q >in && + ensure_expanded add -i <in +' + +test_expect_success 'sparse-index is not expanded: checkout -p, reset -p' ' + init_repos && + + # Does not expand when edits are within sparse checkout. + echo "new content" >sparse-index/deep/a && + echo "new content" >sparse-index/deep/deeper1/a && + git -C sparse-index commit -a -m "inside-changes" && + + test_write_lines y y >in && + ensure_not_expanded checkout HEAD~1 --patch <in && + + echo "new content" >sparse-index/deep/a && + echo "new content" >sparse-index/deep/deeper1/a && + git -C sparse-index add . && + ensure_not_expanded reset --patch <in && + + # -p does expand when edits are outside sparse checkout. + mkdir -p sparse-index/folder1 && + echo "new content" >sparse-index/folder1/a && + git -C sparse-index add --sparse folder1 && + git -C sparse-index sparse-checkout reapply && + ensure_expanded reset --patch <in && + + # Fully reset the index. + mkdir -p sparse-index/folder1 && + echo "new content" >sparse-index/folder1/a && + git -C sparse-index add --sparse folder1 && + git -C sparse-index commit -m "folder1 change" && + git -C sparse-index sparse-checkout reapply && + ensure_expanded checkout HEAD~1 --patch <in +' + test_expect_success 'advice.sparseIndexExpanded' ' init_repos && diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index 0105045376..5ae86c42be 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -7,6 +7,7 @@ test_description='git fsck random collection of tests ' . ./test-lib.sh +. "$TEST_DIRECTORY/lib-loose.sh" test_expect_success setup ' git config gc.auto 0 && @@ -71,30 +72,6 @@ test_expect_success 'object with hash mismatch' ' ) ' -test_expect_success 'object with hash and type mismatch' ' - git init --bare hash-type-mismatch && - ( - cd hash-type-mismatch && - - oid=$(echo blob | git hash-object -w --stdin -t garbage --literally) && - oldoid=$oid && - old=$(test_oid_to_path "$oid") && - new=$(dirname $old)/$(test_oid ff_2) && - oid="$(dirname $new)$(basename $new)" && - - mv objects/$old objects/$new && - git update-index --add --cacheinfo 100644 $oid foo && - tree=$(git write-tree) && - cmt=$(echo bogus | git commit-tree $tree) && - git update-ref refs/heads/bogus $cmt && - - - test_must_fail git fsck 2>out && - grep "^error: $oldoid: hash-path mismatch, found at: .*$new" out && - grep "^error: $oldoid: object is of unknown type '"'"'garbage'"'"'" out - ) -' - test_expect_success 'zlib corrupt loose object output ' ' git init --bare corrupt-loose-output && ( @@ -997,12 +974,13 @@ test_expect_success 'fsck error and recovery on invalid object type' ' ( cd garbage-type && - garbage_blob=$(git hash-object --stdin -w -t garbage --literally </dev/null) && + garbage_blob=$(loose_obj objects garbage </dev/null) && test_must_fail git fsck 2>err && grep -e "^error" -e "^fatal" err >errors && - test_line_count = 1 errors && - grep "$garbage_blob: object is of unknown type '"'"'garbage'"'"':" err + test_line_count = 2 errors && + test_grep "unable to parse type from header .garbage" err && + test_grep "$garbage_blob: object corrupt or missing:" err ) ' diff --git a/t/t1512-rev-parse-disambiguation.sh b/t/t1512-rev-parse-disambiguation.sh index 70f1e0a998..1a380a4184 100755 --- a/t/t1512-rev-parse-disambiguation.sh +++ b/t/t1512-rev-parse-disambiguation.sh @@ -24,6 +24,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME . ./test-lib.sh +. "$TEST_DIRECTORY/lib-loose.sh" test_cmp_failed_rev_parse () { dir=$1 @@ -67,8 +68,8 @@ test_expect_success 'ambiguous loose bad object parsed as OBJ_BAD' ' cd blob.bad && # Both have the prefix "bad0" - echo xyzfaowcoh | git hash-object -t bad -w --stdin --literally && - echo xyzhjpyvwl | git hash-object -t bad -w --stdin --literally + echo xyzfaowcoh | loose_obj objects bad && + echo xyzhjpyvwl | loose_obj objects bad ) && test_cmp_failed_rev_parse blob.bad bad0 <<-\EOF diff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh index 5f8fa05420..cc627e34a7 100755 --- a/t/t3430-rebase-merges.sh +++ b/t/t3430-rebase-merges.sh @@ -86,7 +86,7 @@ test_expect_success 'create completely different structure' ' test_config sequence.editor \""$PWD"/replace-editor.sh\" && test_tick && git rebase -i -r A main && - test_cmp_graph <<-\EOF + test_cmp_graph <<-\EOF && * Merge the topic branch '\''onebranch'\'' |\ | * D @@ -99,6 +99,15 @@ test_expect_success 'create completely different structure' ' |/ * A EOF + + head="$(git show-ref --verify -s --abbrev HEAD)" && + cat >expect <<-EOF && + $head HEAD@{0}: rebase (finish): returning to refs/heads/main + $head HEAD@{1}: rebase (merge): Merge the topic branch ${SQ}onebranch${SQ} + EOF + + git reflog -n2 HEAD >actual && + test_cmp expect actual ' test_expect_success 'generate correct todo list' ' diff --git a/t/t4018/bash-bashism-style-complete-line-capture b/t/t4018/bash-bashism-style-complete-line-capture new file mode 100644 index 0000000000..070b979fa6 --- /dev/null +++ b/t/t4018/bash-bashism-style-complete-line-capture @@ -0,0 +1,4 @@ +function myfunc # RIGHT +{ + echo 'ChangeMe' +} diff --git a/t/t4018/bash-posix-style-complete-line-capture b/t/t4018/bash-posix-style-complete-line-capture new file mode 100644 index 0000000000..b56942f322 --- /dev/null +++ b/t/t4018/bash-posix-style-complete-line-capture @@ -0,0 +1,4 @@ +func() { # RIGHT + + ChangeMe +} diff --git a/t/t4018/bash-posix-style-single-command-function b/t/t4018/bash-posix-style-single-command-function new file mode 100644 index 0000000000..398ae1c5d2 --- /dev/null +++ b/t/t4018/bash-posix-style-single-command-function @@ -0,0 +1,3 @@ +RIGHT() echo "hello" + + ChangeMe diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh index f51d3557f1..0be647c2fb 100755 --- a/t/t4034-diff-words.sh +++ b/t/t4034-diff-words.sh @@ -320,6 +320,7 @@ test_expect_success 'unset default driver' ' test_language_driver ada test_language_driver bibtex +test_language_driver bash test_language_driver cpp test_language_driver csharp test_language_driver css diff --git a/t/t4034/bash/expect b/t/t4034/bash/expect new file mode 100644 index 0000000000..1864ab25dc --- /dev/null +++ b/t/t4034/bash/expect @@ -0,0 +1,36 @@ +<BOLD>diff --git a/pre b/post<RESET> +<BOLD>index 09ac008..60ba6a2 100644<RESET> +<BOLD>--- a/pre<RESET> +<BOLD>+++ b/post<RESET> +<CYAN>@@ -1,31 +1,31 @@<RESET> +<RED>my_var<RESET><GREEN>new_var<RESET>=10 +x=<RED>123<RESET><GREEN>456<RESET> +echo <RED>$1<RESET><GREEN>$2<RESET> +echo <RED>$USER<RESET><GREEN>$USERNAME<RESET> +${<RED>HOME<RESET><GREEN>HOMEDIR<RESET>} +((a<RED>+<RESET><GREEN>+=<RESET>b)) +((a<RED>*<RESET><GREEN>*=<RESET>b)) +((a<RED>/<RESET><GREEN>/=<RESET>b)) +((a<RED>%<RESET><GREEN>%=<RESET>b)) +((a<RED>|<RESET><GREEN>|=<RESET>b)) +((a<RED>^<RESET><GREEN>^=<RESET>b)) +((a<RED>=<RESET><GREEN>==<RESET>b)) +((a<RED>!<RESET><GREEN>!=<RESET>b)) +((a<RED><<RESET><GREEN><=<RESET>b)) +((a<RED>><RESET><GREEN>>=<RESET>b)) +$((a<RED><<RESET><GREEN><<<RESET>b)) +$((a<RED>><RESET><GREEN>>><RESET>b)) +$((a<RED>&<RESET><GREEN>&&<RESET>b)) +$((a<RED>|<RESET><GREEN>||<RESET>b)) +${a<RED>:<RESET><GREEN>:-<RESET>b} +${a<RED>:<RESET><GREEN>:=<RESET>b} +${a<RED>:<RESET><GREEN>:+<RESET>b} +${a<RED>:<RESET><GREEN>:?<RESET>b} +${a<RED>#<RESET><GREEN>##<RESET>*/} +${a<RED>%<RESET><GREEN>%%<RESET>.*} +${a<RED>^<RESET><GREEN>^^<RESET>} +${a<RED>,<RESET><GREEN>,,<RESET>} +${<GREEN>!<RESET>a} +${a[<RED>*<RESET><GREEN>@<RESET>]} +ls <RED>-a<RESET><GREEN>-x<RESET> +ls <RED>--all<RESET><GREEN>--color<RESET> diff --git a/t/t4034/bash/post b/t/t4034/bash/post new file mode 100644 index 0000000000..2bbee8936d --- /dev/null +++ b/t/t4034/bash/post @@ -0,0 +1,31 @@ +new_var=10 +x=456 +echo $2 +echo $USERNAME +${HOMEDIR} +((a+=b)) +((a*=b)) +((a/=b)) +((a%=b)) +((a|=b)) +((a^=b)) +((a==b)) +((a!=b)) +((a<=b)) +((a>=b)) +$((a<<b)) +$((a>>b)) +$((a&&b)) +$((a||b)) +${a:-b} +${a:=b} +${a:+b} +${a:?b} +${a##*/} +${a%%.*} +${a^^} +${a,,} +${!a} +${a[@]} +ls -x +ls --color diff --git a/t/t4034/bash/pre b/t/t4034/bash/pre new file mode 100644 index 0000000000..8d22039c40 --- /dev/null +++ b/t/t4034/bash/pre @@ -0,0 +1,31 @@ +my_var=10 +x=123 +echo $1 +echo $USER +${HOME} +((a+b)) +((a*b)) +((a/b)) +((a%b)) +((a|b)) +((a^b)) +((a=b)) +((a!b)) +((a<b)) +((a>b)) +$((a<b)) +$((a>b)) +$((a&b)) +$((a|b)) +${a:b} +${a:b} +${a:b} +${a:b} +${a#*/} +${a%.*} +${a^} +${a,} +${a} +${a[*]} +ls -a +ls --all diff --git a/t/t4301-merge-tree-write-tree.sh b/t/t4301-merge-tree-write-tree.sh index f9c5883a7f..6e117ee93c 100755 --- a/t/t4301-merge-tree-write-tree.sh +++ b/t/t4301-merge-tree-write-tree.sh @@ -54,6 +54,25 @@ test_expect_success setup ' git commit -m first-commit ' +test_expect_success '--quiet on clean merge' ' + # Get rid of loose objects to start with + git gc && + echo "0 objects, 0 kilobytes" >expect && + git count-objects >actual && + test_cmp expect actual && + + # Ensure merge is successful (exit code of 0) + git merge-tree --write-tree --quiet side1 side3 >output && + + # Ensure there is no output + test_must_be_empty output && + + # Ensure no loose objects written (all new objects written would have + # been in "outer layer" of the merge) + git count-objects >actual && + test_cmp expect actual +' + test_expect_success 'Clean merge' ' TREE_OID=$(git merge-tree --write-tree side1 side3) && q_to_tab <<-EOF >expect && @@ -72,6 +91,25 @@ test_expect_success 'Failed merge without rename detection' ' grep "CONFLICT (modify/delete): numbers deleted" out ' +test_expect_success '--quiet on conflicted merge' ' + # Get rid of loose objects to start with + git gc && + echo "0 objects, 0 kilobytes" >expect && + git count-objects >actual && + test_cmp expect actual && + + # Ensure merge has conflict + test_expect_code 1 git merge-tree --write-tree --quiet side1 side2 >output && + + # Ensure there is no output + test_must_be_empty output && + + # Ensure no loose objects written (all new objects written would have + # been in "outer layer" of the merge) + git count-objects >actual && + test_cmp expect actual +' + test_expect_success 'Content merge and a few conflicts' ' git checkout side1^0 && test_must_fail git merge side2 && diff --git a/t/t5558-clone-bundle-uri.sh b/t/t5558-clone-bundle-uri.sh index 3816ed5058..9b211a626b 100755 --- a/t/t5558-clone-bundle-uri.sh +++ b/t/t5558-clone-bundle-uri.sh @@ -58,7 +58,7 @@ test_expect_success 'create bundle' ' test_expect_success 'clone with path bundle' ' git clone --bundle-uri="clone-from/B.bundle" \ clone-from clone-path && - git -C clone-path rev-parse refs/bundles/topic >actual && + git -C clone-path rev-parse refs/bundles/heads/topic >actual && git -C clone-from rev-parse topic >expect && test_cmp expect actual ' @@ -68,9 +68,9 @@ test_expect_success 'clone with bundle that has bad header' ' git clone --bundle-uri="clone-from/bad-header.bundle" \ clone-from clone-bad-header 2>err && commit_b=$(git -C clone-from rev-parse B) && - test_grep "trying to write ref '\''refs/bundles/topic'\'' with nonexistent object $commit_b" err && + test_grep "trying to write ref '\''refs/bundles/heads/topic'\'' with nonexistent object $commit_b" err && git -C clone-bad-header for-each-ref --format="%(refname)" >refs && - test_grep ! "refs/bundles/" refs + test_grep ! "refs/bundles/heads/" refs ' test_expect_success 'clone with bundle that has bad object' ' @@ -78,8 +78,8 @@ test_expect_success 'clone with bundle that has bad object' ' git clone --bundle-uri="clone-from/bad-object.bundle" \ clone-from clone-bad-object-no-fsck && git -C clone-bad-object-no-fsck for-each-ref --format="%(refname)" >refs && - grep "refs/bundles/" refs >actual && - test_write_lines refs/bundles/bad >expect && + grep "refs/bundles/heads/" refs >actual && + test_write_lines refs/bundles/heads/bad >expect && test_cmp expect actual && # Unbundle fails with fsckObjects set true, but clone can still proceed. @@ -87,14 +87,14 @@ test_expect_success 'clone with bundle that has bad object' ' clone-from clone-bad-object-fsck 2>err && test_grep "missingEmail" err && git -C clone-bad-object-fsck for-each-ref --format="%(refname)" >refs && - test_grep ! "refs/bundles/" refs + test_grep ! "refs/bundles/heads/" refs ' test_expect_success 'clone with path bundle and non-default hash' ' test_when_finished "rm -rf clone-path-non-default-hash" && GIT_DEFAULT_HASH=sha256 git clone --bundle-uri="clone-from/B.bundle" \ clone-from clone-path-non-default-hash && - git -C clone-path-non-default-hash rev-parse refs/bundles/topic >actual && + git -C clone-path-non-default-hash rev-parse refs/bundles/heads/topic >actual && git -C clone-from rev-parse topic >expect && test_cmp expect actual ' @@ -102,11 +102,41 @@ test_expect_success 'clone with path bundle and non-default hash' ' test_expect_success 'clone with file:// bundle' ' git clone --bundle-uri="file://$(pwd)/clone-from/B.bundle" \ clone-from clone-file && - git -C clone-file rev-parse refs/bundles/topic >actual && + git -C clone-file rev-parse refs/bundles/heads/topic >actual && git -C clone-from rev-parse topic >expect && test_cmp expect actual ' +test_expect_success 'create bundle with tags' ' + git init clone-from-tags && + ( + cd clone-from-tags && + git checkout -b base && + git checkout -b topic && + + test_commit A && + git tag tag-A && + git checkout -b base && + git branch -d topic && + test_commit B && + + git bundle create ALL.bundle --all && + git bundle verify ALL.bundle + ) +' + +test_expect_success 'clone with tags bundle' ' + git clone --bundle-uri="clone-from-tags/ALL.bundle" \ + clone-from-tags clone-tags-path && + + git -C clone-from-tags for-each-ref --format="%(refname:lstrip=1)" \ + >expect && + git -C clone-tags-path for-each-ref --format="%(refname:lstrip=2)" \ + refs/bundles >actual && + + test_cmp expect actual +' + # To get interesting tests for bundle lists, we need to construct a # somewhat-interesting commit history. # @@ -173,12 +203,12 @@ test_expect_success 'clone bundle list (file, no heuristic)' ' git -C clone-list-file cat-file --batch-check <oids && git -C clone-list-file for-each-ref --format="%(refname)" >refs && - grep "refs/bundles/" refs >actual && + grep "refs/bundles/heads/" refs >actual && cat >expect <<-\EOF && - refs/bundles/base - refs/bundles/left - refs/bundles/merge - refs/bundles/right + refs/bundles/heads/base + refs/bundles/heads/left + refs/bundles/heads/merge + refs/bundles/heads/right EOF test_cmp expect actual ' @@ -220,10 +250,10 @@ test_expect_success 'clone bundle list (file, all mode, some failures)' ' git -C clone-all-some cat-file --batch-check <oids && git -C clone-all-some for-each-ref --format="%(refname)" >refs && - grep "refs/bundles/" refs >actual && + grep "refs/bundles/heads/" refs >actual && cat >expect <<-\EOF && - refs/bundles/base - refs/bundles/left + refs/bundles/heads/base + refs/bundles/heads/left EOF test_cmp expect actual ' @@ -253,7 +283,7 @@ test_expect_success 'clone bundle list (file, all mode, all failures)' ' git -C clone-all-fail cat-file --batch-check <oids && git -C clone-all-fail for-each-ref --format="%(refname)" >refs && - ! grep "refs/bundles/" refs + ! grep "refs/bundles/heads/" refs ' test_expect_success 'clone bundle list (file, any mode)' ' @@ -282,9 +312,9 @@ test_expect_success 'clone bundle list (file, any mode)' ' git -C clone-any-file cat-file --batch-check <oids && git -C clone-any-file for-each-ref --format="%(refname)" >refs && - grep "refs/bundles/" refs >actual && + grep "refs/bundles/heads/" refs >actual && cat >expect <<-\EOF && - refs/bundles/base + refs/bundles/heads/base EOF test_cmp expect actual ' @@ -313,7 +343,7 @@ test_expect_success 'clone bundle list (file, any mode, all failures)' ' git -C clone-any-fail cat-file --batch-check <oids && git -C clone-any-fail for-each-ref --format="%(refname)" >refs && - ! grep "refs/bundles/" refs + ! grep "refs/bundles/heads/" refs ' test_expect_success 'negotiation: bundle with part of wanted commits' ' @@ -322,10 +352,10 @@ test_expect_success 'negotiation: bundle with part of wanted commits' ' git clone --no-local --bundle-uri="clone-from/A.bundle" \ clone-from nego-bundle-part && git -C nego-bundle-part for-each-ref --format="%(refname)" >refs && - grep "refs/bundles/" refs >actual && - test_write_lines refs/bundles/topic >expect && + grep "refs/bundles/heads/" refs >actual && + test_write_lines refs/bundles/heads/topic >expect && test_cmp expect actual && - # Ensure that refs/bundles/topic are sent as "have". + # Ensure that refs/bundles/heads/topic are sent as "have". tip=$(git -C clone-from rev-parse A) && test_grep "clone> have $tip" trace-packet.txt ' @@ -337,8 +367,8 @@ test_expect_success 'negotiation: bundle with all wanted commits' ' --bundle-uri="clone-from/B.bundle" \ clone-from nego-bundle-all && git -C nego-bundle-all for-each-ref --format="%(refname)" >refs && - grep "refs/bundles/" refs >actual && - test_write_lines refs/bundles/topic >expect && + grep "refs/bundles/heads/" refs >actual && + test_write_lines refs/bundles/heads/topic >expect && test_cmp expect actual && # We already have all needed commits so no "want" needed. test_grep ! "clone> want " trace-packet.txt @@ -363,13 +393,13 @@ test_expect_success 'negotiation: bundle list (no heuristic)' ' clone-from nego-bundle-list-no-heuristic && git -C nego-bundle-list-no-heuristic for-each-ref --format="%(refname)" >refs && - grep "refs/bundles/" refs >actual && + grep "refs/bundles/heads/" refs >actual && cat >expect <<-\EOF && - refs/bundles/base - refs/bundles/left + refs/bundles/heads/base + refs/bundles/heads/left EOF test_cmp expect actual && - tip=$(git -C nego-bundle-list-no-heuristic rev-parse refs/bundles/left) && + tip=$(git -C nego-bundle-list-no-heuristic rev-parse refs/bundles/heads/left) && test_grep "clone> have $tip" trace-packet.txt ' @@ -395,13 +425,13 @@ test_expect_success 'negotiation: bundle list (creationToken)' ' clone-from nego-bundle-list-heuristic && git -C nego-bundle-list-heuristic for-each-ref --format="%(refname)" >refs && - grep "refs/bundles/" refs >actual && + grep "refs/bundles/heads/" refs >actual && cat >expect <<-\EOF && - refs/bundles/base - refs/bundles/left + refs/bundles/heads/base + refs/bundles/heads/left EOF test_cmp expect actual && - tip=$(git -C nego-bundle-list-heuristic rev-parse refs/bundles/left) && + tip=$(git -C nego-bundle-list-heuristic rev-parse refs/bundles/heads/left) && test_grep "clone> have $tip" trace-packet.txt ' @@ -428,10 +458,10 @@ test_expect_success 'negotiation: bundle list with all wanted commits' ' clone-from nego-bundle-list-all && git -C nego-bundle-list-all for-each-ref --format="%(refname)" >refs && - grep "refs/bundles/" refs >actual && + grep "refs/bundles/heads/" refs >actual && cat >expect <<-\EOF && - refs/bundles/base - refs/bundles/left + refs/bundles/heads/base + refs/bundles/heads/left EOF test_cmp expect actual && # We already have all needed commits so no "want" needed. @@ -465,7 +495,7 @@ test_expect_success 'clone HTTP bundle' ' git clone --bundle-uri="$HTTPD_URL/B.bundle" \ "$HTTPD_URL/smart/fetch.git" clone-http && - git -C clone-http rev-parse refs/bundles/topic >actual && + git -C clone-http rev-parse refs/bundles/heads/topic >actual && git -C clone-from rev-parse topic >expect && test_cmp expect actual && @@ -476,7 +506,7 @@ test_expect_success 'clone HTTP bundle with non-default hash' ' test_when_finished "rm -rf clone-http-non-default-hash" && GIT_DEFAULT_HASH=sha256 git clone --bundle-uri="$HTTPD_URL/B.bundle" \ "$HTTPD_URL/smart/fetch.git" clone-http-non-default-hash && - git -C clone-http-non-default-hash rev-parse refs/bundles/topic >actual && + git -C clone-http-non-default-hash rev-parse refs/bundles/heads/topic >actual && git -C clone-from rev-parse topic >expect && test_cmp expect actual ' @@ -553,12 +583,12 @@ test_expect_success 'clone bundle list (HTTP, any mode)' ' git -C clone-any-http cat-file --batch-check <oids && git -C clone-list-file for-each-ref --format="%(refname)" >refs && - grep "refs/bundles/" refs >actual && + grep "refs/bundles/heads/" refs >actual && cat >expect <<-\EOF && - refs/bundles/base - refs/bundles/left - refs/bundles/merge - refs/bundles/right + refs/bundles/heads/base + refs/bundles/heads/left + refs/bundles/heads/merge + refs/bundles/heads/right EOF test_cmp expect actual ' @@ -641,9 +671,9 @@ test_expect_success 'clone incomplete bundle list (http, creationToken)' ' test_cmp expect actual && # We now have only one bundle ref. - git -C clone-token-http for-each-ref --format="%(refname)" "refs/bundles/*" >refs && + git -C clone-token-http for-each-ref --format="%(refname)" "refs/bundles/heads/*" >refs && cat >expect <<-\EOF && - refs/bundles/base + refs/bundles/heads/base EOF test_cmp expect refs && @@ -679,13 +709,13 @@ test_expect_success 'clone incomplete bundle list (http, creationToken)' ' test_cmp expect actual && # We now have all bundle refs. - git -C clone-token-http for-each-ref --format="%(refname)" "refs/bundles/*" >refs && + git -C clone-token-http for-each-ref --format="%(refname)" "refs/bundles/heads/*" >refs && cat >expect <<-\EOF && - refs/bundles/base - refs/bundles/left - refs/bundles/merge - refs/bundles/right + refs/bundles/heads/base + refs/bundles/heads/left + refs/bundles/heads/merge + refs/bundles/heads/right EOF test_cmp expect refs ' @@ -721,9 +751,9 @@ test_expect_success 'http clone with bundle.heuristic creates fetch.bundleURI' ' test_cmp expect actual && # only received base ref from bundle-1 - git -C fetch-http-4 for-each-ref --format="%(refname)" "refs/bundles/*" >refs && + git -C fetch-http-4 for-each-ref --format="%(refname)" "refs/bundles/heads/*" >refs && cat >expect <<-\EOF && - refs/bundles/base + refs/bundles/heads/base EOF test_cmp expect refs && @@ -749,10 +779,10 @@ test_expect_success 'http clone with bundle.heuristic creates fetch.bundleURI' ' test_cmp expect actual && # received left from bundle-2 - git -C fetch-http-4 for-each-ref --format="%(refname)" "refs/bundles/*" >refs && + git -C fetch-http-4 for-each-ref --format="%(refname)" "refs/bundles/heads/*" >refs && cat >expect <<-\EOF && - refs/bundles/base - refs/bundles/left + refs/bundles/heads/base + refs/bundles/heads/left EOF test_cmp expect refs && @@ -795,12 +825,12 @@ test_expect_success 'http clone with bundle.heuristic creates fetch.bundleURI' ' # received merge ref from bundle-4, but right is missing # because we did not download bundle-3. - git -C fetch-http-4 for-each-ref --format="%(refname)" "refs/bundles/*" >refs && + git -C fetch-http-4 for-each-ref --format="%(refname)" "refs/bundles/heads/*" >refs && cat >expect <<-\EOF && - refs/bundles/base - refs/bundles/left - refs/bundles/merge + refs/bundles/heads/base + refs/bundles/heads/left + refs/bundles/heads/merge EOF test_cmp expect refs && @@ -862,7 +892,7 @@ test_expect_success 'creationToken heuristic with failed downloads (clone)' ' test_cmp expect actual && # All bundles failed to unbundle - git -C download-1 for-each-ref --format="%(refname)" "refs/bundles/*" >refs && + git -C download-1 for-each-ref --format="%(refname)" "refs/bundles/heads/*" >refs && test_must_be_empty refs && # Case 2: middle bundle does not exist, only two bundles can unbundle @@ -909,10 +939,10 @@ test_expect_success 'creationToken heuristic with failed downloads (clone)' ' test_cmp expect actual && # bundle-1 and bundle-3 could unbundle, but bundle-4 could not - git -C download-2 for-each-ref --format="%(refname)" "refs/bundles/*" >refs && + git -C download-2 for-each-ref --format="%(refname)" "refs/bundles/heads/*" >refs && cat >expect <<-EOF && - refs/bundles/base - refs/bundles/right + refs/bundles/heads/base + refs/bundles/heads/right EOF test_cmp expect refs && @@ -961,11 +991,11 @@ test_expect_success 'creationToken heuristic with failed downloads (clone)' ' test_cmp expect actual && # fake.bundle did not unbundle, but the others did. - git -C download-3 for-each-ref --format="%(refname)" "refs/bundles/*" >refs && + git -C download-3 for-each-ref --format="%(refname)" "refs/bundles/heads/*" >refs && cat >expect <<-EOF && - refs/bundles/base - refs/bundles/left - refs/bundles/right + refs/bundles/heads/base + refs/bundles/heads/left + refs/bundles/heads/right EOF test_cmp expect refs ' @@ -1083,15 +1113,15 @@ test_expect_success 'creationToken heuristic with failed downloads (fetch)' ' test_cmp expect actual && # Check which bundles have unbundled by refs - git -C fetch-1 for-each-ref --format="%(refname)" "refs/bundles/*" >refs && + git -C fetch-1 for-each-ref --format="%(refname)" "refs/bundles/heads/*" >refs && cat >expect <<-EOF && - refs/bundles/base - refs/bundles/left - refs/bundles/lefter - refs/bundles/merge - refs/bundles/right - refs/bundles/righter - refs/bundles/top + refs/bundles/heads/base + refs/bundles/heads/left + refs/bundles/heads/lefter + refs/bundles/heads/merge + refs/bundles/heads/right + refs/bundles/heads/righter + refs/bundles/heads/top EOF test_cmp expect refs && @@ -1144,12 +1174,12 @@ test_expect_success 'creationToken heuristic with failed downloads (fetch)' ' test_cmp expect actual && # Check which bundles have unbundled by refs - git -C fetch-2 for-each-ref --format="%(refname)" "refs/bundles/*" >refs && + git -C fetch-2 for-each-ref --format="%(refname)" "refs/bundles/heads/*" >refs && cat >expect <<-EOF && - refs/bundles/base - refs/bundles/left - refs/bundles/merge - refs/bundles/right + refs/bundles/heads/base + refs/bundles/heads/left + refs/bundles/heads/merge + refs/bundles/heads/right EOF test_cmp expect refs && @@ -1204,13 +1234,13 @@ test_expect_success 'creationToken heuristic with failed downloads (fetch)' ' test_cmp expect actual && # Check which bundles have unbundled by refs - git -C fetch-3 for-each-ref --format="%(refname)" "refs/bundles/*" >refs && + git -C fetch-3 for-each-ref --format="%(refname)" "refs/bundles/heads/*" >refs && cat >expect <<-EOF && - refs/bundles/base - refs/bundles/left - refs/bundles/lefter - refs/bundles/right - refs/bundles/righter + refs/bundles/heads/base + refs/bundles/heads/left + refs/bundles/heads/lefter + refs/bundles/heads/right + refs/bundles/heads/righter EOF test_cmp expect refs ' diff --git a/t/t9210-scalar.sh b/t/t9210-scalar.sh index a81662713e..bd6f0c40d2 100755 --- a/t/t9210-scalar.sh +++ b/t/t9210-scalar.sh @@ -108,7 +108,7 @@ test_expect_success 'scalar register warns when background maintenance fails' ' git init register-repo && GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \ scalar register register-repo 2>err && - grep "could not turn on maintenance" err + grep "could not toggle maintenance" err ' test_expect_success 'scalar unregister' ' @@ -129,6 +129,17 @@ test_expect_success 'scalar unregister' ' scalar unregister vanish ' +test_expect_success 'scalar register --no-maintenance' ' + git init register-no-maint && + event_log="$(pwd)/no-maint.event" && + GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \ + GIT_TRACE2_EVENT="$event_log" \ + GIT_TRACE2_EVENT_DEPTH=100 \ + scalar register --no-maintenance register-no-maint 2>err && + test_must_be_empty err && + test_subcommand ! git maintenance unregister --force <no-maint.event +' + test_expect_success 'set up repository to clone' ' test_commit first && test_commit second && @@ -199,7 +210,18 @@ test_expect_success 'scalar reconfigure' ' GIT_TRACE2_EVENT="$(pwd)/reconfigure" scalar reconfigure -a && test_path_is_file one/src/cron.txt && test true = "$(git -C one/src config core.preloadIndex)" && - test_subcommand git maintenance start <reconfigure + test_subcommand git maintenance start <reconfigure && + test_subcommand ! git maintenance unregister --force <reconfigure && + + GIT_TRACE2_EVENT="$(pwd)/reconfigure-maint-disable" \ + scalar reconfigure -a --maintenance=disable && + test_subcommand ! git maintenance start <reconfigure-maint-disable && + test_subcommand git maintenance unregister --force <reconfigure-maint-disable && + + GIT_TRACE2_EVENT="$(pwd)/reconfigure-maint-keep" \ + scalar reconfigure --maintenance=keep -a && + test_subcommand ! git maintenance start <reconfigure-maint-keep && + test_subcommand ! git maintenance unregister --force <reconfigure-maint-keep ' test_expect_success 'scalar reconfigure --all with includeIf.onbranch' ' diff --git a/t/t9211-scalar-clone.sh b/t/t9211-scalar-clone.sh index 01f71910f5..bfbf22a462 100755 --- a/t/t9211-scalar-clone.sh +++ b/t/t9211-scalar-clone.sh @@ -177,7 +177,16 @@ test_expect_success 'progress without tty' ' test_expect_success 'scalar clone warns when background maintenance fails' ' GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \ scalar clone "file://$(pwd)/to-clone" maint-fail 2>err && - grep "could not turn on maintenance" err + grep "could not toggle maintenance" err +' + +test_expect_success 'scalar clone --no-maintenance' ' + GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \ + GIT_TRACE2_EVENT="$(pwd)/no-maint.event" \ + GIT_TRACE2_EVENT_DEPTH=100 \ + scalar clone --no-maintenance "file://$(pwd)/to-clone" no-maint 2>err && + ! grep "could not toggle maintenance" err && + test_subcommand ! git maintenance unregister --force <no-maint.event ' test_expect_success '`scalar clone --no-src`' ' diff --git a/t/unit-tests/t-reftable-block.c b/t/unit-tests/t-reftable-block.c index 7dbd93601c..52f1dae1c9 100644 --- a/t/unit-tests/t-reftable-block.c +++ b/t/unit-tests/t-reftable-block.c @@ -64,7 +64,8 @@ static void t_ref_block_read_write(void) block_writer_release(&bw); block_source_from_buf(&source ,&block_data); - reftable_block_init(&block, &source, 0, header_off, block_size, REFTABLE_HASH_SIZE_SHA1); + reftable_block_init(&block, &source, 0, header_off, block_size, + REFTABLE_HASH_SIZE_SHA1, REFTABLE_BLOCK_TYPE_REF); block_iter_init(&it, &block); @@ -153,7 +154,8 @@ static void t_log_block_read_write(void) block_writer_release(&bw); block_source_from_buf(&source, &block_data); - reftable_block_init(&block, &source, 0, header_off, block_size, REFTABLE_HASH_SIZE_SHA1); + reftable_block_init(&block, &source, 0, header_off, block_size, + REFTABLE_HASH_SIZE_SHA1, REFTABLE_BLOCK_TYPE_LOG); block_iter_init(&it, &block); @@ -245,7 +247,8 @@ static void t_obj_block_read_write(void) block_writer_release(&bw); block_source_from_buf(&source, &block_data); - reftable_block_init(&block, &source, 0, header_off, block_size, REFTABLE_HASH_SIZE_SHA1); + reftable_block_init(&block, &source, 0, header_off, block_size, + REFTABLE_HASH_SIZE_SHA1, REFTABLE_BLOCK_TYPE_OBJ); block_iter_init(&it, &block); @@ -329,7 +332,8 @@ static void t_index_block_read_write(void) block_writer_release(&bw); block_source_from_buf(&source, &block_data); - reftable_block_init(&block, &source, 0, header_off, block_size, REFTABLE_HASH_SIZE_SHA1); + reftable_block_init(&block, &source, 0, header_off, block_size, + REFTABLE_HASH_SIZE_SHA1, REFTABLE_BLOCK_TYPE_INDEX); block_iter_init(&it, &block); @@ -411,7 +415,8 @@ static void t_block_iterator(void) check_int(err, >, 0); block_source_from_buf(&source, &data); - reftable_block_init(&block, &source, 0, 0, data.len, REFTABLE_HASH_SIZE_SHA1); + reftable_block_init(&block, &source, 0, 0, data.len, + REFTABLE_HASH_SIZE_SHA1, REFTABLE_BLOCK_TYPE_REF); err = reftable_block_init_iterator(&block, &it); check_int(err, ==, 0); diff --git a/t/unit-tests/u-oidmap.c b/t/unit-tests/u-oidmap.c index dc805b7e3c..b23af449f6 100644 --- a/t/unit-tests/u-oidmap.c +++ b/t/unit-tests/u-oidmap.c @@ -35,7 +35,7 @@ void test_oidmap__initialize(void) void test_oidmap__cleanup(void) { - oidmap_free(&map, 1); + oidmap_clear(&map, 1); } void test_oidmap__replace(void) |
