From 28b479b79d3f4cf29437d20b0bd121ca6a1830ad Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Fri, 12 Mar 2021 15:30:18 +0200 Subject: [PATCH] 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 10401e4..8dcdad4 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 "