From 8a8a15b9984ad4c2e40934e49335dfafd1bf3d1a Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Wed, 13 Mar 2019 07:39:33 -0700 Subject: [PATCH] filter-repo: add tests for --debug and --dry-run Signed-off-by: Elijah Newren --- t/t9390-filter-repo.sh | 74 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/t/t9390-filter-repo.sh b/t/t9390-filter-repo.sh index 519f250..a24bf41 100755 --- a/t/t9390-filter-repo.sh +++ b/t/t9390-filter-repo.sh @@ -282,6 +282,80 @@ test_expect_success 'refs/replace/ to add more initial history' ' ) ' +test_expect_success '--debug' ' + ( + git clone file://"$(pwd)"/metasyntactic debug && + cd debug && + + git filter-repo --path words --debug && + + test $(git rev-list --count HEAD) = 2 && + git cat-file --batch-check --batch-all-objects >all-objs && + test_line_count = 12 all-objs && + git log --format=%n --name-only | sort | uniq >filenames && + test_line_count = 6 filenames && + + test_path_is_file .git/filter-repo/fast-export.original && + grep "^commit " .git/filter-repo/fast-export.original >out && + test_line_count = 3 out && + test_path_is_file .git/filter-repo/fast-export.filtered && + grep "^commit " .git/filter-repo/fast-export.filtered >out && + test_line_count = 2 out + ) +' + +test_expect_success '--dry-run' ' + ( + git clone file://"$(pwd)"/metasyntactic dry_run && + cd dry_run && + + git filter-repo --path words --dry-run && + + git show-ref | grep master >out && + test_line_count = 2 out && + awk "{print \$1}" out | uniq >out2 && + test_line_count = 1 out2 && + + test $(git rev-list --count HEAD) = 3 && + git cat-file --batch-check --batch-all-objects >all-objs && + test_line_count = 19 all-objs && + git log --format=%n --name-only | sort | uniq >filenames && + test_line_count = 9 filenames && + + test_path_is_file .git/filter-repo/fast-export.original && + grep "^commit " .git/filter-repo/fast-export.original >out && + test_line_count = 3 out && + test_path_is_file .git/filter-repo/fast-export.filtered && + grep "^commit " .git/filter-repo/fast-export.filtered >out && + test_line_count = 2 out + ) +' + +test_expect_success '--dry-run --stdin' ' + ( + git clone file://"$(pwd)"/metasyntactic dry_run_stdin && + cd dry_run_stdin && + + git fast-export --all | git filter-repo --path words --dry-run --stdin && + + git show-ref | grep master >out && + test_line_count = 2 out && + awk "{print \$1}" out | uniq >out2 && + test_line_count = 1 out2 && + + test $(git rev-list --count HEAD) = 3 && + git cat-file --batch-check --batch-all-objects >all-objs && + test_line_count = 19 all-objs && + git log --format=%n --name-only | sort | uniq >filenames && + test_line_count = 9 filenames && + + test_path_is_missing .git/filter-repo/fast-export.original && + test_path_is_file .git/filter-repo/fast-export.filtered && + grep "^commit " .git/filter-repo/fast-export.filtered >out && + test_line_count = 2 out + ) +' + test_expect_success 'setup analyze_me' ' test_create_repo analyze_me && (