From 00a914c3e4772bed8f713cbd1e2b409d57e93dc9 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Thu, 11 Mar 2021 14:46:18 -0800 Subject: [PATCH 1/4] filter-repo: fix --use-mailmap --use-mailmap was defined as `--mailmap .mailmap` except that it would set args.mailmap to ".mailmap" rather than b".mailmap" (in other words, it accidentally set it to a string rather than a bytestring). Since the --mailmap parameter is always passed as a bytestring, we ran into errors with calling unknown functions due to the type mismatch. Signed-off-by: Elijah Newren --- git-filter-repo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-filter-repo b/git-filter-repo index 10401e45..8fc4745b 100755 --- a/git-filter-repo +++ b/git-filter-repo @@ -1862,7 +1862,7 @@ EXAMPLES "part of git history, historical versions of the file will " "be ignored; only the current contents are consulted.")) people.add_argument('--use-mailmap', dest='mailmap', - action='store_const', const='.mailmap', + action='store_const', const=b'.mailmap', help=_("Same as: '--mailmap .mailmap' ")) parents = parser.add_argument_group(title=_("Parent rewriting")) From 8dc74b1633a590216ff00632544befac58cd9d5d Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Fri, 12 Mar 2021 15:30:18 +0200 Subject: [PATCH 2/4] Fix bug in --path-rename argument without colon The --path-rename flag expected an argument with a colon character (':') in it, which it assumed without checking. If the user gave an argument with no colon in it, this backtrace would be shown: File "/usr/local/bin/git-filter-repo", line 1626, in __call__ if values[0] and values[1] and not ( IndexError: list index out of range Add a real error message in place of the backtrace. Also check that there's exactly one colon; show an error message if there's more than one, as that syntax has no interpretation that is obviously the right one. Signed-off-by: Lassi Kortela --- git-filter-repo | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/git-filter-repo b/git-filter-repo index 10401e45..8dcdad42 100755 --- a/git-filter-repo +++ b/git-filter-repo @@ -1622,7 +1622,10 @@ class FilteringOptions(object): if suffix.startswith('rename'): mod_type = 'rename' match_type = option_string[len('--path-rename-'):] or 'match' - values = values.split(b':', 1) + values = values.split(b':') + if len(values) != 2: + raise SystemExit(_("Error: --path-rename expects one colon in its" + " argument: .")) if values[0] and values[1] and not ( values[0].endswith(b'/') == values[1].endswith(b'/')): raise SystemExit(_("Error: With --path-rename, if OLD_NAME and " From 6ef207d280e0b0bcde1483163067b4050ea0f670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vilius=20=C5=A0umskas?= Date: Wed, 17 Mar 2021 00:35:40 +0200 Subject: [PATCH 3/4] Improve installation documentation for Windows users Since Windows do allow to install Python more easily these days and takes care of most PATH stuff, use recommendations from Microsoft. The only hiccup is that Python from the store cannot parse get-filter-repo SHEBANG value when the script is installed via pip. That value is very long by default. Changing it to #!\python.exe solves the issue. Tested under clean installation of Windows 10 Enterprise version 20H2. --- INSTALL.md | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 8e6791ef..a139b304 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -19,8 +19,33 @@ these versions. # Notes for Windows Users -It seems that the default python on Windows is not fully functional, -and windows might not allow executing python scripts by default. See +If you don't do a full blown Python web development on Windows the +best way to install git-filter-repo is to use Python and pip from +[Microsoft +Store](https://docs.microsoft.com/en-us/windows/python/beginners). +Follow these simple steps: + +1. Install Python from Microsoft Store. +2. Run `pip install git-filter-repo` from the Windows Command Prompt. +3. Copy git-filter-repo file from + *%LOCALAPPDATA%\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts* + to the directory pointed to by `git --exec-path`, + + or + + add + *%LOCALAPPDATA%\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts* + to you PATH environment variable. + + The folder above could be different depending on your Python's + version. +4. Change first line of the git-filter-repo script to +`#!\python.exe`. + +If you have Python installed via +[WSL](https://docs.microsoft.com/en-us/windows/python/web-frameworks) +or from official [Python for Windows +installer](https://www.python.org/downloads/windows/) see [issue 124](https://github.com/newren/git-filter-repo/issues/124), [issue 36](https://github.com/newren/git-filter-repo/issues/36), and [this git mailing list From be9b0be6c74cbf81ec6a38d602186ec84a4d4488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vilius=20=C5=A0umskas?= Date: Fri, 11 Jun 2021 16:39:26 +0300 Subject: [PATCH 4/4] Remove step 4 as this is now fixed in Git for Windows --- INSTALL.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index a139b304..621f7816 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -39,8 +39,6 @@ Follow these simple steps: The folder above could be different depending on your Python's version. -4. Change first line of the git-filter-repo script to -`#!\python.exe`. If you have Python installed via [WSL](https://docs.microsoft.com/en-us/windows/python/web-frameworks)