From 453128fff77439c6006155900d934cb415b055eb Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 21 Oct 2020 22:31:00 +0200 Subject: [PATCH 01/12] Ignore the generated Python cache Signed-off-by: Johannes Schindelin --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6dfbd93..cd5ded4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /Documentation/man1/ /t/test-results /t/trash directory* +/__pycache__/ From 580e0f03954238b3708bd3f5dd3f1cb43b3d087b Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 21 Oct 2020 16:56:58 +0200 Subject: [PATCH 02/12] Test data and scripts must have Unix line endings The tests will otherwise fail. Signed-off-by: Johannes Schindelin --- .gitattributes | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9d44a69 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +*.sh eol=lf +*.py eol=lf +/git-filter-repo eol=lf +/contrib/filter-repo-demos/[a-z]* eol=lf +/t/t9*/* eol=lf From 6c475a7e091f6621dcc30dfa0a901834f80239cf Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 21 Oct 2020 19:23:35 +0200 Subject: [PATCH 03/12] t9390: use the correct prereq when using "funny" file names Signed-off-by: Johannes Schindelin --- t/t9390-filter-repo.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/t/t9390-filter-repo.sh b/t/t9390-filter-repo.sh index 8ab4749..124b77e 100755 --- a/t/t9390-filter-repo.sh +++ b/t/t9390-filter-repo.sh @@ -298,7 +298,7 @@ setup_metasyntactic_repo() { ) } -test_expect_success '--tag-rename' ' +test_expect_success FUNNYNAMES '--tag-rename' ' setup_metasyntactic_repo && ( git clone file://"$(pwd)"/metasyntactic tag_rename && @@ -342,7 +342,7 @@ test_expect_success 'tag of tag before relevant portion of history' ' ) ' -test_expect_success '--subdirectory-filter' ' +test_expect_success FUNNYNAMES '--subdirectory-filter' ' setup_metasyntactic_repo && ( git clone file://"$(pwd)"/metasyntactic subdir_filter && @@ -361,7 +361,7 @@ test_expect_success '--subdirectory-filter' ' ) ' -test_expect_success '--subdirectory-filter with trailing slash' ' +test_expect_success FUNNYNAMES '--subdirectory-filter with trailing slash' ' setup_metasyntactic_repo && ( git clone file://"$(pwd)"/metasyntactic subdir_filter_2 && @@ -380,7 +380,7 @@ test_expect_success '--subdirectory-filter with trailing slash' ' ) ' -test_expect_success '--to-subdirectory-filter' ' +test_expect_success FUNNYNAMES '--to-subdirectory-filter' ' setup_metasyntactic_repo && ( git clone file://"$(pwd)"/metasyntactic to_subdir_filter && @@ -400,7 +400,7 @@ test_expect_success '--to-subdirectory-filter' ' ) ' -test_expect_success '--use-base-name' ' +test_expect_success FUNNYNAMES '--use-base-name' ' setup_metasyntactic_repo && ( git clone file://"$(pwd)"/metasyntactic use_base_name && @@ -419,7 +419,7 @@ test_expect_success '--use-base-name' ' ) ' -test_expect_success 'refs/replace/ to skip a parent' ' +test_expect_success FUNNYNAMES 'refs/replace/ to skip a parent' ' setup_metasyntactic_repo && ( git clone file://"$(pwd)"/metasyntactic replace_skip_ref && @@ -441,7 +441,7 @@ test_expect_success 'refs/replace/ to skip a parent' ' ) ' -test_expect_success 'refs/replace/ to add more initial history' ' +test_expect_success FUNNYNAMES 'refs/replace/ to add more initial history' ' setup_metasyntactic_repo && ( git clone file://"$(pwd)"/metasyntactic replace_add_refs && @@ -476,7 +476,7 @@ test_expect_success 'refs/replace/ to add more initial history' ' ) ' -test_expect_success 'creation/deletion/updating of replace refs' ' +test_expect_success FUNNYNAMES 'creation/deletion/updating of replace refs' ' setup_metasyntactic_repo && ( git clone file://"$(pwd)"/metasyntactic replace_handling && @@ -535,7 +535,7 @@ test_expect_success 'creation/deletion/updating of replace refs' ' ) ' -test_expect_success '--debug' ' +test_expect_success FUNNYNAMES '--debug' ' setup_metasyntactic_repo && ( git clone file://"$(pwd)"/metasyntactic debug && @@ -558,7 +558,7 @@ test_expect_success '--debug' ' ) ' -test_expect_success '--dry-run' ' +test_expect_success FUNNYNAMES '--dry-run' ' setup_metasyntactic_repo && ( git clone file://"$(pwd)"/metasyntactic dry_run && @@ -586,7 +586,7 @@ test_expect_success '--dry-run' ' ) ' -test_expect_success '--dry-run --debug' ' +test_expect_success FUNNYNAMES '--dry-run --debug' ' setup_metasyntactic_repo && ( git clone file://"$(pwd)"/metasyntactic dry_run_debug && @@ -614,7 +614,7 @@ test_expect_success '--dry-run --debug' ' ) ' -test_expect_success '--dry-run --stdin' ' +test_expect_success FUNNYNAMES '--dry-run --stdin' ' setup_metasyntactic_repo && ( git clone file://"$(pwd)"/metasyntactic dry_run_stdin && @@ -1565,7 +1565,7 @@ test_expect_success '--state-branch with expanding paths and refs' ' ) ' -test_expect_success 'degenerate merge with non-matching filenames' ' +test_expect_success FUNNYNAMES 'degenerate merge with non-matching filenames' ' test_create_repo degenerate_merge_differing_filenames && ( cd degenerate_merge_differing_filenames && From f1ee28d78fbb33994ce52f72e457fbca9c0f6602 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 21 Oct 2020 22:58:33 +0200 Subject: [PATCH 04/12] t9390: expect the correct line count in `--strip-blobs-with-ids` In that test case, we expect the line count to be 5, but it is actually 6 lines that we should expect: numbers/medium.num numbers/small.num sequence/know whatever words/know Note the empty line at the top: this list is generated via `git log --format=%n`, and that `%n` stands for "newline", meaning that we _must_ expect an empty line. This expectation seems to have been broken already in the commit that added the test case: b6a35f8 (filter-repo: implement --strip-blobs-with-ids, 2019-05-30). It was hidden for such a long time by a broken &&-chain, which we will fix next. Signed-off-by: Johannes Schindelin --- t/t9390-filter-repo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t9390-filter-repo.sh b/t/t9390-filter-repo.sh index 124b77e..9cfda4e 100755 --- a/t/t9390-filter-repo.sh +++ b/t/t9390-filter-repo.sh @@ -937,7 +937,7 @@ test_expect_success '--strip-blobs-with-ids' ' git filter-repo --strip-blobs-with-ids ../bad-ids --replace-text ../replace-rules && git log --format=%n --name-only | sort | uniq >../filenames && - test_line_count = 5 ../filenames && + test_line_count = 6 ../filenames && ! grep sequence/to ../filenames && ! grep words/to ../filenames && ! grep capricious ../filenames && From 8bc195673cf9514f89fd5358d2788ff2eee7be49 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 21 Oct 2020 19:24:03 +0200 Subject: [PATCH 05/12] t9390: close link of broken &&-chain Signed-off-by: Johannes Schindelin --- t/t9390-filter-repo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t9390-filter-repo.sh b/t/t9390-filter-repo.sh index 9cfda4e..b0d7cdf 100755 --- a/t/t9390-filter-repo.sh +++ b/t/t9390-filter-repo.sh @@ -942,7 +942,7 @@ test_expect_success '--strip-blobs-with-ids' ' ! grep words/to ../filenames && ! grep capricious ../filenames && ! grep fickle ../filenames && - ! grep mercurial ../filenames + ! grep mercurial ../filenames && # Remove the temporary auxiliary files rm ../bad-ids && From e6ffeded2e8dbdd6675021f52e54bc85de041d21 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 21 Oct 2020 19:24:12 +0200 Subject: [PATCH 06/12] t9390: avoid using Bash-ism `<(...)` The problem with this is that on Windows, we use the MSYS2 Bash which uses the POSIX emulation layer called "MSYS2 runtime" that pretends that there _is_ something like the `/dev/fd/` namespace, and tells `git.exe` about it, but `git.exe` does not use the POSIX emulation layer, and hence has no idea what Bash is talking about. Besides, we should avoid pipes, just as we do in the Git project. Signed-off-by: Johannes Schindelin --- t/t9390-filter-repo.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/t/t9390-filter-repo.sh b/t/t9390-filter-repo.sh index b0d7cdf..899e9f1 100755 --- a/t/t9390-filter-repo.sh +++ b/t/t9390-filter-repo.sh @@ -917,7 +917,8 @@ test_expect_success '--strip-blobs-with-ids' ' grep fake_submodule ../filenames && # Strip "a certain file" files - git filter-repo --strip-blobs-with-ids <(echo deadbeefdeadbeefdeadbeefdeadbeefdeadbeef) && + echo deadbeefdeadbeefdeadbeefdeadbeefdeadbeef >../input && + git filter-repo --strip-blobs-with-ids ../input && git log --format=%n --name-only | sort | uniq >../filenames && test_line_count = 10 ../filenames && @@ -1232,10 +1233,12 @@ test_expect_success 'other startup error cases and requests for help' ' test_must_fail git filter-repo --path-rename foo:bar/ 2>err && test_i18ngrep "either ends with a slash then both must." err && - test_must_fail git filter-repo --paths-from-file <(echo "foo==>bar/") 2>err && + echo "foo==>bar/" >input && + test_must_fail git filter-repo --paths-from-file input 2>err && test_i18ngrep "either ends with a slash then both must." err && - test_must_fail git filter-repo --paths-from-file <(echo "glob:*.py==>newname") 2>err && + echo "glob:*.py==>newname" >input && + test_must_fail git filter-repo --paths-from-file input 2>err && test_i18ngrep "renaming globs makes no sense" err && test_must_fail git filter-repo --strip-blobs-bigger-than 3GiB 2>err && @@ -1358,7 +1361,8 @@ test_expect_success '--refs and --replace-text' ' git clone file://"$(pwd)"/path_rename refs_and_replace_text && cd refs_and_replace_text && git rev-parse --short=10 HEAD~1 >myparent && - git filter-repo --force --replace-text <(echo "10==>TEN") --refs $(cat myparent)..master && + echo "10==>TEN" >input && + git filter-repo --force --replace-text input --refs $(cat myparent)..master && cat <<-EOF >expect && TEN11 EOF @@ -1629,7 +1633,8 @@ test_expect_success 'degenerate merge with typechange' ' git ls-files >actual && test_cmp expect actual && - test_line_count = 2 <(git log --oneline HEAD) + git log --oneline HEAD >input && + test_line_count = 2 input ) ' From 6967fad156dacf790fc04eb668e5be7c4b8bbf75 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 21 Oct 2020 22:31:16 +0200 Subject: [PATCH 07/12] t9390: avoid using `colrm` While it is true that `colrm` is available on macOS by default, and even in Ubuntu (thanks to the `bsdmainutils` package), it is not available on Windows. Let's use `cut` instead. Signed-off-by: Johannes Schindelin --- t/t9390-filter-repo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t9390-filter-repo.sh b/t/t9390-filter-repo.sh index 899e9f1..61c7efa 100755 --- a/t/t9390-filter-repo.sh +++ b/t/t9390-filter-repo.sh @@ -1675,7 +1675,7 @@ test_expect_success 'tweaking just a tag' ' test_expect_success '--version' ' git filter-repo --version >actual && - git hash-object ../../git-filter-repo | colrm 13 >expect && + git hash-object ../../git-filter-repo | cut -c 1-12 >expect && test_cmp expect actual ' From 848cd652f049e0f5c7447873d4ed3e6a041d9ea6 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 22 Oct 2020 00:03:57 +0200 Subject: [PATCH 08/12] t9390: work around clash with MSYS2's Unix<->Win32 path conversion MSYS2 tries to be very helpful, and in most cases it even works, by converting parameters passed from inside an MSYS2 Bash to a non-MSYS2 application (such as `git.exe`) if they look like Unix-style paths or path lists. Sometimes, however, this automatic path conversion is unhelpful, e.g. when passing the parameter `foo:.` to Git, which MSYS2 will readily convert to a Windows-style path list: `foo;bar` (i.e. using a semicolon instead of a colon). Happily, there is a way to avoid that: the `MSYS_NO_PATHCONV` variable. Let's use it. Signed-off-by: Johannes Schindelin --- t/t9390-filter-repo.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/t/t9390-filter-repo.sh b/t/t9390-filter-repo.sh index 61c7efa..01a6966 100755 --- a/t/t9390-filter-repo.sh +++ b/t/t9390-filter-repo.sh @@ -1197,6 +1197,12 @@ test_expect_success 'startup sanity checks' ' test_expect_success 'other startup error cases and requests for help' ' ( + # prevent MSYS2 (Git for Windows) from converting the colon to + # a semicolon when encountering parameters that look like + # Unix-style, colon-separated path lists (such as `foo:.`) + MSYS_NO_PATHCONV=1 && + export MSYS_NO_PATHCONV + git init startup_errors && cd startup_errors && From fe79ec9912b1027ae8de60e319b350b29f3d3524 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 22 Oct 2020 00:11:29 +0200 Subject: [PATCH 09/12] t9390: work around yet another Unix<->Win32 path issue On Windows, there is no absolute path `/fake/path`, but MSYS2 (which Git for Windows uses e.g. for running Bash scripts) pretends that it exists. This only works within MSYS2 applications, of course, so... when MSYS2 sees that we hand a parameter to a non-MSYS2 application in a shell script, it helpfully converts it to the full path (prepending MSYS2's pseudo root directory). Let's work around that by using a Win32-compatible path to begin with: `$(pwd)` produces that on Windows. On other platforms, it still works. As a bonus, this safe-guards our test against a setup where `/fake/path` _actually exists_. Stranger things have been seen in the wild, after all. Signed-off-by: Johannes Schindelin --- t/t9390-filter-repo.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/t/t9390-filter-repo.sh b/t/t9390-filter-repo.sh index 01a6966..3c8f849 100755 --- a/t/t9390-filter-repo.sh +++ b/t/t9390-filter-repo.sh @@ -1291,8 +1291,9 @@ test_expect_success 'mailmap sanity checks' ' git clone file://"$(pwd)"/analyze_me mailmap_sanity_checks && cd mailmap_sanity_checks && - test_must_fail git filter-repo --mailmap /fake/path 2>../err && - test_i18ngrep "Cannot read /fake/path" ../err && + fake=$(pwd)/fake && + test_must_fail git filter-repo --mailmap "$fake"/path 2>../err && + test_i18ngrep "Cannot read $fake/path" ../err && echo "Total Bogus" >../whoopsies && test_must_fail git filter-repo --mailmap ../whoopsies 2>../err && From 85afdf9da9e80a7762f5fc20565f15d0bf03a84a Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 21 Oct 2020 21:41:07 +0200 Subject: [PATCH 10/12] t9391: don't rely on the system gitconfig defining core.autocrlf=false The test case t9391.12 specifically wants to test LF vs CR/LF line ending issues, expecting `core.autoCRLF` to default to `false`. This is true on Linux and macOS and pretty much everywhere else, except on Windows. Let's make sure that the test operates with the `core.autoCRLF` value it assumes to operate under. Signed-off-by: Johannes Schindelin --- t/t9391-filter-repo-lib-usage.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/t/t9391-filter-repo-lib-usage.sh b/t/t9391-filter-repo-lib-usage.sh index f2ac101..a8fa48f 100755 --- a/t/t9391-filter-repo-lib-usage.sh +++ b/t/t9391-filter-repo-lib-usage.sh @@ -168,6 +168,7 @@ test_expect_success 'lint-history' ' test_create_repo lint-history && ( cd lint-history && + git config core.autocrlf false && echo initial >content && git add content && git commit -m "initial" && From d0dcece202a0b558e68b860bf7a4f70797b4d8a6 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 21 Oct 2020 23:49:00 +0200 Subject: [PATCH 11/12] t9391: guard `dos2unix` use behind a prereq Not all setups have `dos2unix`. Most notably, the Ubuntu and macOS agents of GitHub Actions don't. Signed-off-by: Johannes Schindelin --- t/t9391-filter-repo-lib-usage.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/t/t9391-filter-repo-lib-usage.sh b/t/t9391-filter-repo-lib-usage.sh index a8fa48f..761f43a 100755 --- a/t/t9391-filter-repo-lib-usage.sh +++ b/t/t9391-filter-repo-lib-usage.sh @@ -164,6 +164,11 @@ test_expect_success 'other error cases' ' ) ' +test_lazy_prereq DOS2UNIX ' + dos2unix -h + test $? -ne 127 +' + test_expect_success 'lint-history' ' test_create_repo lint-history && ( @@ -181,10 +186,13 @@ test_expect_success 'lint-history' ' git add content && git commit -m "oops, that was embarassing" && - $CONTRIB_DIR/lint-history --filenames-important dos2unix && - echo 2 >expect && - git rev-list --count HEAD >actual && - test_cmp expect actual + if test_have_prereq DOS2UNIX + then + $CONTRIB_DIR/lint-history --filenames-important dos2unix && + echo 2 >expect && + git rev-list --count HEAD >actual && + test_cmp expect actual + fi ) ' From d28b2a7346c673832d4d3d4c64ce5c555846df2b Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 21 Oct 2020 16:57:17 +0200 Subject: [PATCH 12/12] Add a GitHub workflow to test this thing Signed-off-by: Johannes Schindelin --- .github/workflows/test.yml | 49 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..1d22fe7 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,49 @@ +name: Run tests + +on: [push, pull_request] + +jobs: + run-tests: + strategy: + matrix: + os: [ 'windows', 'ubuntu', 'macos' ] + fail-fast: false + runs-on: ${{ matrix.os }}-latest + steps: + - uses: actions/checkout@v2 + - name: Setup python + uses: actions/setup-python@v2 + with: + python-version: 3.x + - name: test + shell: bash + run: | + # setup-python puts `python` into the `PATH`, not `python3`, yet + # `git-filter-repo` expects `python3` in the `PATH`. Let's add + # a shim. + printf '#!/bin/sh\n\nexec python "$@"\n' >python3 && + + export PATH=$PWD:$PATH && + export PYTHONPATH=$PWD && + export TEST_SHELL_PATH=/bin/sh && + + failed=0 && + cd t && + for t in t[0-9]*.sh + do + printf '\n\n== %s ==\n' "$t" && + bash $t -q -v -x || + failed=$(($failed+1)) + done && + if test 0 != $failed + then + mkdir ../failed && + tar czf ../failed/failed.tar.gz . + exit 1 + fi + - name: upload failed tests' directories + if: failure() + uses: actions/upload-artifact@v1 + with: + name: failed-${{ matrix.os }} + path: failed