diff options
Diffstat (limited to 't')
38 files changed, 1032 insertions, 1859 deletions
diff --git a/t/helper/.gitignore b/t/helper/.gitignore index 48c7bb0bbb..8c2ddcce95 100644 --- a/t/helper/.gitignore +++ b/t/helper/.gitignore @@ -1,4 +1,2 @@ /test-tool /test-fake-ssh -/test-line-buffer -/test-svn-fe diff --git a/t/helper/test-line-buffer.c b/t/helper/test-line-buffer.c deleted file mode 100644 index 078dd7e29d..0000000000 --- a/t/helper/test-line-buffer.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * test-line-buffer.c: code to exercise the svn importer's input helper - */ - -#include "git-compat-util.h" -#include "strbuf.h" -#include "vcs-svn/line_buffer.h" - -static uint32_t strtouint32(const char *s) -{ - char *end; - uintmax_t n = strtoumax(s, &end, 10); - if (*s == '\0' || *end != '\0') - die("invalid count: %s", s); - return (uint32_t) n; -} - -static void handle_command(const char *command, const char *arg, struct line_buffer *buf) -{ - if (starts_with(command, "binary ")) { - struct strbuf sb = STRBUF_INIT; - strbuf_addch(&sb, '>'); - buffer_read_binary(buf, &sb, strtouint32(arg)); - fwrite(sb.buf, 1, sb.len, stdout); - strbuf_release(&sb); - } else if (starts_with(command, "copy ")) { - buffer_copy_bytes(buf, strtouint32(arg)); - } else if (starts_with(command, "skip ")) { - buffer_skip_bytes(buf, strtouint32(arg)); - } else { - die("unrecognized command: %s", command); - } -} - -static void handle_line(const char *line, struct line_buffer *stdin_buf) -{ - const char *arg = strchr(line, ' '); - if (!arg) - die("no argument in line: %s", line); - handle_command(line, arg + 1, stdin_buf); -} - -int cmd_main(int argc, const char **argv) -{ - struct line_buffer stdin_buf = LINE_BUFFER_INIT; - struct line_buffer file_buf = LINE_BUFFER_INIT; - struct line_buffer *input = &stdin_buf; - const char *filename; - char *s; - - if (argc == 1) - filename = NULL; - else if (argc == 2) - filename = argv[1]; - else - usage("test-line-buffer [file | &fd] < script"); - - if (buffer_init(&stdin_buf, NULL)) - die_errno("open error"); - if (filename) { - if (*filename == '&') { - if (buffer_fdinit(&file_buf, strtouint32(filename + 1))) - die_errno("error opening fd %s", filename + 1); - } else { - if (buffer_init(&file_buf, filename)) - die_errno("error opening %s", filename); - } - input = &file_buf; - } - - while ((s = buffer_read_line(&stdin_buf))) - handle_line(s, input); - - if (filename && buffer_deinit(&file_buf)) - die("error reading from %s", filename); - if (buffer_deinit(&stdin_buf)) - die("input error"); - if (ferror(stdout)) - die("output error"); - return 0; -} diff --git a/t/helper/test-svn-fe.c b/t/helper/test-svn-fe.c deleted file mode 100644 index 7667c0803f..0000000000 --- a/t/helper/test-svn-fe.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * test-svn-fe: Code to exercise the svn import lib - */ - -#include "git-compat-util.h" -#include "vcs-svn/svndump.h" -#include "vcs-svn/svndiff.h" -#include "vcs-svn/sliding_window.h" -#include "vcs-svn/line_buffer.h" - -static const char test_svnfe_usage[] = - "test-svn-fe (<dumpfile> | [-d] <preimage> <delta> <len>)"; - -static int apply_delta(int argc, const char **argv) -{ - struct line_buffer preimage = LINE_BUFFER_INIT; - struct line_buffer delta = LINE_BUFFER_INIT; - struct sliding_view preimage_view = SLIDING_VIEW_INIT(&preimage, -1); - - if (argc != 5) - usage(test_svnfe_usage); - - if (buffer_init(&preimage, argv[2])) - die_errno("cannot open preimage"); - if (buffer_init(&delta, argv[3])) - die_errno("cannot open delta"); - if (svndiff0_apply(&delta, (off_t) strtoumax(argv[4], NULL, 0), - &preimage_view, stdout)) - return 1; - if (buffer_deinit(&preimage)) - die_errno("cannot close preimage"); - if (buffer_deinit(&delta)) - die_errno("cannot close delta"); - strbuf_release(&preimage_view.buf); - return 0; -} - -int cmd_main(int argc, const char **argv) -{ - if (argc == 2) { - if (svndump_init(argv[1])) - return 1; - svndump_read(NULL, "refs/heads/master", "refs/notes/svn/revs"); - svndump_deinit(); - svndump_reset(); - return 0; - } - - if (argc >= 2 && !strcmp(argv[1], "-d")) - return apply_delta(argc, argv); - usage(test_svnfe_usage); -} diff --git a/t/perf/README b/t/perf/README index c7b70e2d28..bd649afa97 100644 --- a/t/perf/README +++ b/t/perf/README @@ -84,6 +84,15 @@ You can set the following variables (also in your config.mak): probably be about linux.git size for optimal results. Both default to the git.git you are running from. + GIT_PERF_EXTRA + Boolean to enable additional tests. Most test scripts are + written to detect regressions between two versions of Git, and + the output will compare timings for individual tests between + those versions. Some scripts have additional tests which are not + run by default, that show patterns within a single version of + Git (e.g., performance of index-pack as the number of threads + changes). These can be enabled with GIT_PERF_EXTRA. + You can also pass the options taken by ordinary git tests; the most useful one is: diff --git a/t/perf/p1400-update-ref.sh b/t/perf/p1400-update-ref.sh index d275a81248..ce5ac3ed85 100755 --- a/t/perf/p1400-update-ref.sh +++ b/t/perf/p1400-update-ref.sh @@ -7,11 +7,13 @@ test_description="Tests performance of update-ref" test_perf_fresh_repo test_expect_success "setup" ' + git init --bare target-repo.git && test_commit PRE && test_commit POST && printf "create refs/heads/%d PRE\n" $(test_seq 1000) >create && printf "update refs/heads/%d POST PRE\n" $(test_seq 1000) >update && - printf "delete refs/heads/%d POST\n" $(test_seq 1000) >delete + printf "delete refs/heads/%d POST\n" $(test_seq 1000) >delete && + git update-ref --stdin <create ' test_perf "update-ref" ' @@ -24,9 +26,14 @@ test_perf "update-ref" ' ' test_perf "update-ref --stdin" ' - git update-ref --stdin <create && git update-ref --stdin <update && - git update-ref --stdin <delete + git update-ref --stdin <delete && + git update-ref --stdin <create +' + +test_perf "nonatomic push" ' + git push ./target-repo.git $(test_seq 1000) && + git push --delete ./target-repo.git $(test_seq 1000) ' test_done diff --git a/t/perf/p5302-pack-index.sh b/t/perf/p5302-pack-index.sh index a9b3e112d9..228593d9ad 100755 --- a/t/perf/p5302-pack-index.sh +++ b/t/perf/p5302-pack-index.sh @@ -13,35 +13,36 @@ test_expect_success 'repack' ' export PACK ' -test_perf 'index-pack 0 threads' ' - rm -rf repo.git && - git init --bare repo.git && - GIT_DIR=repo.git git index-pack --threads=1 --stdin < $PACK -' - -test_perf 'index-pack 1 thread ' ' - rm -rf repo.git && - git init --bare repo.git && - GIT_DIR=repo.git GIT_FORCE_THREADS=1 git index-pack --threads=1 --stdin < $PACK +# Rather than counting up and doubling each time, count down from the endpoint, +# halving each time. That ensures that our final test uses as many threads as +# CPUs, even if it isn't a power of 2. +test_expect_success 'set up thread-counting tests' ' + t=$(test-tool online-cpus) && + threads= && + while test $t -gt 0 + do + threads="$t $threads" + t=$((t / 2)) + done ' -test_perf 'index-pack 2 threads' ' +test_perf PERF_EXTRA 'index-pack 0 threads' ' rm -rf repo.git && git init --bare repo.git && - GIT_DIR=repo.git git index-pack --threads=2 --stdin < $PACK -' - -test_perf 'index-pack 4 threads' ' - rm -rf repo.git && - git init --bare repo.git && - GIT_DIR=repo.git git index-pack --threads=4 --stdin < $PACK + GIT_DIR=repo.git git index-pack --threads=1 --stdin < $PACK ' -test_perf 'index-pack 8 threads' ' - rm -rf repo.git && - git init --bare repo.git && - GIT_DIR=repo.git git index-pack --threads=8 --stdin < $PACK -' +for t in $threads +do + THREADS=$t + export THREADS + test_perf PERF_EXTRA "index-pack $t threads" ' + rm -rf repo.git && + git init --bare repo.git && + GIT_DIR=repo.git GIT_FORCE_THREADS=1 \ + git index-pack --threads=$THREADS --stdin <$PACK + ' +done test_perf 'index-pack default number of threads' ' rm -rf repo.git && diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh index 13e389367a..821581a885 100644 --- a/t/perf/perf-lib.sh +++ b/t/perf/perf-lib.sh @@ -245,3 +245,5 @@ test_at_end_hook_ () { test_export () { export "$@" } + +test_lazy_prereq PERF_EXTRA 'test_bool_env GIT_PERF_EXTRA false' diff --git a/t/t0001-init.sh b/t/t0001-init.sh index 50222a10c5..2f7c3dcd0f 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@ -329,6 +329,15 @@ test_expect_success 'implicit bare & --separate-git-dir incompatible' ' test_i18ngrep "incompatible" err ' +test_expect_success 'bare & --separate-git-dir incompatible within worktree' ' + test_when_finished "rm -rf bare.git linkwt seprepo" && + test_commit gumby && + git clone --bare . bare.git && + git -C bare.git worktree add --detach ../linkwt && + test_must_fail git -C linkwt init --separate-git-dir seprepo 2>err && + test_i18ngrep "incompatible" err +' + test_lazy_prereq GETCWD_IGNORES_PERMS ' base=GETCWD_TEST_BASE_DIR && mkdir -p $base/dir && @@ -405,6 +414,25 @@ test_expect_success SYMLINKS 're-init to move gitdir symlink' ' test_path_is_dir realgitdir/refs ' +sep_git_dir_worktree () { + test_when_finished "rm -rf mainwt linkwt seprepo" && + git init mainwt && + test_commit -C mainwt gumby && + git -C mainwt worktree add --detach ../linkwt && + git -C "$1" init --separate-git-dir ../seprepo && + git -C mainwt rev-parse --git-common-dir >expect && + git -C linkwt rev-parse --git-common-dir >actual && + test_cmp expect actual +} + +test_expect_success 're-init to move gitdir with linked worktrees' ' + sep_git_dir_worktree mainwt +' + +test_expect_success 're-init to move gitdir within linked worktree' ' + sep_git_dir_worktree linkwt +' + test_expect_success MINGW '.git hidden' ' rm -rf newdir && ( diff --git a/t/t0081-line-buffer.sh b/t/t0081-line-buffer.sh deleted file mode 100755 index ce92e6acad..0000000000 --- a/t/t0081-line-buffer.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/sh - -test_description="Test the svn importer's input handling routines. - -These tests provide some simple checks that the line_buffer API -behaves as advertised. - -While at it, check that input of newlines and null bytes are handled -correctly. -" -. ./test-lib.sh - -test_expect_success 'hello world' ' - echo ">HELLO" >expect && - test-line-buffer <<-\EOF >actual && - binary 6 - HELLO - EOF - test_cmp expect actual -' - -test_expect_success '0-length read, send along greeting' ' - echo ">HELLO" >expect && - test-line-buffer <<-\EOF >actual && - binary 0 - copy 6 - HELLO - EOF - test_cmp expect actual -' - -test_expect_success !MINGW 'read from file descriptor' ' - rm -f input && - echo hello >expect && - echo hello >input && - echo copy 6 | - test-line-buffer "&4" 4<input >actual && - test_cmp expect actual -' - -test_expect_success 'skip, copy null byte' ' - echo Q | q_to_nul >expect && - q_to_nul <<-\EOF | test-line-buffer >actual && - skip 2 - Q - copy 2 - Q - EOF - test_cmp expect actual -' - -test_expect_success 'read null byte' ' - echo ">QhelloQ" | q_to_nul >expect && - q_to_nul <<-\EOF | test-line-buffer >actual && - binary 8 - QhelloQ - EOF - test_cmp expect actual -' - -test_expect_success 'long reads are truncated' ' - echo ">foo" >expect && - test-line-buffer <<-\EOF >actual && - binary 5 - foo - EOF - test_cmp expect actual -' - -test_expect_success 'long copies are truncated' ' - printf "%s\n" ">" foo >expect && - test-line-buffer <<-\EOF >actual && - binary 1 - - copy 5 - foo - EOF - test_cmp expect actual -' - -test_expect_success 'long binary reads are truncated' ' - echo ">foo" >expect && - test-line-buffer <<-\EOF >actual && - binary 5 - foo - EOF - test_cmp expect actual -' - -test_done diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh index a5ebdf9ff3..584a039b85 100755 --- a/t/t0410-partial-clone.sh +++ b/t/t0410-partial-clone.sh @@ -183,7 +183,7 @@ test_expect_success 'missing CLI object, but promised, passes fsck' ' ' test_expect_success 'fetching of missing objects' ' - rm -rf repo && + rm -rf repo err && test_create_repo server && test_commit -C server foo && git -C server repack -a -d --write-bitmap-index && @@ -194,7 +194,10 @@ test_expect_success 'fetching of missing objects' ' git -C repo config core.repositoryformatversion 1 && git -C repo config extensions.partialclone "origin" && - git -C repo cat-file -p "$HASH" && + git -C repo cat-file -p "$HASH" 2>err && + + # Ensure that no spurious FETCH_HEAD messages are written + ! grep FETCH_HEAD err && # Ensure that the .promisor file is written, and check that its # associated packfile contains the object @@ -214,7 +217,7 @@ test_expect_success 'fetching of missing objects works with ref-in-want enabled' rm -rf repo/.git/objects/* && rm -f trace && GIT_TRACE_PACKET="$(pwd)/trace" git -C repo cat-file -p "$HASH" && - grep "git< fetch=.*ref-in-want" trace + grep "fetch< fetch=.*ref-in-want" trace ' test_expect_success 'fetching of missing objects from another promisor remote' ' diff --git a/t/t2025-checkout-no-overlay.sh b/t/t2025-checkout-no-overlay.sh index 76330cb5ab..fa9e098706 100755 --- a/t/t2025-checkout-no-overlay.sh +++ b/t/t2025-checkout-no-overlay.sh @@ -44,4 +44,16 @@ test_expect_success '--no-overlay --theirs with D/F conflict deletes file' ' test_path_is_missing file1 ' +test_expect_success 'wildcard pathspec matches file in subdirectory' ' + git reset --hard && + mkdir subdir && + test_commit file3-1 subdir/file3 && + test_commit file3-2 subdir/file3 && + + git checkout --no-overlay file3-1 "*file3" && + echo file3-1 >expect && + test_path_is_file subdir/file3 && + test_cmp expect subdir/file3 +' + test_done diff --git a/t/t2072-restore-pathspec-file.sh b/t/t2072-restore-pathspec-file.sh index 0d47946e8a..b48345bf95 100755 --- a/t/t2072-restore-pathspec-file.sh +++ b/t/t2072-restore-pathspec-file.sh @@ -9,18 +9,21 @@ test_tick test_expect_success setup ' test_commit file0 && + mkdir dir1 && + echo 1 >dir1/file && echo 1 >fileA.t && echo 1 >fileB.t && echo 1 >fileC.t && echo 1 >fileD.t && - git add fileA.t fileB.t fileC.t fileD.t && + git add dir1 fileA.t fileB.t fileC.t fileD.t && git commit -m "files 1" && + echo 2 >dir1/file && echo 2 >fileA.t && echo 2 >fileB.t && echo 2 >fileC.t && echo 2 >fileD.t && - git add fileA.t fileB.t fileC.t fileD.t && + git add dir1 fileA.t fileB.t fileC.t fileD.t && git commit -m "files 2" && git tag checkpoint @@ -31,7 +34,7 @@ restore_checkpoint () { } verify_expect () { - git status --porcelain --untracked-files=no -- fileA.t fileB.t fileC.t fileD.t >actual && + git status --porcelain --untracked-files=no -- dir1 fileA.t fileB.t fileC.t fileD.t >actual && test_cmp expect actual } @@ -161,4 +164,14 @@ test_expect_success 'error conditions' ' test_i18ngrep -e "you must specify path(s) to restore" err ' +test_expect_success 'wildcard pathspec matches file in subdirectory' ' + restore_checkpoint && + + echo "*file" | git restore --pathspec-from-file=- --source=HEAD^1 && + cat >expect <<-\EOF && + M dir1/file + EOF + verify_expect +' + test_done diff --git a/t/t2406-worktree-repair.sh b/t/t2406-worktree-repair.sh new file mode 100755 index 0000000000..1fe468bfe8 --- /dev/null +++ b/t/t2406-worktree-repair.sh @@ -0,0 +1,179 @@ +#!/bin/sh + +test_description='test git worktree repair' + +. ./test-lib.sh + +test_expect_success setup ' + test_commit init +' + +test_expect_success 'skip missing worktree' ' + test_when_finished "git worktree prune" && + git worktree add --detach missing && + rm -rf missing && + git worktree repair >out 2>err && + test_must_be_empty out && + test_must_be_empty err +' + +test_expect_success 'worktree path not directory' ' + test_when_finished "git worktree prune" && + git worktree add --detach notdir && + rm -rf notdir && + >notdir && + test_must_fail git worktree repair >out 2>err && + test_must_be_empty out && + test_i18ngrep "not a directory" err +' + +test_expect_success "don't clobber .git repo" ' + test_when_finished "rm -rf repo && git worktree prune" && + git worktree add --detach repo && + rm -rf repo && + test_create_repo repo && + test_must_fail git worktree repair >out 2>err && + test_must_be_empty out && + test_i18ngrep ".git is not a file" err +' + +test_corrupt_gitfile () { + butcher=$1 && + problem=$2 && + repairdir=${3:-.} && + test_when_finished 'rm -rf corrupt && git worktree prune' && + git worktree add --detach corrupt && + git -C corrupt rev-parse --absolute-git-dir >expect && + eval "$butcher" && + git -C "$repairdir" worktree repair >out 2>err && + test_i18ngrep "$problem" out && + test_must_be_empty err && + git -C corrupt rev-parse --absolute-git-dir >actual && + test_cmp expect actual +} + +test_expect_success 'repair missing .git file' ' + test_corrupt_gitfile "rm -f corrupt/.git" ".git file broken" +' + +test_expect_success 'repair bogus .git file' ' + test_corrupt_gitfile "echo \"gitdir: /nowhere\" >corrupt/.git" \ + ".git file broken" +' + +test_expect_success 'repair incorrect .git file' ' + test_when_finished "rm -rf other && git worktree prune" && + test_create_repo other && + other=$(git -C other rev-parse --absolute-git-dir) && + test_corrupt_gitfile "echo \"gitdir: $other\" >corrupt/.git" \ + ".git file incorrect" +' + +test_expect_success 'repair .git file from main/.git' ' + test_corrupt_gitfile "rm -f corrupt/.git" ".git file broken" .git +' + +test_expect_success 'repair .git file from linked worktree' ' + test_when_finished "rm -rf other && git worktree prune" && + git worktree add --detach other && + test_corrupt_gitfile "rm -f corrupt/.git" ".git file broken" other +' + +test_expect_success 'repair .git file from bare.git' ' + test_when_finished "rm -rf bare.git corrupt && git worktree prune" && + git clone --bare . bare.git && + git -C bare.git worktree add --detach ../corrupt && + git -C corrupt rev-parse --absolute-git-dir >expect && + rm -f corrupt/.git && + git -C bare.git worktree repair && + git -C corrupt rev-parse --absolute-git-dir >actual && + test_cmp expect actual +' + +test_expect_success 'invalid worktree path' ' + test_must_fail git worktree repair /notvalid >out 2>err && + test_must_be_empty out && + test_i18ngrep "not a valid path" err +' + +test_expect_success 'repo not found; .git not file' ' + test_when_finished "rm -rf not-a-worktree" && + test_create_repo not-a-worktree && + test_must_fail git worktree repair not-a-worktree >out 2>err && + test_must_be_empty out && + test_i18ngrep ".git is not a file" err +' + +test_expect_success 'repo not found; .git file broken' ' + test_when_finished "rm -rf orig moved && git worktree prune" && + git worktree add --detach orig && + echo /invalid >orig/.git && + mv orig moved && + test_must_fail git worktree repair moved >out 2>err && + test_must_be_empty out && + test_i18ngrep ".git file broken" err +' + +test_expect_success 'repair broken gitdir' ' + test_when_finished "rm -rf orig moved && git worktree prune" && + git worktree add --detach orig && + sed s,orig/\.git$,moved/.git, .git/worktrees/orig/gitdir >expect && + rm .git/worktrees/orig/gitdir && + mv orig moved && + git worktree repair moved >out 2>err && + test_cmp expect .git/worktrees/orig/gitdir && + test_i18ngrep "gitdir unreadable" out && + test_must_be_empty err +' + +test_expect_success 'repair incorrect gitdir' ' + test_when_finished "rm -rf orig moved && git worktree prune" && + git worktree add --detach orig && + sed s,orig/\.git$,moved/.git, .git/worktrees/orig/gitdir >expect && + mv orig moved && + git worktree repair moved >out 2>err && + test_cmp expect .git/worktrees/orig/gitdir && + test_i18ngrep "gitdir incorrect" out && + test_must_be_empty err +' + +test_expect_success 'repair gitdir (implicit) from linked worktree' ' + test_when_finished "rm -rf orig moved && git worktree prune" && + git worktree add --detach orig && + sed s,orig/\.git$,moved/.git, .git/worktrees/orig/gitdir >expect && + mv orig moved && + git -C moved worktree repair >out 2>err && + test_cmp expect .git/worktrees/orig/gitdir && + test_i18ngrep "gitdir incorrect" out && + test_must_be_empty err +' + +test_expect_success 'unable to repair gitdir (implicit) from main worktree' ' + test_when_finished "rm -rf orig moved && git worktree prune" && + git worktree add --detach orig && + cat .git/worktrees/orig/gitdir >expect && + mv orig moved && + git worktree repair >out 2>err && + test_cmp expect .git/worktrees/orig/gitdir && + test_must_be_empty out && + test_must_be_empty err +' + +test_expect_success 'repair multiple gitdir files' ' + test_when_finished "rm -rf orig1 orig2 moved1 moved2 && + git worktree prune" && + git worktree add --detach orig1 && + git worktree add --detach orig2 && + sed s,orig1/\.git$,moved1/.git, .git/worktrees/orig1/gitdir >expect1 && + sed s,orig2/\.git$,moved2/.git, .git/worktrees/orig2/gitdir >expect2 && + mv orig1 moved1 && + mv orig2 moved2 && + git worktree repair moved1 moved2 >out 2>err && + test_cmp expect1 .git/worktrees/orig1/gitdir && + test_cmp expect2 .git/worktrees/orig2/gitdir && + test_i18ngrep "gitdir incorrect:.*orig1/gitdir$" out && + test_i18ngrep "gitdir incorrect:.*orig2/gitdir$" out && + test_must_be_empty err +' + +test_done diff --git a/t/t3422-rebase-incompatible-options.sh b/t/t3422-rebase-incompatible-options.sh index 50e7960702..c8234062c6 100755 --- a/t/t3422-rebase-incompatible-options.sh +++ b/t/t3422-rebase-incompatible-options.sh @@ -61,8 +61,6 @@ test_rebase_am_only () { } test_rebase_am_only --whitespace=fix -test_rebase_am_only --ignore-whitespace -test_rebase_am_only --committer-date-is-author-date test_rebase_am_only -C4 test_expect_success REBASE_P '--preserve-merges incompatible with --signoff' ' diff --git a/t/t3436-rebase-more-options.sh b/t/t3436-rebase-more-options.sh new file mode 100755 index 0000000000..996e82787e --- /dev/null +++ b/t/t3436-rebase-more-options.sh @@ -0,0 +1,180 @@ +#!/bin/sh +# +# Copyright (c) 2019 Rohit Ashiwal +# + +test_description='tests to ensure compatibility between am and interactive backends' + +. ./test-lib.sh + +. "$TEST_DIRECTORY"/lib-rebase.sh + +GIT_AUTHOR_DATE="1999-04-02T08:03:20+05:30" +export GIT_AUTHOR_DATE + +# This is a special case in which both am and interactive backends +# provide the same output. It was done intentionally because +# both the backends fall short of optimal behaviour. +test_expect_success 'setup' ' + git checkout -b topic && + test_write_lines "line 1" " line 2" "line 3" >file && + git add file && + git commit -m "add file" && + + test_write_lines "line 1" "new line 2" "line 3" >file && + git commit -am "update file" && + git tag side && + test_commit commit1 foo foo1 && + test_commit commit2 foo foo2 && + test_commit commit3 foo foo3 && + + git checkout --orphan master && + rm foo && + test_write_lines "line 1" " line 2" "line 3" >file && + git commit -am "add file" && + git tag main && + + mkdir test-bin && + write_script test-bin/git-merge-test <<-\EOF + exec git merge-recursive "$@" + EOF +' + +test_expect_success '--ignore-whitespace works with apply backend' ' + test_must_fail git rebase --apply main side && + git rebase --abort && + git rebase --apply --ignore-whitespace main side && + git diff --exit-code side +' + +test_expect_success '--ignore-whitespace works with merge backend' ' + test_must_fail git rebase --merge main side && + git rebase --abort && + git rebase --merge --ignore-whitespace main side && + git diff --exit-code side +' + +test_expect_success '--ignore-whitespace is remembered when continuing' ' + ( + set_fake_editor && + FAKE_LINES="break 1" git rebase -i --ignore-whitespace \ + main side && + git rebase --continue + ) && + git diff --exit-code side +' + +test_ctime_is_atime () { + git log $1 --format=%ai >authortime && + git log $1 --format=%ci >committertime && + test_cmp authortime committertime +} + +test_expect_success '--committer-date-is-author-date works with apply backend' ' + GIT_AUTHOR_DATE="@1234 +0300" git commit --amend --reset-author && + git rebase --apply --committer-date-is-author-date HEAD^ && + test_ctime_is_atime -1 +' + +test_expect_success '--committer-date-is-author-date works with merge backend' ' + GIT_AUTHOR_DATE="@1234 +0300" git commit --amend --reset-author && + git rebase -m --committer-date-is-author-date HEAD^ && + test_ctime_is_atime -1 +' + +test_expect_success '--committer-date-is-author-date works with rebase -r' ' + git checkout side && + GIT_AUTHOR_DATE="@1234 +0300" git merge --no-ff commit3 && + git rebase -r --root --committer-date-is-author-date && + test_ctime_is_atime +' + +test_expect_success '--committer-date-is-author-date works when forking merge' ' + git checkout side && + GIT_AUTHOR_DATE="@1234 +0300" git merge --no-ff commit3 && + PATH="./test-bin:$PATH" git rebase -r --root --strategy=test \ + --committer-date-is-author-date && + test_ctime_is_atime +' + +test_expect_success '--committer-date-is-author-date works when committing conflict resolution' ' + git checkout commit2 && + GIT_AUTHOR_DATE="@1980 +0000" git commit --amend --only --reset-author && + test_must_fail git rebase -m --committer-date-is-author-date \ + --onto HEAD^^ HEAD^ && + echo resolved > foo && + git add foo && + git rebase --continue && + test_ctime_is_atime -1 +' + +# Checking for +0000 in the author date is sufficient since the +# default timezone is UTC but the timezone used while committing is +# +0530. The inverted logic in the grep is necessary to check all the +# author dates in the file. +test_atime_is_ignored () { + git log $1 --format=%ai >authortime && + ! grep -v +0000 authortime +} + +test_expect_success '--reset-author-date works with apply backend' ' + git commit --amend --date="$GIT_AUTHOR_DATE" && + git rebase --apply --reset-author-date HEAD^ && + test_atime_is_ignored -1 +' + +test_expect_success '--reset-author-date works with merge backend' ' + git commit --amend --date="$GIT_AUTHOR_DATE" && + git rebase --reset-author-date -m HEAD^ && + test_atime_is_ignored -1 +' + +test_expect_success '--reset-author-date works after conflict resolution' ' + test_must_fail git rebase --reset-author-date -m \ + --onto commit2^^ commit2^ commit2 && + echo resolved >foo && + git add foo && + git rebase --continue && + test_atime_is_ignored -1 +' + +test_expect_success '--reset-author-date works with rebase -r' ' + git checkout side && + git merge --no-ff commit3 && + git rebase -r --root --reset-author-date && + test_atime_is_ignored +' + +test_expect_success '--reset-author-date with --committer-date-is-author-date works' ' + test_must_fail git rebase -m --committer-date-is-author-date \ + --reset-author-date --onto commit2^^ commit2^ commit3 && + git checkout --theirs foo && + git add foo && + git rebase --continue && + test_ctime_is_atime -2 && + test_atime_is_ignored -2 +' + +test_expect_success '--reset-author-date --committer-date-is-author-date works when forking merge' ' + GIT_SEQUENCE_EDITOR="echo \"merge -C $(git rev-parse HEAD) commit3\">" \ + PATH="./test-bin:$PATH" git rebase -i --strategy=test \ + --reset-author-date \ + --committer-date-is-author-date side side && + test_ctime_is_atime -1 && + test_atime_is_ignored -1 + ' + +test_expect_success '--ignore-date is an alias for --reset-author-date' ' + git commit --amend --date="$GIT_AUTHOR_DATE" && + git rebase --apply --ignore-date HEAD^ && + git commit --allow-empty -m empty --date="$GIT_AUTHOR_DATE" && + git rebase -m --ignore-date HEAD^ && + test_atime_is_ignored -2 +' + +# This must be the last test in this file +test_expect_success '$EDITOR and friends are unchanged' ' + test_editor_unchanged +' + +test_done diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index 5f97dd6d65..5c7b0122b4 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -130,27 +130,45 @@ test_expect_success setup ' EOF process_diffs () { - _x04="[0-9a-f][0-9a-f][0-9a-f][0-9a-f]" && - _x07="$_x05[0-9a-f][0-9a-f]" && - sed -e "s/$OID_REGEX/$ZERO_OID/g" \ - -e "s/From $_x40 /From $ZERO_OID /" \ - -e "s/from $_x40)/from $ZERO_OID)/" \ - -e "s/commit $_x40\$/commit $ZERO_OID/" \ - -e "s/commit $_x40 (/commit $ZERO_OID (/" \ - -e "s/$_x40 $_x40 $_x40/$ZERO_OID $ZERO_OID $ZERO_OID/" \ - -e "s/$_x40 $_x40 /$ZERO_OID $ZERO_OID /" \ - -e "s/^$_x40 $_x40$/$ZERO_OID $ZERO_OID/" \ - -e "s/^$_x40 /$ZERO_OID /" \ - -e "s/^$_x40$/$ZERO_OID/" \ - -e "s/$_x07\.\.$_x07/fffffff..fffffff/g" \ - -e "s/$_x07,$_x07\.\.$_x07/fffffff,fffffff..fffffff/g" \ - -e "s/$_x07 $_x07 $_x07/fffffff fffffff fffffff/g" \ - -e "s/$_x07 $_x07 /fffffff fffffff /g" \ - -e "s/Merge: $_x07 $_x07/Merge: fffffff fffffff/g" \ - -e "s/$_x07\.\.\./fffffff.../g" \ - -e "s/ $_x04\.\.\./ ffff.../g" \ - -e "s/ $_x04/ ffff/g" \ - "$1" + perl -e ' + my $oid_length = length($ARGV[0]); + my $x40 = "[0-9a-f]{40}"; + my $xab = "[0-9a-f]{4,16}"; + my $orx = "[0-9a-f]" x $oid_length; + + sub munge_oid { + my ($oid) = @_; + my $x; + + return "" unless length $oid; + + if ($oid =~ /^(100644|100755|120000)$/) { + return $oid; + } + + if ($oid =~ /^0*$/) { + $x = "0"; + } else { + $x = "f"; + } + + if (length($oid) == 40) { + return $x x $oid_length; + } else { + return $x x length($oid); + } + } + + while (<STDIN>) { + s/($orx)/munge_oid($1)/ge; + s/From ($x40)( |\))/"From " . munge_oid($1) . $2/ge; + s/commit ($x40)($| \(from )($x40?)/"commit " . munge_oid($1) . $2 . munge_oid($3)/ge; + s/\b($x40)( |\.\.|$)/munge_oid($1) . $2/ge; + s/^($x40)($| )/munge_oid($1) . $2/e; + s/($xab)(\.\.|,| |\.\.\.|$)/munge_oid($1) . $2/ge; + print; + } + ' "$ZERO_OID" <"$1" } V=$(git version | sed -e 's/^git version //' -e 's/\./\\./g') @@ -221,6 +239,9 @@ diff-tree --root -r --abbrev=4 initial :noellipses diff-tree --root -r --abbrev=4 initial diff-tree -p initial diff-tree --root -p initial +diff-tree --root -p --abbrev=10 initial +diff-tree --root -p --full-index initial +diff-tree --root -p --full-index --abbrev=10 initial diff-tree --patch-with-stat initial diff-tree --root --patch-with-stat initial diff-tree --patch-with-raw initial diff --git a/t/t4013/diff.diff-tree_--root_-p_--abbrev=10_initial b/t/t4013/diff.diff-tree_--root_-p_--abbrev=10_initial new file mode 100644 index 0000000000..7518a9044e --- /dev/null +++ b/t/t4013/diff.diff-tree_--root_-p_--abbrev=10_initial @@ -0,0 +1,29 @@ +$ git diff-tree --root -p --abbrev=10 initial +444ac553ac7612cc88969031b02b3767fb8a353a +diff --git a/dir/sub b/dir/sub +new file mode 100644 +index 0000000000..35d242ba79 +--- /dev/null ++++ b/dir/sub +@@ -0,0 +1,2 @@ ++A ++B +diff --git a/file0 b/file0 +new file mode 100644 +index 0000000000..01e79c32a8 +--- /dev/null ++++ b/file0 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +diff --git a/file2 b/file2 +new file mode 100644 +index 0000000000..01e79c32a8 +--- /dev/null ++++ b/file2 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +$ diff --git a/t/t4013/diff.diff-tree_--root_-p_--full-index_--abbrev=10_initial b/t/t4013/diff.diff-tree_--root_-p_--full-index_--abbrev=10_initial new file mode 100644 index 0000000000..69f913fbe5 --- /dev/null +++ b/t/t4013/diff.diff-tree_--root_-p_--full-index_--abbrev=10_initial @@ -0,0 +1,29 @@ +$ git diff-tree --root -p --full-index --abbrev=10 initial +444ac553ac7612cc88969031b02b3767fb8a353a +diff --git a/dir/sub b/dir/sub +new file mode 100644 +index 0000000000000000000000000000000000000000..35d242ba79ae89ac695e26b3d4c27a8e6f028f9e +--- /dev/null ++++ b/dir/sub +@@ -0,0 +1,2 @@ ++A ++B +diff --git a/file0 b/file0 +new file mode 100644 +index 0000000000000000000000000000000000000000..01e79c32a8c99c557f0757da7cb6d65b3414466d +--- /dev/null ++++ b/file0 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +diff --git a/file2 b/file2 +new file mode 100644 +index 0000000000000000000000000000000000000000..01e79c32a8c99c557f0757da7cb6d65b3414466d +--- /dev/null ++++ b/file2 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +$ diff --git a/t/t4013/diff.diff-tree_--root_-p_--full-index_initial b/t/t4013/diff.diff-tree_--root_-p_--full-index_initial new file mode 100644 index 0000000000..1b0b6717fa --- /dev/null +++ b/t/t4013/diff.diff-tree_--root_-p_--full-index_initial @@ -0,0 +1,29 @@ +$ git diff-tree --root -p --full-index initial +444ac553ac7612cc88969031b02b3767fb8a353a +diff --git a/dir/sub b/dir/sub +new file mode 100644 +index 0000000000000000000000000000000000000000..35d242ba79ae89ac695e26b3d4c27a8e6f028f9e +--- /dev/null ++++ b/dir/sub +@@ -0,0 +1,2 @@ ++A ++B +diff --git a/file0 b/file0 +new file mode 100644 +index 0000000000000000000000000000000000000000..01e79c32a8c99c557f0757da7cb6d65b3414466d +--- /dev/null ++++ b/file0 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +diff --git a/file2 b/file2 +new file mode 100644 +index 0000000000000000000000000000000000000000..01e79c32a8c99c557f0757da7cb6d65b3414466d +--- /dev/null ++++ b/file2 +@@ -0,0 +1,3 @@ ++1 ++2 ++3 +$ diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh index 88d3026894..8bdaa0a693 100755 --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@ -789,7 +789,7 @@ test_expect_success 'checkdiff allows new blank lines' ' git diff --check ' -test_expect_success 'whitespace-only changes not reported' ' +test_expect_success 'whitespace-only changes not reported (diff)' ' git reset --hard && echo >x "hello world" && git add x && @@ -799,10 +799,44 @@ test_expect_success 'whitespace-only changes not reported' ' test_must_be_empty actual ' -test_expect_success 'whitespace-only changes reported across renames' ' +test_expect_success 'whitespace-only changes not reported (diffstat)' ' + # reuse state from previous test + git diff --stat -b >actual && + test_must_be_empty actual +' + +test_expect_success 'whitespace changes with modification reported (diffstat)' ' + git reset --hard && + echo >x "hello world" && + git update-index --chmod=+x x && + git diff --stat --cached -b >actual && + cat <<-EOF >expect && + x | 0 + 1 file changed, 0 insertions(+), 0 deletions(-) + EOF + test_cmp expect actual +' + +test_expect_success 'whitespace-only changes reported across renames (diffstat)' ' 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 && + git commit -m "base" && + sed -e "5s/^/ /" x >z && + git rm x && + git add z && + git diff -w -M --cached --stat >actual && + cat <<-EOF >expect && + x => z | 0 + 1 file changed, 0 insertions(+), 0 deletions(-) + EOF + test_cmp expect actual +' + +test_expect_success 'whitespace-only changes reported across renames' ' + git reset --hard HEAD~1 && + for i in 1 2 3 4 5 6 7 8 9; do echo "$i$i$i$i$i$i"; done >x && + git add x && hash_x=$(git hash-object x) && before=$(git rev-parse --short "$hash_x") && git commit -m "base" && diff --git a/t/t4067-diff-partial-clone.sh b/t/t4067-diff-partial-clone.sh index ef8e0e9cb0..804f2a82e8 100755 --- a/t/t4067-diff-partial-clone.sh +++ b/t/t4067-diff-partial-clone.sh @@ -20,7 +20,7 @@ test_expect_success 'git show batches blobs' ' # Ensure that there is exactly 1 negotiation by checking that there is # only 1 "done" line sent. ("done" marks the end of negotiation.) GIT_TRACE_PACKET="$(pwd)/trace" git -C client show HEAD && - grep "git> done" trace >done_lines && + grep "fetch> done" trace >done_lines && test_line_count = 1 done_lines ' @@ -44,7 +44,7 @@ test_expect_success 'diff batches blobs' ' # Ensure that there is exactly 1 negotiation by checking that there is # only 1 "done" line sent. ("done" marks the end of negotiation.) GIT_TRACE_PACKET="$(pwd)/trace" git -C client diff HEAD^ HEAD && - grep "git> done" trace >done_lines && + grep "fetch> done" trace >done_lines && test_line_count = 1 done_lines ' @@ -127,7 +127,7 @@ test_expect_success 'diff with rename detection batches blobs' ' # only 1 "done" line sent. ("done" marks the end of negotiation.) GIT_TRACE_PACKET="$(pwd)/trace" git -C client diff --raw -M HEAD^ HEAD >out && grep ":100644 100644.*R[0-9][0-9][0-9].*b.*c" out && - grep "git> done" trace >done_lines && + grep "fetch> done" trace >done_lines && test_line_count = 1 done_lines ' @@ -175,7 +175,7 @@ test_expect_success 'diff --break-rewrites fetches only if necessary, and batche # by checking that there is only 1 "done" line sent. ("done" marks the # end of negotiation.) GIT_TRACE_PACKET="$(pwd)/trace" git -C client diff --break-rewrites --raw -M HEAD^ HEAD && - grep "git> done" trace >done_lines && + grep "fetch> done" trace >done_lines && test_line_count = 1 done_lines ' diff --git a/t/t4202-log.sh b/t/t4202-log.sh index a0930599aa..56d34ed465 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -1850,6 +1850,16 @@ test_expect_success 'log does not default to HEAD when rev input is given' ' test_must_be_empty actual ' +test_expect_success 'do not default to HEAD with ignored object on cmdline' ' + git log --ignore-missing $ZERO_OID >actual && + test_must_be_empty actual +' + +test_expect_success 'do not default to HEAD with ignored object on stdin' ' + echo $ZERO_OID | git log --ignore-missing --stdin >actual && + test_must_be_empty actual +' + test_expect_success 'set up --source tests' ' git checkout --orphan source-a && test_commit one && diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh index 3d6a93343a..392201cabd 100755 --- a/t/t5300-pack-object.sh +++ b/t/t5300-pack-object.sh @@ -528,7 +528,7 @@ test_expect_success 'prefetch objects' ' TWO=$(git -C server rev-parse three_branch^) && git -C client fetch --filter=blob:none origin "$TWO" && GIT_TRACE_PACKET=$(pwd)/trace git -C client push origin "$TWO":refs/heads/two_branch && - grep "git> done" trace >donelines && + grep "fetch> done" trace >donelines && test_line_count = 1 donelines ' diff --git a/t/t5319-multi-pack-index.sh b/t/t5319-multi-pack-index.sh index 43b1b5b2af..f340b376bc 100755 --- a/t/t5319-multi-pack-index.sh +++ b/t/t5319-multi-pack-index.sh @@ -382,12 +382,52 @@ test_expect_success 'repack with the --no-progress option' ' test_line_count = 0 err ' -test_expect_success 'repack removes multi-pack-index' ' +test_expect_success 'repack removes multi-pack-index when deleting packs' ' test_path_is_file $objdir/pack/multi-pack-index && - GIT_TEST_MULTI_PACK_INDEX=0 git repack -adf && + # Set GIT_TEST_MULTI_PACK_INDEX to 0 to avoid writing a new + # multi-pack-index after repacking, but set "core.multiPackIndex" to + # true so that "git repack" can read the existing MIDX. + GIT_TEST_MULTI_PACK_INDEX=0 git -c core.multiPackIndex repack -adf && test_path_is_missing $objdir/pack/multi-pack-index ' +test_expect_success 'repack preserves multi-pack-index when creating packs' ' + git init preserve && + test_when_finished "rm -fr preserve" && + ( + cd preserve && + packdir=.git/objects/pack && + midx=$packdir/multi-pack-index && + + test_commit 1 && + pack1=$(git pack-objects --all $packdir/pack) && + touch $packdir/pack-$pack1.keep && + test_commit 2 && + pack2=$(git pack-objects --revs $packdir/pack) && + touch $packdir/pack-$pack2.keep && + + git multi-pack-index write && + cp $midx $midx.bak && + + cat >pack-input <<-EOF && + HEAD + ^HEAD~1 + EOF + test_commit 3 && + pack3=$(git pack-objects --revs $packdir/pack <pack-input) && + test_commit 4 && + pack4=$(git pack-objects --revs $packdir/pack <pack-input) && + + GIT_TEST_MULTI_PACK_INDEX=0 git -c core.multiPackIndex repack -ad && + ls -la $packdir && + test_path_is_file $packdir/pack-$pack1.pack && + test_path_is_file $packdir/pack-$pack2.pack && + test_path_is_missing $packdir/pack-$pack3.pack && + test_path_is_missing $packdir/pack-$pack4.pack && + test_cmp_bin $midx.bak $midx + ) +' + compare_results_with_midx "after repack" test_expect_success 'multi-pack-index and pack-bitmap' ' diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index 2a1abe91f0..759aec9305 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -543,16 +543,18 @@ test_expect_success 'fetch into the current branch with --update-head-ok' ' ' -test_expect_success 'fetch --dry-run does not touch FETCH_HEAD' ' - rm -f .git/FETCH_HEAD && - git fetch --dry-run . && - ! test -f .git/FETCH_HEAD +test_expect_success 'fetch --dry-run does not touch FETCH_HEAD, but still prints what would be written' ' + rm -f .git/FETCH_HEAD err && + git fetch --dry-run . 2>err && + ! test -f .git/FETCH_HEAD && + grep FETCH_HEAD err ' -test_expect_success '--no-write-fetch-head does not touch FETCH_HEAD' ' - rm -f .git/FETCH_HEAD && - git fetch --no-write-fetch-head . && - ! test -f .git/FETCH_HEAD +test_expect_success '--no-write-fetch-head does not touch FETCH_HEAD, and does not print what would be written' ' + rm -f .git/FETCH_HEAD err && + git fetch --no-write-fetch-head . 2>err && + ! test -f .git/FETCH_HEAD && + ! grep FETCH_HEAD err ' test_expect_success '--write-fetch-head gets defeated by --dry-run' ' diff --git a/t/t5554-noop-fetch-negotiator.sh b/t/t5554-noop-fetch-negotiator.sh new file mode 100755 index 0000000000..2ac7b5859e --- /dev/null +++ b/t/t5554-noop-fetch-negotiator.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +test_description='test noop fetch negotiator' +. ./test-lib.sh + +test_expect_success 'noop negotiator does not emit any "have"' ' + rm -f trace && + + test_create_repo server && + test_commit -C server to_fetch && + + test_create_repo client && + test_commit -C client we_have && + + test_config -C client fetch.negotiationalgorithm noop && + GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch "$(pwd)/server" && + + ! grep "fetch> have" trace && + grep "fetch> done" trace +' + +test_done diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh index eb9a093e25..15fb64c18d 100755 --- a/t/t5601-clone.sh +++ b/t/t5601-clone.sh @@ -704,7 +704,7 @@ test_expect_success 'batch missing blob request during checkout' ' # Ensure that there is only one negotiation by checking that there is # only "done" line sent. ("done" marks the end of negotiation.) GIT_TRACE_PACKET="$(pwd)/trace" git -C client checkout HEAD^ && - grep "git> done" trace >done_lines && + grep "fetch> done" trace >done_lines && test_line_count = 1 done_lines ' diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh index 8827c2ed18..f4d49d8335 100755 --- a/t/t5616-partial-clone.sh +++ b/t/t5616-partial-clone.sh @@ -163,6 +163,22 @@ test_expect_success 'manual prefetch of missing objects' ' test_line_count = 0 observed.oids ' +test_expect_success 'partial clone with transfer.fsckobjects=1 works with submodules' ' + test_create_repo submodule && + test_commit -C submodule mycommit && + + test_create_repo src_with_sub && + test_config -C src_with_sub uploadpack.allowfilter 1 && + test_config -C src_with_sub uploadpack.allowanysha1inwant 1 && + + git -C src_with_sub submodule add "file://$(pwd)/submodule" mysub && + git -C src_with_sub commit -m "commit with submodule" && + + git -c transfer.fsckobjects=1 \ + clone --filter="blob:none" "file://$(pwd)/src_with_sub" dst && + test_when_finished rm -rf dst +' + test_expect_success 'partial clone with transfer.fsckobjects=1 uses index-pack --fsck-objects' ' git init src && test_commit -C src x && @@ -417,6 +433,26 @@ test_expect_success 'fetch lazy-fetches only to resolve deltas, protocol v2' ' grep "want $(cat hash)" trace ' +test_expect_success 'fetch does not lazy-fetch missing targets of its refs' ' + rm -rf server client trace && + + test_create_repo server && + test_config -C server uploadpack.allowfilter 1 && + test_config -C server uploadpack.allowanysha1inwant 1 && + test_commit -C server foo && + + git clone --filter=blob:none "file://$(pwd)/server" client && + # Make all refs point to nothing by deleting all objects. + rm client/.git/objects/pack/* && + + test_commit -C server bar && + GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch \ + --no-tags --recurse-submodules=no \ + origin refs/tags/bar && + FOO_HASH=$(git -C server rev-parse foo) && + ! grep "want $FOO_HASH" trace +' + # The following two tests must be in this order. It is important that # the srv.bare repository did not have tags during clone, but has tags # in the fetch. diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh index 5a60fbe3ed..7d5b17909b 100755 --- a/t/t5702-protocol-v2.sh +++ b/t/t5702-protocol-v2.sh @@ -883,6 +883,59 @@ test_expect_success 'fetching with valid packfile URI but invalid hash fails' ' test_i18ngrep "pack downloaded from.*does not match expected hash" err ' +test_expect_success 'packfile-uri with transfer.fsckobjects' ' + P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" && + rm -rf "$P" http_child log && + + git init "$P" && + git -C "$P" config "uploadpack.allowsidebandall" "true" && + + echo my-blob >"$P/my-blob" && + git -C "$P" add my-blob && + git -C "$P" commit -m x && + + configure_exclusion "$P" my-blob >h && + + sane_unset GIT_TEST_SIDEBAND_ALL && + git -c protocol.version=2 -c transfer.fsckobjects=1 \ + -c fetch.uriprotocols=http,https \ + clone "$HTTPD_URL/smart/http_parent" http_child && + + # Ensure that there are exactly 4 files (2 .pack and 2 .idx). + ls http_child/.git/objects/pack/* >filelist && + test_line_count = 4 filelist +' + +test_expect_success 'packfile-uri with transfer.fsckobjects fails on bad object' ' + P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" && + rm -rf "$P" http_child log && + + git init "$P" && + git -C "$P" config "uploadpack.allowsidebandall" "true" && + + cat >bogus-commit <<-EOF && + tree $EMPTY_TREE + author Bugs Bunny 1234567890 +0000 + committer Bugs Bunny <bugs@bun.ni> 1234567890 +0000 + + This commit object intentionally broken + EOF + BOGUS=$(git -C "$P" hash-object -t commit -w --stdin <bogus-commit) && + git -C "$P" branch bogus-branch "$BOGUS" && + + echo my-blob >"$P/my-blob" && + git -C "$P" add my-blob && + git -C "$P" commit -m x && + + configure_exclusion "$P" my-blob >h && + + sane_unset GIT_TEST_SIDEBAND_ALL && + test_must_fail git -c protocol.version=2 -c transfer.fsckobjects=1 \ + -c fetch.uriprotocols=http,https \ + clone "$HTTPD_URL/smart/http_parent" http_child 2>error && + test_i18ngrep "invalid author/committer line - missing email" error +' + # DO NOT add non-httpd-specific tests here, because the last part of this # test script is only executed when httpd is available and enabled. diff --git a/t/t6018-rev-list-glob.sh b/t/t6018-rev-list-glob.sh index bb5aeac07f..b31ff7eeec 100755 --- a/t/t6018-rev-list-glob.sh +++ b/t/t6018-rev-list-glob.sh @@ -345,6 +345,11 @@ test_expect_success 'rev-list should succeed with empty output with empty glob' test_must_be_empty actual ' +test_expect_success 'rev-list should succeed with empty output when ignoring missing' ' + git rev-list --ignore-missing $ZERO_OID >actual && + test_must_be_empty actual +' + test_expect_success 'shortlog accepts --glob/--tags/--remotes' ' compare shortlog "subspace/one subspace/two" --branches=subspace && diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh index a83579fbdf..b359023189 100755 --- a/t/t6300-for-each-ref.sh +++ b/t/t6300-for-each-ref.sh @@ -116,7 +116,13 @@ test_atom head objectname:short $(git rev-parse --short refs/heads/master) test_atom head objectname:short=1 $(git rev-parse --short=1 refs/heads/master) test_atom head objectname:short=10 $(git rev-parse --short=10 refs/heads/master) test_atom head tree $(git rev-parse refs/heads/master^{tree}) +test_atom head tree:short $(git rev-parse --short refs/heads/master^{tree}) +test_atom head tree:short=1 $(git rev-parse --short=1 refs/heads/master^{tree}) +test_atom head tree:short=10 $(git rev-parse --short=10 refs/heads/master^{tree}) test_atom head parent '' +test_atom head parent:short '' +test_atom head parent:short=1 '' +test_atom head parent:short=10 '' test_atom head numparent 0 test_atom head object '' test_atom head type '' @@ -125,19 +131,26 @@ test_atom head '*objecttype' '' test_atom head author 'A U Thor <author@example.com> 1151968724 +0200' test_atom head authorname 'A U Thor' test_atom head authoremail '<author@example.com>' +test_atom head authoremail:trim 'author@example.com' +test_atom head authoremail:localpart 'author' test_atom head authordate 'Tue Jul 4 01:18:44 2006 +0200' test_atom head committer 'C O Mitter <committer@example.com> 1151968723 +0200' test_atom head committername 'C O Mitter' test_atom head committeremail '<committer@example.com>' +test_atom head committeremail:trim 'committer@example.com' +test_atom head committeremail:localpart 'committer' test_atom head committerdate 'Tue Jul 4 01:18:43 2006 +0200' test_atom head tag '' test_atom head tagger '' test_atom head taggername '' test_atom head taggeremail '' +test_atom head taggeremail:trim '' +test_atom head taggeremail:localpart '' test_atom head taggerdate '' test_atom head creator 'C O Mitter <committer@example.com> 1151968723 +0200' test_atom head creatordate 'Tue Jul 4 01:18:43 2006 +0200' test_atom head subject 'Initial' +test_atom head subject:sanitize 'Initial' test_atom head contents:subject 'Initial' test_atom head body '' test_atom head contents:body '' @@ -161,7 +174,13 @@ test_atom tag objectname:short $(git rev-parse --short refs/tags/testtag) test_atom head objectname:short=1 $(git rev-parse --short=1 refs/heads/master) test_atom head objectname:short=10 $(git rev-parse --short=10 refs/heads/master) test_atom tag tree '' +test_atom tag tree:short '' +test_atom tag tree:short=1 '' +test_atom tag tree:short=10 '' test_atom tag parent '' +test_atom tag parent:short '' +test_atom tag parent:short=1 '' +test_atom tag parent:short=10 '' test_atom tag numparent '' test_atom tag object $(git rev-parse refs/tags/testtag^0) test_atom tag type 'commit' @@ -170,19 +189,26 @@ test_atom tag '*objecttype' 'commit' test_atom tag author '' test_atom tag authorname '' test_atom tag authoremail '' +test_atom tag authoremail:trim '' +test_atom tag authoremail:localpart '' test_atom tag authordate '' test_atom tag committer '' test_atom tag committername '' test_atom tag committeremail '' +test_atom tag committeremail:trim '' +test_atom tag committeremail:localpart '' test_atom tag committerdate '' test_atom tag tag 'testtag' test_atom tag tagger 'C O Mitter <committer@example.com> 1151968725 +0200' test_atom tag taggername 'C O Mitter' test_atom tag taggeremail '<committer@example.com>' +test_atom tag taggeremail:trim 'committer@example.com' +test_atom tag taggeremail:localpart 'committer' test_atom tag taggerdate 'Tue Jul 4 01:18:45 2006 +0200' test_atom tag creator 'C O Mitter <committer@example.com> 1151968725 +0200' test_atom tag creatordate 'Tue Jul 4 01:18:45 2006 +0200' test_atom tag subject 'Tagging at 1151968727' +test_atom tag subject:sanitize 'Tagging-at-1151968727' test_atom tag contents:subject 'Tagging at 1151968727' test_atom tag body '' test_atom tag contents:body '' @@ -564,10 +590,14 @@ test_atom refs/tags/taggerless tag 'taggerless' test_atom refs/tags/taggerless tagger '' test_atom refs/tags/taggerless taggername '' test_atom refs/tags/taggerless taggeremail '' +test_atom refs/tags/taggerless taggeremail:trim '' +test_atom refs/tags/taggerless taggeremail:localpart '' test_atom refs/tags/taggerless taggerdate '' test_atom refs/tags/taggerless committer '' test_atom refs/tags/taggerless committername '' test_atom refs/tags/taggerless committeremail '' +test_atom refs/tags/taggerless committeremail:trim '' +test_atom refs/tags/taggerless committeremail:localpart '' test_atom refs/tags/taggerless committerdate '' test_atom refs/tags/taggerless subject 'Broken tag' @@ -591,6 +621,7 @@ test_expect_success 'create tag with subject and body content' ' git tag -F msg subject-body ' test_atom refs/tags/subject-body subject 'the subject line' +test_atom refs/tags/subject-body subject:sanitize 'the-subject-line' test_atom refs/tags/subject-body body 'first body line second body line ' @@ -611,6 +642,7 @@ test_expect_success 'create tag with multiline subject' ' git tag -F msg multiline ' test_atom refs/tags/multiline subject 'first subject line second subject line' +test_atom refs/tags/multiline subject:sanitize 'first-subject-line-second-subject-line' test_atom refs/tags/multiline contents:subject 'first subject line second subject line' test_atom refs/tags/multiline body 'first body line second body line @@ -643,6 +675,7 @@ sig='-----BEGIN PGP SIGNATURE----- PREREQ=GPG test_atom refs/tags/signed-empty subject '' +test_atom refs/tags/signed-empty subject:sanitize '' test_atom refs/tags/signed-empty contents:subject '' test_atom refs/tags/signed-empty body "$sig" test_atom refs/tags/signed-empty contents:body '' @@ -650,6 +683,7 @@ test_atom refs/tags/signed-empty contents:signature "$sig" test_atom refs/tags/signed-empty contents "$sig" test_atom refs/tags/signed-short subject 'subject line' +test_atom refs/tags/signed-short subject:sanitize 'subject-line' test_atom refs/tags/signed-short contents:subject 'subject line' test_atom refs/tags/signed-short body "$sig" test_atom refs/tags/signed-short contents:body '' @@ -658,6 +692,7 @@ test_atom refs/tags/signed-short contents "subject line $sig" test_atom refs/tags/signed-long subject 'subject line' +test_atom refs/tags/signed-long subject:sanitize 'subject-line' test_atom refs/tags/signed-long contents:subject 'subject line' test_atom refs/tags/signed-long body "body contents $sig" @@ -776,61 +811,40 @@ test_expect_success 'set up trailers for next test' ' ' test_expect_success '%(trailers:unfold) unfolds trailers' ' - git for-each-ref --format="%(trailers:unfold)" refs/heads/master >actual && { unfold <trailers echo } >expect && + git for-each-ref --format="%(trailers:unfold)" refs/heads/master >actual && + test_cmp expect actual && + git for-each-ref --format="%(contents:trailers:unfold)" refs/heads/master >actual && test_cmp expect actual ' test_expect_success '%(trailers:only) shows only "key: value" trailers' ' - git for-each-ref --format="%(trailers:only)" refs/heads/master >actual && { grep -v patch.description <trailers && echo } >expect && + git for-each-ref --format="%(trailers:only)" refs/heads/master >actual && + test_cmp expect actual && + git for-each-ref --format="%(contents:trailers:only)" refs/heads/master >actual && test_cmp expect actual ' test_expect_success '%(trailers:only) and %(trailers:unfold) work together' ' - git for-each-ref --format="%(trailers:only,unfold)" refs/heads/master >actual && - git for-each-ref --format="%(trailers:unfold,only)" refs/heads/master >reverse && - test_cmp actual reverse && { grep -v patch.description <trailers | unfold && echo } >expect && - test_cmp expect actual -' - -test_expect_success '%(contents:trailers:unfold) unfolds trailers' ' - git for-each-ref --format="%(contents:trailers:unfold)" refs/heads/master >actual && - { - unfold <trailers - echo - } >expect && - test_cmp expect actual -' - -test_expect_success '%(contents:trailers:only) shows only "key: value" trailers' ' - git for-each-ref --format="%(contents:trailers:only)" refs/heads/master >actual && - { - grep -v patch.description <trailers && - echo - } >expect && - test_cmp expect actual -' - -test_expect_success '%(contents:trailers:only) and %(contents:trailers:unfold) work together' ' + git for-each-ref --format="%(trailers:only,unfold)" refs/heads/master >actual && + test_cmp expect actual && + git for-each-ref --format="%(trailers:unfold,only)" refs/heads/master >actual && + test_cmp actual actual && git for-each-ref --format="%(contents:trailers:only,unfold)" refs/heads/master >actual && - git for-each-ref --format="%(contents:trailers:unfold,only)" refs/heads/master >reverse && - test_cmp actual reverse && - { - grep -v patch.description <trailers | unfold && - echo - } >expect && - test_cmp expect actual + test_cmp expect actual && + git for-each-ref --format="%(contents:trailers:unfold,only)" refs/heads/master >actual && + test_cmp actual actual ' test_expect_success '%(trailers) rejects unknown trailers arguments' ' @@ -839,15 +853,16 @@ test_expect_success '%(trailers) rejects unknown trailers arguments' ' fatal: unknown %(trailers) argument: unsupported EOF test_must_fail git for-each-ref --format="%(trailers:unsupported)" 2>actual && + test_i18ncmp expect actual && + test_must_fail git for-each-ref --format="%(contents:trailers:unsupported)" 2>actual && test_i18ncmp expect actual ' -test_expect_success '%(contents:trailers) rejects unknown trailers arguments' ' - # error message cannot be checked under i18n +test_expect_success 'if arguments, %(contents:trailers) shows error if colon is missing' ' cat >expect <<-EOF && - fatal: unknown %(trailers) argument: unsupported + fatal: unrecognized %(contents) argument: trailersonly EOF - test_must_fail git for-each-ref --format="%(contents:trailers:unsupported)" 2>actual && + test_must_fail git for-each-ref --format="%(contents:trailersonly)" 2>actual && test_i18ncmp expect actual ' diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh index 9bc841d085..7608814708 100755 --- a/t/t7401-submodule-summary.sh +++ b/t/t7401-submodule-summary.sh @@ -5,9 +5,18 @@ test_description='Summary support for submodules -This test tries to verify the sanity of summary subcommand of git submodule. +This test script tries to verify the sanity of summary subcommand of git submodule. ' +# NOTE: This test script uses 'git add' instead of 'git submodule add' to add +# submodules to the superproject. Some submodule subcommands such as init and +# deinit might not work as expected in this script. t7421 does not have this +# caveat. +# +# NEEDSWORK: This test script is old fashioned and may need a big cleanup due to +# various reasons, one of them being that there are lots of commands taking place +# outside of 'test_expect_success' block, which is no longer in good-style. + . ./test-lib.sh add_file () { @@ -16,12 +25,12 @@ add_file () { owd=$(pwd) cd "$sm" for name; do - echo "$name" > "$name" && + echo "$name" >"$name" && git add "$name" && test_tick && git commit -m "Add $name" done >/dev/null - git rev-parse --verify HEAD | cut -c1-7 + git rev-parse --short HEAD cd "$owd" } commit_file () { @@ -38,10 +47,10 @@ test_expect_success 'added submodule' " git add sm1 && git submodule summary >actual && cat >expected <<-EOF && -* sm1 0000000...$head1 (2): - > Add foo2 + * sm1 0000000...$head1 (2): + > Add foo2 -EOF + EOF test_cmp expected actual " @@ -52,10 +61,10 @@ test_expect_success 'added submodule (subdirectory)' " git submodule summary >../actual ) && cat >expected <<-EOF && -* ../sm1 0000000...$head1 (2): - > Add foo2 + * ../sm1 0000000...$head1 (2): + > Add foo2 -EOF + EOF test_cmp expected actual " @@ -73,10 +82,10 @@ test_expect_success 'added submodule (subdirectory with explicit path)' " git submodule summary ../sm1 >../actual ) && cat >expected <<-EOF && -* ../sm1 0000000...$head1 (2): - > Add foo2 + * ../sm1 0000000...$head1 (2): + > Add foo2 -EOF + EOF test_cmp expected actual " @@ -86,20 +95,20 @@ head2=$(add_file sm1 foo3) test_expect_success 'modified submodule(forward)' " git submodule summary >actual && cat >expected <<-EOF && -* sm1 $head1...$head2 (1): - > Add foo3 + * sm1 $head1...$head2 (1): + > Add foo3 -EOF + EOF test_cmp expected actual " test_expect_success 'modified submodule(forward), --files' " git submodule summary --files >actual && cat >expected <<-EOF && -* sm1 $head1...$head2 (1): - > Add foo3 + * sm1 $head1...$head2 (1): + > Add foo3 -EOF + EOF test_cmp expected actual " @@ -110,10 +119,10 @@ test_expect_success 'no ignore=all setting has any effect' " git config diff.ignoreSubmodules all && git submodule summary >actual && cat >expected <<-EOF && -* sm1 $head1...$head2 (1): - > Add foo3 + * sm1 $head1...$head2 (1): + > Add foo3 -EOF + EOF test_cmp expected actual && git config --unset diff.ignoreSubmodules && git config --remove-section submodule.sm1 && @@ -125,17 +134,17 @@ commit_file sm1 && head3=$( cd sm1 && git reset --hard HEAD~2 >/dev/null && - git rev-parse --verify HEAD | cut -c1-7 + git rev-parse --short HEAD ) test_expect_success 'modified submodule(backward)' " git submodule summary >actual && cat >expected <<-EOF && -* sm1 $head2...$head3 (2): - < Add foo3 - < Add foo2 + * sm1 $head2...$head3 (2): + < Add foo3 + < Add foo2 -EOF + EOF test_cmp expected actual " @@ -144,25 +153,25 @@ head4_full=$(GIT_DIR=sm1/.git git rev-parse --verify HEAD) test_expect_success 'modified submodule(backward and forward)' " git submodule summary >actual && cat >expected <<-EOF && -* sm1 $head2...$head4 (4): - > Add foo5 - > Add foo4 - < Add foo3 - < Add foo2 + * sm1 $head2...$head4 (4): + > Add foo5 + > Add foo4 + < Add foo3 + < Add foo2 -EOF + EOF test_cmp expected actual " test_expect_success '--summary-limit' " git submodule summary -n 3 >actual && cat >expected <<-EOF && -* sm1 $head2...$head4 (4): - > Add foo5 - > Add foo4 - < Add foo3 + * sm1 $head2...$head4 (4): + > Add foo5 + > Add foo4 + < Add foo3 -EOF + EOF test_cmp expected actual " @@ -177,21 +186,21 @@ mv sm1-bak sm1 test_expect_success 'typechanged submodule(submodule->blob), --cached' " git submodule summary --cached >actual && cat >expected <<-EOF && -* sm1 $head4(submodule)->$head5(blob) (3): - < Add foo5 + * sm1 $head4(submodule)->$head5(blob) (3): + < Add foo5 -EOF - test_i18ncmp actual expected + EOF + test_i18ncmp expected actual " test_expect_success 'typechanged submodule(submodule->blob), --files' " git submodule summary --files >actual && cat >expected <<-EOF && -* sm1 $head5(blob)->$head4(submodule) (3): - > Add foo5 + * sm1 $head5(blob)->$head4(submodule) (3): + > Add foo5 -EOF - test_i18ncmp actual expected + EOF + test_i18ncmp expected actual " rm -rf sm1 && @@ -199,10 +208,10 @@ git checkout-index sm1 test_expect_success 'typechanged submodule(submodule->blob)' " git submodule summary >actual && cat >expected <<-EOF && -* sm1 $head4(submodule)->$head5(blob): + * sm1 $head4(submodule)->$head5(blob): -EOF - test_i18ncmp actual expected + EOF + test_i18ncmp expected actual " rm -f sm1 && @@ -211,21 +220,21 @@ head6=$(add_file sm1 foo6 foo7) test_expect_success 'nonexistent commit' " git submodule summary >actual && cat >expected <<-EOF && -* sm1 $head4...$head6: - Warn: sm1 doesn't contain commit $head4_full + * sm1 $head4...$head6: + Warn: sm1 doesn't contain commit $head4_full -EOF - test_i18ncmp actual expected + EOF + test_i18ncmp expected actual " commit_file test_expect_success 'typechanged submodule(blob->submodule)' " git submodule summary >actual && cat >expected <<-EOF && -* sm1 $head5(blob)->$head6(submodule) (2): - > Add foo7 + * sm1 $head5(blob)->$head6(submodule) (2): + > Add foo7 -EOF + EOF test_i18ncmp expected actual " @@ -234,9 +243,9 @@ rm -rf sm1 test_expect_success 'deleted submodule' " git submodule summary >actual && cat >expected <<-EOF && -* sm1 $head6...0000000: + * sm1 $head6...0000000: -EOF + EOF test_cmp expected actual " @@ -249,22 +258,22 @@ test_expect_success 'create second submodule' ' test_expect_success 'multiple submodules' " git submodule summary >actual && cat >expected <<-EOF && -* sm1 $head6...0000000: + * sm1 $head6...0000000: -* sm2 0000000...$head7 (2): - > Add foo9 + * sm2 0000000...$head7 (2): + > Add foo9 -EOF + EOF test_cmp expected actual " test_expect_success 'path filter' " git submodule summary sm2 >actual && cat >expected <<-EOF && -* sm2 0000000...$head7 (2): - > Add foo9 + * sm2 0000000...$head7 (2): + > Add foo9 -EOF + EOF test_cmp expected actual " @@ -272,24 +281,24 @@ commit_file sm2 test_expect_success 'given commit' " git submodule summary HEAD^ >actual && cat >expected <<-EOF && -* sm1 $head6...0000000: + * sm1 $head6...0000000: -* sm2 0000000...$head7 (2): - > Add foo9 + * sm2 0000000...$head7 (2): + > Add foo9 -EOF + EOF test_cmp expected actual " test_expect_success '--for-status' " git submodule summary --for-status HEAD^ >actual && - test_i18ncmp actual - <<EOF -* sm1 $head6...0000000: + test_i18ncmp - actual <<-EOF + * sm1 $head6...0000000: -* sm2 0000000...$head7 (2): - > Add foo9 + * sm2 0000000...$head7 (2): + > Add foo9 -EOF + EOF " test_expect_success 'fail when using --files together with --cached' " diff --git a/t/t7421-submodule-summary-add.sh b/t/t7421-submodule-summary-add.sh new file mode 100755 index 0000000000..b070f13714 --- /dev/null +++ b/t/t7421-submodule-summary-add.sh @@ -0,0 +1,69 @@ +#!/bin/sh +# +# Copyright (C) 2020 Shourya Shukla +# + +test_description='Summary support for submodules, adding them using git submodule add + +This test script tries to verify the sanity of summary subcommand of git submodule +while making sure to add submodules using `git submodule add` instead of +`git add` as done in t7401. +' + +. ./test-lib.sh + +test_expect_success 'summary test environment setup' ' + git init sm && + test_commit -C sm "add file" file file-content file-tag && + + git submodule add ./sm my-subm && + test_tick && + git commit -m "add submodule" +' + +test_expect_success 'submodule summary output for initialized submodule' ' + test_commit -C sm "add file2" file2 file2-content file2-tag && + git submodule update --remote && + test_tick && + git commit -m "update submodule" my-subm && + git submodule summary HEAD^ >actual && + rev1=$(git -C sm rev-parse --short HEAD^) && + rev2=$(git -C sm rev-parse --short HEAD) && + cat >expected <<-EOF && + * my-subm ${rev1}...${rev2} (1): + > add file2 + + EOF + test_cmp expected actual +' + +test_expect_success 'submodule summary output for deinitialized submodule' ' + git submodule deinit my-subm && + git submodule summary HEAD^ >actual && + test_must_be_empty actual && + git submodule update --init my-subm && + git submodule summary HEAD^ >actual && + rev1=$(git -C sm rev-parse --short HEAD^) && + rev2=$(git -C sm rev-parse --short HEAD) && + cat >expected <<-EOF && + * my-subm ${rev1}...${rev2} (1): + > add file2 + + EOF + test_cmp expected actual +' + +test_expect_success 'submodule summary output for submodules with changed paths' ' + git mv my-subm subm && + git commit -m "change submodule path" && + rev=$(git -C sm rev-parse --short HEAD^) && + git submodule summary HEAD^^ -- my-subm >actual 2>err && + test_must_be_empty err && + cat >expected <<-EOF && + * my-subm ${rev}...0000000: + + EOF + test_cmp expected actual +' + +test_done diff --git a/t/t7518-ident-corner-cases.sh b/t/t7518-ident-corner-cases.sh index b22f631261..dc3e9c8c88 100755 --- a/t/t7518-ident-corner-cases.sh +++ b/t/t7518-ident-corner-cases.sh @@ -29,7 +29,18 @@ test_expect_success 'empty configured name does not auto-detect' ' sane_unset GIT_AUTHOR_NAME && test_must_fail \ git -c user.name= commit --allow-empty -m foo 2>err && - test_i18ngrep "empty ident name" err + test_i18ngrep "empty ident name" err && + test_i18ngrep "Author identity unknown" err + ) +' + +test_expect_success 'empty configured name does not auto-detect for committer' ' + ( + sane_unset GIT_COMMITTER_NAME && + test_must_fail \ + git -c user.name= commit --allow-empty -m foo 2>err && + test_i18ngrep "empty ident name" err && + test_i18ngrep "Committer identity unknown" err ) ' diff --git a/t/t9010-svn-fe.sh b/t/t9010-svn-fe.sh deleted file mode 100755 index 83f8f5cacb..0000000000 --- a/t/t9010-svn-fe.sh +++ /dev/null @@ -1,1105 +0,0 @@ -#!/bin/sh - -test_description='check svn dumpfile importer' - -. ./test-lib.sh - -if test_have_prereq !PIPE -then - skip_all="svn dumpfile importer testing requires the PIPE prerequisite" - test_done -fi - -reinit_git () { - rm -fr .git && - rm -f stream backflow && - git init && - mkfifo stream backflow -} - -try_dump () { - input=$1 && - maybe_fail_svnfe=${2:+test_$2} && - maybe_fail_fi=${3:+test_$3} && - - { - $maybe_fail_svnfe test-svn-fe "$input" >stream 3<backflow & - } && - $maybe_fail_fi git fast-import --cat-blob-fd=3 <stream 3>backflow && - wait $! -} - -properties () { - while test "$#" -ne 0 - do - property="$1" && - value="$2" && - printf "%s\n" "K ${#property}" && - printf "%s\n" "$property" && - printf "%s\n" "V ${#value}" && - printf "%s\n" "$value" && - shift 2 || - return 1 - done -} - -text_no_props () { - text="$1 -" && - printf "%s\n" "Prop-content-length: 10" && - printf "%s\n" "Text-content-length: ${#text}" && - printf "%s\n" "Content-length: $((${#text} + 10))" && - printf "%s\n" "" "PROPS-END" && - printf "%s\n" "$text" -} - -test_expect_success 'empty dump' ' - reinit_git && - echo "SVN-fs-dump-format-version: 2" >input && - try_dump input -' - -test_expect_success 'v4 dumps not supported' ' - reinit_git && - echo "SVN-fs-dump-format-version: 4" >v4.dump && - try_dump v4.dump must_fail -' - -test_expect_failure 'empty revision' ' - reinit_git && - printf "rev <nobody, nobody@local>: %s\n" "" "" >expect && - cat >emptyrev.dump <<-\EOF && - SVN-fs-dump-format-version: 3 - - Revision-number: 1 - Prop-content-length: 0 - Content-length: 0 - - Revision-number: 2 - Prop-content-length: 0 - Content-length: 0 - - EOF - try_dump emptyrev.dump && - git log -p --format="rev <%an, %ae>: %s" HEAD >actual && - test_cmp expect actual -' - -test_expect_success 'empty properties' ' - reinit_git && - printf "rev <nobody, nobody@local>: %s\n" "" "" >expect && - cat >emptyprop.dump <<-\EOF && - SVN-fs-dump-format-version: 3 - - Revision-number: 1 - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - - Revision-number: 2 - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - EOF - try_dump emptyprop.dump && - git log -p --format="rev <%an, %ae>: %s" HEAD >actual && - test_cmp expect actual -' - -test_expect_success 'author name and commit message' ' - reinit_git && - echo "<author@example.com, author@example.com@local>" >expect.author && - cat >message <<-\EOF && - A concise summary of the change - - A detailed description of the change, why it is needed, what - was broken and why applying this is the best course of action. - - * file.c - Details pertaining to an individual file. - EOF - { - properties \ - svn:author author@example.com \ - svn:log "$(cat message)" && - echo PROPS-END - } >props && - { - echo "SVN-fs-dump-format-version: 3" && - echo && - echo "Revision-number: 1" && - echo Prop-content-length: $(wc -c <props) && - echo Content-length: $(wc -c <props) && - echo && - cat props - } >log.dump && - try_dump log.dump && - git log -p --format="%B" HEAD >actual.log && - git log --format="<%an, %ae>" >actual.author && - test_cmp message actual.log && - test_cmp expect.author actual.author -' - -test_expect_success 'unsupported properties are ignored' ' - reinit_git && - echo author >expect && - cat >extraprop.dump <<-\EOF && - SVN-fs-dump-format-version: 3 - - Revision-number: 1 - Prop-content-length: 56 - Content-length: 56 - - K 8 - nonsense - V 1 - y - K 10 - svn:author - V 6 - author - PROPS-END - EOF - try_dump extraprop.dump && - git log -p --format=%an HEAD >actual && - test_cmp expect actual -' - -test_expect_failure 'timestamp and empty file' ' - echo author@example.com >expect.author && - echo 1999-01-01 >expect.date && - echo file >expect.files && - reinit_git && - { - properties \ - svn:author author@example.com \ - svn:date "1999-01-01T00:01:002.000000Z" \ - svn:log "add empty file" && - echo PROPS-END - } >props && - { - cat <<-EOF && - SVN-fs-dump-format-version: 3 - - Revision-number: 1 - EOF - echo Prop-content-length: $(wc -c <props) && - echo Content-length: $(wc -c <props) && - echo && - cat props && - cat <<-\EOF - - Node-path: empty-file - Node-kind: file - Node-action: add - Content-length: 0 - - EOF - } >emptyfile.dump && - try_dump emptyfile.dump && - git log --format=%an HEAD >actual.author && - git log --date=short --format=%ad HEAD >actual.date && - git ls-tree -r --name-only HEAD >actual.files && - test_cmp expect.author actual.author && - test_cmp expect.date actual.date && - test_cmp expect.files actual.files && - git checkout HEAD empty-file && - test_must_be_empty file -' - -test_expect_success 'directory with files' ' - reinit_git && - printf "%s\n" directory/file1 directory/file2 >expect.files && - echo hi >hi && - echo hello >hello && - { - properties \ - svn:author author@example.com \ - svn:date "1999-02-01T00:01:002.000000Z" \ - svn:log "add directory with some files in it" && - echo PROPS-END - } >props && - { - cat <<-EOF && - SVN-fs-dump-format-version: 3 - - Revision-number: 1 - EOF - echo Prop-content-length: $(wc -c <props) && - echo Content-length: $(wc -c <props) && - echo && - cat props && - cat <<-\EOF && - - Node-path: directory - Node-kind: dir - Node-action: add - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - - Node-path: directory/file1 - Node-kind: file - Node-action: add - EOF - text_no_props hello && - cat <<-\EOF && - Node-path: directory/file2 - Node-kind: file - Node-action: add - EOF - text_no_props hi - } >directory.dump && - try_dump directory.dump && - - git ls-tree -r --name-only HEAD >actual.files && - git checkout HEAD directory && - test_cmp expect.files actual.files && - test_cmp hello directory/file1 && - test_cmp hi directory/file2 -' - -test_expect_success 'branch name with backslash' ' - reinit_git && - sort <<-\EOF >expect.branch-files && - trunk/file1 - trunk/file2 - "branches/UpdateFOPto094\\/file1" - "branches/UpdateFOPto094\\/file2" - EOF - - echo hi >hi && - echo hello >hello && - { - properties \ - svn:author author@example.com \ - svn:date "1999-02-02T00:01:02.000000Z" \ - svn:log "add directory with some files in it" && - echo PROPS-END - } >props.setup && - { - properties \ - svn:author brancher@example.com \ - svn:date "2007-12-06T21:38:34.000000Z" \ - svn:log "Updating fop to .94 and adjust fo-stylesheets" && - echo PROPS-END - } >props.branch && - { - cat <<-EOF && - SVN-fs-dump-format-version: 3 - - Revision-number: 1 - EOF - echo Prop-content-length: $(wc -c <props.setup) && - echo Content-length: $(wc -c <props.setup) && - echo && - cat props.setup && - cat <<-\EOF && - - Node-path: trunk - Node-kind: dir - Node-action: add - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - - Node-path: branches - Node-kind: dir - Node-action: add - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - - Node-path: trunk/file1 - Node-kind: file - Node-action: add - EOF - text_no_props hello && - cat <<-\EOF && - Node-path: trunk/file2 - Node-kind: file - Node-action: add - EOF - text_no_props hi && - cat <<-\EOF && - - Revision-number: 2 - EOF - echo Prop-content-length: $(wc -c <props.branch) && - echo Content-length: $(wc -c <props.branch) && - echo && - cat props.branch && - cat <<-\EOF - - Node-path: branches/UpdateFOPto094\ - Node-kind: dir - Node-action: add - Node-copyfrom-rev: 1 - Node-copyfrom-path: trunk - - Node-kind: dir - Node-action: add - Prop-content-length: 34 - Content-length: 34 - - K 13 - svn:mergeinfo - V 0 - - PROPS-END - EOF - } >branch.dump && - try_dump branch.dump && - - git ls-tree -r --name-only HEAD | - sort >actual.branch-files && - test_cmp expect.branch-files actual.branch-files -' - -test_expect_success 'node without action' ' - reinit_git && - cat >inaction.dump <<-\EOF && - SVN-fs-dump-format-version: 3 - - Revision-number: 1 - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - - Node-path: directory - Node-kind: dir - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - EOF - try_dump inaction.dump must_fail -' - -test_expect_success 'action: add node without text' ' - reinit_git && - cat >textless.dump <<-\EOF && - SVN-fs-dump-format-version: 3 - - Revision-number: 1 - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - - Node-path: textless - Node-kind: file - Node-action: add - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - EOF - try_dump textless.dump must_fail -' - -test_expect_failure 'change file mode but keep old content' ' - reinit_git && - cat >expect <<-\EOF && - OBJID - :120000 100644 OBJID OBJID T greeting - OBJID - :100644 120000 OBJID OBJID T greeting - OBJID - :000000 100644 OBJID OBJID A greeting - EOF - echo "link hello" >expect.blob && - echo hello >hello && - cat >filemode.dump <<-\EOF && - SVN-fs-dump-format-version: 3 - - Revision-number: 1 - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - - Node-path: greeting - Node-kind: file - Node-action: add - Prop-content-length: 10 - Text-content-length: 11 - Content-length: 21 - - PROPS-END - link hello - - Revision-number: 2 - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - - Node-path: greeting - Node-kind: file - Node-action: change - Prop-content-length: 33 - Content-length: 33 - - K 11 - svn:special - V 1 - * - PROPS-END - - Revision-number: 3 - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - - Node-path: greeting - Node-kind: file - Node-action: change - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - EOF - try_dump filemode.dump && - { - git rev-list HEAD | - git diff-tree --root --stdin | - sed "s/$OID_REGEX/OBJID/g" - } >actual && - git show HEAD:greeting >actual.blob && - git show HEAD^:greeting >actual.target && - test_cmp expect actual && - test_cmp expect.blob actual.blob && - test_cmp hello actual.target -' - -test_expect_success 'NUL in property value' ' - reinit_git && - echo "commit message" >expect.message && - { - properties \ - unimportant "something with a NUL (Q)" \ - svn:log "commit message" && - echo PROPS-END - } | - q_to_nul >props && - { - cat <<-\EOF && - SVN-fs-dump-format-version: 3 - - Revision-number: 1 - EOF - echo Prop-content-length: $(wc -c <props) && - echo Content-length: $(wc -c <props) && - echo && - cat props - } >nulprop.dump && - try_dump nulprop.dump && - git diff-tree --always -s --format=%s HEAD >actual.message && - test_cmp expect.message actual.message -' - -test_expect_success 'NUL in log message, file content, and property name' ' - # Caveat: svnadmin 1.6.16 (r1073529) truncates at \0 in the - # svn:specialQnotreally example. - reinit_git && - cat >expect <<-\EOF && - OBJID - :100644 100644 OBJID OBJID M greeting - OBJID - :000000 100644 OBJID OBJID A greeting - EOF - printf "\n%s\n" "something with an ASCII NUL (Q)" >expect.message && - printf "%s\n" "helQo" >expect.hello1 && - printf "%s\n" "link hello" >expect.hello2 && - { - properties svn:log "something with an ASCII NUL (Q)" && - echo PROPS-END - } | - q_to_nul >props && - { - q_to_nul <<-\EOF && - SVN-fs-dump-format-version: 3 - - Revision-number: 1 - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - - Node-path: greeting - Node-kind: file - Node-action: add - Prop-content-length: 10 - Text-content-length: 6 - Content-length: 16 - - PROPS-END - helQo - - Revision-number: 2 - EOF - echo Prop-content-length: $(wc -c <props) && - echo Content-length: $(wc -c <props) && - echo && - cat props && - q_to_nul <<-\EOF - - Node-path: greeting - Node-kind: file - Node-action: change - Prop-content-length: 43 - Text-content-length: 11 - Content-length: 54 - - K 21 - svn:specialQnotreally - V 1 - * - PROPS-END - link hello - EOF - } >8bitclean.dump && - try_dump 8bitclean.dump && - { - git rev-list HEAD | - git diff-tree --root --stdin | - sed "s/$OID_REGEX/OBJID/g" - } >actual && - { - git cat-file commit HEAD | nul_to_q && - echo - } | - sed -ne "/^\$/,\$ p" >actual.message && - git cat-file blob HEAD^:greeting | nul_to_q >actual.hello1 && - git cat-file blob HEAD:greeting | nul_to_q >actual.hello2 && - test_cmp expect actual && - test_cmp expect.message actual.message && - test_cmp expect.hello1 actual.hello1 && - test_cmp expect.hello2 actual.hello2 -' - -test_expect_success 'change file mode and reiterate content' ' - reinit_git && - cat >expect <<-\EOF && - OBJID - :120000 100644 OBJID OBJID T greeting - OBJID - :100644 120000 OBJID OBJID T greeting - OBJID - :000000 100644 OBJID OBJID A greeting - EOF - echo "link hello" >expect.blob && - echo hello >hello && - cat >filemode2.dump <<-\EOF && - SVN-fs-dump-format-version: 3 - - Revision-number: 1 - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - - Node-path: greeting - Node-kind: file - Node-action: add - Prop-content-length: 10 - Text-content-length: 11 - Content-length: 21 - - PROPS-END - link hello - - Revision-number: 2 - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - - Node-path: greeting - Node-kind: file - Node-action: change - Prop-content-length: 33 - Text-content-length: 11 - Content-length: 44 - - K 11 - svn:special - V 1 - * - PROPS-END - link hello - - Revision-number: 3 - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - - Node-path: greeting - Node-kind: file - Node-action: change - Prop-content-length: 10 - Text-content-length: 11 - Content-length: 21 - - PROPS-END - link hello - EOF - try_dump filemode2.dump && - { - git rev-list HEAD | - git diff-tree --root --stdin | - sed "s/$OID_REGEX/OBJID/g" - } >actual && - git show HEAD:greeting >actual.blob && - git show HEAD^:greeting >actual.target && - test_cmp expect actual && - test_cmp expect.blob actual.blob && - test_cmp hello actual.target -' - -test_expect_success 'deltas supported' ' - reinit_git && - { - # (old) h + (inline) ello + (old) \n - printf "SVNQ%b%b%s" "Q\003\006\005\004" "\001Q\0204\001\002" "ello" | - q_to_nul - } >delta && - { - properties \ - svn:author author@example.com \ - svn:date "1999-01-05T00:01:002.000000Z" \ - svn:log "add greeting" && - echo PROPS-END - } >props && - { - properties \ - svn:author author@example.com \ - svn:date "1999-01-06T00:01:002.000000Z" \ - svn:log "change it" && - echo PROPS-END - } >props2 && - { - echo SVN-fs-dump-format-version: 3 && - echo && - echo Revision-number: 1 && - echo Prop-content-length: $(wc -c <props) && - echo Content-length: $(wc -c <props) && - echo && - cat props && - cat <<-\EOF && - - Node-path: hello - Node-kind: file - Node-action: add - Prop-content-length: 10 - Text-content-length: 3 - Content-length: 13 - - PROPS-END - hi - - EOF - echo Revision-number: 2 && - echo Prop-content-length: $(wc -c <props2) && - echo Content-length: $(wc -c <props2) && - echo && - cat props2 && - cat <<-\EOF && - - Node-path: hello - Node-kind: file - Node-action: change - Text-delta: true - Prop-content-length: 10 - EOF - echo Text-content-length: $(wc -c <delta) && - echo Content-length: $((10 + $(wc -c <delta))) && - echo && - echo PROPS-END && - cat delta - } >delta.dump && - try_dump delta.dump -' - -test_expect_success 'property deltas supported' ' - reinit_git && - cat >expect <<-\EOF && - OBJID - :100755 100644 OBJID OBJID M script.sh - EOF - { - properties \ - svn:author author@example.com \ - svn:date "1999-03-06T00:01:002.000000Z" \ - svn:log "make an executable, or chmod -x it" && - echo PROPS-END - } >revprops && - { - echo SVN-fs-dump-format-version: 3 && - echo && - echo Revision-number: 1 && - echo Prop-content-length: $(wc -c <revprops) && - echo Content-length: $(wc -c <revprops) && - echo && - cat revprops && - echo && - cat <<-\EOF && - Node-path: script.sh - Node-kind: file - Node-action: add - Text-content-length: 0 - Prop-content-length: 39 - Content-length: 39 - - K 14 - svn:executable - V 4 - true - PROPS-END - - EOF - echo Revision-number: 2 && - echo Prop-content-length: $(wc -c <revprops) && - echo Content-length: $(wc -c <revprops) && - echo && - cat revprops && - echo && - cat <<-\EOF - Node-path: script.sh - Node-kind: file - Node-action: change - Prop-delta: true - Prop-content-length: 30 - Content-length: 30 - - D 14 - svn:executable - PROPS-END - EOF - } >propdelta.dump && - try_dump propdelta.dump && - { - git rev-list HEAD | - git diff-tree --stdin | - sed "s/$OID_REGEX/OBJID/g" - } >actual && - test_cmp expect actual -' - -test_expect_success 'properties on /' ' - reinit_git && - cat <<-\EOF >expect && - OBJID - OBJID - :000000 100644 OBJID OBJID A greeting - EOF - sed -e "s/X$//" <<-\EOF >changeroot.dump && - SVN-fs-dump-format-version: 3 - - Revision-number: 1 - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - - Node-path: greeting - Node-kind: file - Node-action: add - Text-content-length: 0 - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - - Revision-number: 2 - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - - Node-path: X - Node-kind: dir - Node-action: change - Prop-delta: true - Prop-content-length: 43 - Content-length: 43 - - K 10 - svn:ignore - V 11 - build-area - - PROPS-END - EOF - try_dump changeroot.dump && - { - git rev-list HEAD | - git diff-tree --root --always --stdin | - sed "s/$OID_REGEX/OBJID/g" - } >actual && - test_cmp expect actual -' - -test_expect_success 'deltas for typechange' ' - reinit_git && - cat >expect <<-\EOF && - OBJID - :120000 100644 OBJID OBJID T test-file - OBJID - :100755 120000 OBJID OBJID T test-file - OBJID - :000000 100755 OBJID OBJID A test-file - EOF - cat >deleteprop.dump <<-\EOF && - SVN-fs-dump-format-version: 3 - - Revision-number: 1 - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - - Node-path: test-file - Node-kind: file - Node-action: add - Prop-delta: true - Prop-content-length: 35 - Text-content-length: 17 - Content-length: 52 - - K 14 - svn:executable - V 0 - - PROPS-END - link testing 123 - - Revision-number: 2 - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - - Node-path: test-file - Node-kind: file - Node-action: change - Prop-delta: true - Prop-content-length: 53 - Text-content-length: 17 - Content-length: 70 - - K 11 - svn:special - V 1 - * - D 14 - svn:executable - PROPS-END - link testing 231 - - Revision-number: 3 - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - - Node-path: test-file - Node-kind: file - Node-action: change - Prop-delta: true - Prop-content-length: 27 - Text-content-length: 17 - Content-length: 44 - - D 11 - svn:special - PROPS-END - link testing 321 - EOF - try_dump deleteprop.dump && - { - git rev-list HEAD | - git diff-tree --root --stdin | - sed "s/$OID_REGEX/OBJID/g" - } >actual && - test_cmp expect actual -' - -test_expect_success 'deltas need not consume the whole preimage' ' - reinit_git && - cat >expect <<-\EOF && - OBJID - :120000 100644 OBJID OBJID T postimage - OBJID - :100644 120000 OBJID OBJID T postimage - OBJID - :000000 100644 OBJID OBJID A postimage - EOF - echo "first preimage" >expect.1 && - printf target >expect.2 && - printf lnk >expect.3 && - { - printf "SVNQ%b%b%b" "QQ\017\001\017" "\0217" "first preimage\n" | - q_to_nul - } >delta.1 && - { - properties svn:special "*" && - echo PROPS-END - } >symlink.props && - { - printf "SVNQ%b%b%b" "Q\002\013\004\012" "\0201\001\001\0211" "lnk target" | - q_to_nul - } >delta.2 && - { - printf "SVNQ%b%b" "Q\004\003\004Q" "\001Q\002\002" | - q_to_nul - } >delta.3 && - { - cat <<-\EOF && - SVN-fs-dump-format-version: 3 - - Revision-number: 1 - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - - Node-path: postimage - Node-kind: file - Node-action: add - Text-delta: true - Prop-content-length: 10 - EOF - echo Text-content-length: $(wc -c <delta.1) && - echo Content-length: $((10 + $(wc -c <delta.1))) && - echo && - echo PROPS-END && - cat delta.1 && - cat <<-\EOF && - - Revision-number: 2 - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - - Node-path: postimage - Node-kind: file - Node-action: change - Text-delta: true - EOF - echo Prop-content-length: $(wc -c <symlink.props) && - echo Text-content-length: $(wc -c <delta.2) && - echo Content-length: $(($(wc -c <symlink.props) + $(wc -c <delta.2))) && - echo && - cat symlink.props && - cat delta.2 && - cat <<-\EOF && - - Revision-number: 3 - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - - Node-path: postimage - Node-kind: file - Node-action: change - Text-delta: true - Prop-content-length: 10 - EOF - echo Text-content-length: $(wc -c <delta.3) && - echo Content-length: $((10 + $(wc -c <delta.3))) && - echo && - echo PROPS-END && - cat delta.3 && - echo - } >deltapartial.dump && - try_dump deltapartial.dump && - { - git rev-list HEAD | - git diff-tree --root --stdin | - sed "s/$OID_REGEX/OBJID/g" - } >actual && - test_cmp expect actual && - git show HEAD:postimage >actual.3 && - git show HEAD^:postimage >actual.2 && - git show HEAD^^:postimage >actual.1 && - test_cmp expect.1 actual.1 && - test_cmp expect.2 actual.2 && - test_cmp expect.3 actual.3 -' - -test_expect_success 'no hang for delta trying to read past end of preimage' ' - reinit_git && - { - # COPY 1 - printf "SVNQ%b%b" "Q\001\001\002Q" "\001Q" | - q_to_nul - } >greedy.delta && - { - cat <<-\EOF && - SVN-fs-dump-format-version: 3 - - Revision-number: 1 - Prop-content-length: 10 - Content-length: 10 - - PROPS-END - - Node-path: bootstrap - Node-kind: file - Node-action: add - Text-delta: true - Prop-content-length: 10 - EOF - echo Text-content-length: $(wc -c <greedy.delta) && - echo Content-length: $((10 + $(wc -c <greedy.delta))) && - echo && - echo PROPS-END && - cat greedy.delta && - echo - } >greedydelta.dump && - try_dump greedydelta.dump must_fail might_fail -' - -test_expect_success 'set up svn repo' ' - svnconf=$PWD/svnconf && - mkdir -p "$svnconf" && - - if - svnadmin -h >/dev/null 2>&1 && - svnadmin create simple-svn && - svnadmin load simple-svn <"$TEST_DIRECTORY/t9135/svn.dump" && - svn export --config-dir "$svnconf" "file://$PWD/simple-svn" simple-svnco - then - test_set_prereq SVNREPO - fi -' - -test_expect_success SVNREPO 't9135/svn.dump' ' - mkdir -p simple-git && - ( - cd simple-git && - reinit_git && - try_dump "$TEST_DIRECTORY/t9135/svn.dump" - ) && - ( - cd simple-svnco && - git init && - git add . && - git fetch ../simple-git master && - git diff --exit-code FETCH_HEAD - ) -' - -test_done diff --git a/t/t9011-svn-da.sh b/t/t9011-svn-da.sh deleted file mode 100755 index ab1ef28fd9..0000000000 --- a/t/t9011-svn-da.sh +++ /dev/null @@ -1,248 +0,0 @@ -#!/bin/sh - -test_description='test parsing of svndiff0 files - -Using the "test-svn-fe -d" helper, check that svn-fe correctly -interprets deltas using various facilities (some from the spec, -some only learned from practice). -' -. ./test-lib.sh - ->empty -printf foo >preimage - -test_expect_success 'reject empty delta' ' - test_must_fail test-svn-fe -d preimage empty 0 -' - -test_expect_success 'delta can empty file' ' - printf "SVNQ" | q_to_nul >clear.delta && - test-svn-fe -d preimage clear.delta 4 >actual && - test_must_be_empty actual -' - -test_expect_success 'reject svndiff2' ' - printf "SVN\002" >bad.filetype && - test_must_fail test-svn-fe -d preimage bad.filetype 4 -' - -test_expect_success 'one-window empty delta' ' - printf "SVNQ%s" "QQQQQ" | q_to_nul >clear.onewindow && - test-svn-fe -d preimage clear.onewindow 9 >actual && - test_must_be_empty actual -' - -test_expect_success 'reject incomplete window header' ' - printf "SVNQ%s" "QQQQQ" | q_to_nul >clear.onewindow && - printf "SVNQ%s" "QQ" | q_to_nul >clear.partialwindow && - test_must_fail test-svn-fe -d preimage clear.onewindow 6 && - test_must_fail test-svn-fe -d preimage clear.partialwindow 6 -' - -test_expect_success 'reject declared delta longer than actual delta' ' - printf "SVNQ%s" "QQQQQ" | q_to_nul >clear.onewindow && - printf "SVNQ%s" "QQ" | q_to_nul >clear.partialwindow && - test_must_fail test-svn-fe -d preimage clear.onewindow 14 && - test_must_fail test-svn-fe -d preimage clear.partialwindow 9 -' - -test_expect_success 'two-window empty delta' ' - printf "SVNQ%s%s" "QQQQQ" "QQQQQ" | q_to_nul >clear.twowindow && - test-svn-fe -d preimage clear.twowindow 14 >actual && - test_must_fail test-svn-fe -d preimage clear.twowindow 13 && - test_must_be_empty actual -' - -test_expect_success 'noisy zeroes' ' - printf "SVNQ%s" \ - "RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRQQQQQ" | - tr R "\200" | - q_to_nul >clear.noisy && - len=$(wc -c <clear.noisy) && - test-svn-fe -d preimage clear.noisy $len && - test_must_be_empty actual -' - -test_expect_success 'reject variable-length int in magic' ' - printf "SVNRQ" | tr R "\200" | q_to_nul >clear.badmagic && - test_must_fail test-svn-fe -d preimage clear.badmagic 5 -' - -test_expect_success 'reject truncated integer' ' - printf "SVNQ%s%s" "QQQQQ" "QQQQRRQ" | - tr R "\200" | - q_to_nul >clear.fullint && - printf "SVNQ%s%s" "QQQQQ" "QQQQRR" | - tr RT "\201" | - q_to_nul >clear.partialint && - test_must_fail test-svn-fe -d preimage clear.fullint 15 && - test-svn-fe -d preimage clear.fullint 16 && - test_must_fail test-svn-fe -d preimage clear.partialint 15 -' - -test_expect_success 'nonempty (but unused) preimage view' ' - printf "SVNQ%b" "Q\003QQQ" | q_to_nul >clear.readpreimage && - test-svn-fe -d preimage clear.readpreimage 9 >actual && - test_must_be_empty actual -' - -test_expect_success 'preimage view: right endpoint cannot backtrack' ' - printf "SVNQ%b%b" "Q\003QQQ" "Q\002QQQ" | - q_to_nul >clear.backtrack && - test_must_fail test-svn-fe -d preimage clear.backtrack 14 -' - -test_expect_success 'preimage view: left endpoint can advance' ' - printf "SVNQ%b%b" "Q\003QQQ" "\001\002QQQ" | - q_to_nul >clear.preshrink && - printf "SVNQ%b%b" "Q\003QQQ" "\001\001QQQ" | - q_to_nul >clear.shrinkbacktrack && - test-svn-fe -d preimage clear.preshrink 14 >actual && - test_must_fail test-svn-fe -d preimage clear.shrinkbacktrack 14 && - test_must_be_empty actual -' - -test_expect_success 'preimage view: offsets compared by value' ' - printf "SVNQ%b%b" "\001\001QQQ" "\0200Q\003QQQ" | - q_to_nul >clear.noisybacktrack && - printf "SVNQ%b%b" "\001\001QQQ" "\0200\001\002QQQ" | - q_to_nul >clear.noisyadvance && - test_must_fail test-svn-fe -d preimage clear.noisybacktrack 15 && - test-svn-fe -d preimage clear.noisyadvance 15 && - test_must_be_empty actual -' - -test_expect_success 'preimage view: reject truncated preimage' ' - printf "SVNQ%b" "\010QQQQ" | q_to_nul >clear.lateemptyread && - printf "SVNQ%b" "\010\001QQQ" | q_to_nul >clear.latenonemptyread && - printf "SVNQ%b" "\001\010QQQ" | q_to_nul >clear.longread && - test_must_fail test-svn-fe -d preimage clear.lateemptyread 9 && - test_must_fail test-svn-fe -d preimage clear.latenonemptyread 9 && - test_must_fail test-svn-fe -d preimage clear.longread 9 -' - -test_expect_success 'forbid unconsumed inline data' ' - printf "SVNQ%b%s%b%s" "QQQQ\003" "bar" "QQQQ\001" "x" | - q_to_nul >inline.clear && - test_must_fail test-svn-fe -d preimage inline.clear 18 >actual -' - -test_expect_success 'reject truncated inline data' ' - printf "SVNQ%b%s" "QQQQ\003" "b" | q_to_nul >inline.trunc && - test_must_fail test-svn-fe -d preimage inline.trunc 10 -' - -test_expect_success 'reject truncated inline data (after instruction section)' ' - printf "SVNQ%b%b%s" "QQ\001\001\003" "\0201" "b" | q_to_nul >insn.trunc && - test_must_fail test-svn-fe -d preimage insn.trunc 11 -' - -test_expect_success 'copyfrom_data' ' - echo hi >expect && - printf "SVNQ%b%b%b" "QQ\003\001\003" "\0203" "hi\n" | q_to_nul >copydat && - test-svn-fe -d preimage copydat 13 >actual && - test_cmp expect actual -' - -test_expect_success 'multiple copyfrom_data' ' - echo hi >expect && - printf "SVNQ%b%b%b%b%b" "QQ\003\002\003" "\0201\0202" "hi\n" \ - "QQQ\002Q" "\0200Q" | q_to_nul >copy.multi && - len=$(wc -c <copy.multi) && - test-svn-fe -d preimage copy.multi $len >actual && - test_cmp expect actual -' - -test_expect_success 'incomplete multiple insn' ' - printf "SVNQ%b%b%b" "QQ\003\002\003" "\0203\0200" "hi\n" | - q_to_nul >copy.partial && - len=$(wc -c <copy.partial) && - test_must_fail test-svn-fe -d preimage copy.partial $len -' - -test_expect_success 'catch attempt to copy missing data' ' - printf "SVNQ%b%b%s%b%s" "QQ\002\002\001" "\0201\0201" "X" \ - "QQQQ\002" "YZ" | - q_to_nul >copy.incomplete && - len=$(wc -c <copy.incomplete) && - test_must_fail test-svn-fe -d preimage copy.incomplete $len -' - -test_expect_success 'copyfrom target to repeat data' ' - printf foofoo >expect && - printf "SVNQ%b%b%s" "QQ\006\004\003" "\0203\0100\003Q" "foo" | - q_to_nul >copytarget.repeat && - len=$(wc -c <copytarget.repeat) && - test-svn-fe -d preimage copytarget.repeat $len >actual && - test_cmp expect actual -' - -test_expect_success 'copyfrom target out of order' ' - printf foooof >expect && - printf "SVNQ%b%b%s" \ - "QQ\006\007\003" "\0203\0101\002\0101\001\0101Q" "foo" | - q_to_nul >copytarget.reverse && - len=$(wc -c <copytarget.reverse) && - test-svn-fe -d preimage copytarget.reverse $len >actual && - test_cmp expect actual -' - -test_expect_success 'catch copyfrom future' ' - printf "SVNQ%b%b%s" "QQ\004\004\003" "\0202\0101\002\0201" "XYZ" | - q_to_nul >copytarget.infuture && - len=$(wc -c <copytarget.infuture) && - test_must_fail test-svn-fe -d preimage copytarget.infuture $len -' - -test_expect_success 'copy to sustain' ' - printf XYXYXYXYXYXZ >expect && - printf "SVNQ%b%b%s" "QQ\014\004\003" "\0202\0111Q\0201" "XYZ" | - q_to_nul >copytarget.sustain && - len=$(wc -c <copytarget.sustain) && - test-svn-fe -d preimage copytarget.sustain $len >actual && - test_cmp expect actual -' - -test_expect_success 'catch copy that overflows' ' - printf "SVNQ%b%b%s" "QQ\003\003\001" "\0201\0177Q" X | - q_to_nul >copytarget.overflow && - len=$(wc -c <copytarget.overflow) && - test_must_fail test-svn-fe -d preimage copytarget.overflow $len -' - -test_expect_success 'copyfrom source' ' - printf foo >expect && - printf "SVNQ%b%b" "Q\003\003\002Q" "\003Q" | q_to_nul >copysource.all && - test-svn-fe -d preimage copysource.all 11 >actual && - test_cmp expect actual -' - -test_expect_success 'copy backwards' ' - printf oof >expect && - printf "SVNQ%b%b" "Q\003\003\006Q" "\001\002\001\001\001Q" | - q_to_nul >copysource.rev && - test-svn-fe -d preimage copysource.rev 15 >actual && - test_cmp expect actual -' - -test_expect_success 'offsets are relative to window' ' - printf fo >expect && - printf "SVNQ%b%b%b%b" "Q\003\001\002Q" "\001Q" \ - "\002\001\001\002Q" "\001Q" | - q_to_nul >copysource.two && - test-svn-fe -d preimage copysource.two 18 >actual && - test_cmp expect actual -' - -test_expect_success 'example from notes/svndiff' ' - printf aaaaccccdddddddd >expect && - printf aaaabbbbcccc >source && - printf "SVNQ%b%b%s" "Q\014\020\007\001" \ - "\004Q\004\010\0201\0107\010" d | - q_to_nul >delta.example && - len=$(wc -c <delta.example) && - test-svn-fe -d source delta.example $len >actual && - test_cmp expect actual -' - -test_done diff --git a/t/t9020-remote-svn.sh b/t/t9020-remote-svn.sh deleted file mode 100755 index 754c4a3284..0000000000 --- a/t/t9020-remote-svn.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/bin/sh - -test_description='tests remote-svn' - -. ./test-lib.sh - -MARKSPATH=.git/info/fast-import/remote-svn - -if ! test_have_prereq PYTHON -then - skip_all='skipping remote-svn tests, python not available' - test_done -fi - -# Override svnrdump with our simulator -PATH="$HOME:$PATH" -export PATH PYTHON_PATH GIT_BUILD_DIR - -write_script "$HOME/svnrdump" <<\EOF -exec "$PYTHON_PATH" "$GIT_BUILD_DIR/contrib/svn-fe/svnrdump_sim.py" "$@" -EOF - -init_git () { - rm -fr .git && - git init && - #git remote add svnsim testsvn::sim:///$TEST_DIRECTORY/t9020/example.svnrdump - # let's reuse an existing dump file!? - git remote add svnsim "testsvn::sim://$TEST_DIRECTORY/t9154/svn.dump" - git remote add svnfile "testsvn::file://$TEST_DIRECTORY/t9154/svn.dump" -} - -if test -e "$GIT_BUILD_DIR/git-remote-testsvn" -then - test_set_prereq REMOTE_SVN -fi - -test_debug ' - git --version - type git - type svnrdump -' - -test_expect_success REMOTE_SVN 'simple fetch' ' - init_git && - git fetch svnsim && - test_cmp .git/refs/svn/svnsim/master .git/refs/remotes/svnsim/master && - cp .git/refs/remotes/svnsim/master master.good -' - -test_debug ' - git show-ref -s refs/svn/svnsim/master - git show-ref -s refs/remotes/svnsim/master -' - -test_expect_success REMOTE_SVN 'repeated fetch, nothing shall change' ' - git fetch svnsim && - test_cmp master.good .git/refs/remotes/svnsim/master -' - -test_expect_success REMOTE_SVN 'fetch from a file:// url gives the same result' ' - git fetch svnfile -' - -test_expect_failure REMOTE_SVN 'the sha1 differ because the git-svn-id line in the commit msg contains the url' ' - test_cmp .git/refs/remotes/svnfile/master .git/refs/remotes/svnsim/master -' - -test_expect_success REMOTE_SVN 'mark-file regeneration' ' - # filter out any other marks, that can not be regenerated. Only up to 3 digit revisions are allowed here - grep ":[0-9]\{1,3\} " $MARKSPATH/svnsim.marks > $MARKSPATH/svnsim.marks.old && - rm $MARKSPATH/svnsim.marks && - git fetch svnsim && - test_cmp $MARKSPATH/svnsim.marks.old $MARKSPATH/svnsim.marks -' - -test_expect_success REMOTE_SVN 'incremental imports must lead to the same head' ' - SVNRMAX=3 && - export SVNRMAX && - init_git && - git fetch svnsim && - test_cmp .git/refs/svn/svnsim/master .git/refs/remotes/svnsim/master && - unset SVNRMAX && - git fetch svnsim && - test_cmp master.good .git/refs/remotes/svnsim/master -' - -test_expect_success REMOTE_SVN 'respects configured default initial branch' ' - git -c init.defaultBranch=trunk remote add -f trunk \ - "testsvn::file://$TEST_DIRECTORY/t9154/svn.dump" && - git rev-parse --verify refs/remotes/trunk/trunk -' - -test_debug 'git branch -a' - -test_done diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 6a8e194a99..f9904066fe 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -820,7 +820,7 @@ test_must_fail_acceptable () { fi case "$1" in - git|__git*|test-tool|test-svn-fe|test_terminal) + git|__git*|test-tool|test_terminal) return 0 ;; *) |