Skip to content

Commit 28b479b

Browse files
committed
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 <[email protected]>
1 parent 407d15d commit 28b479b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

git-filter-repo

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1622,7 +1622,10 @@ class FilteringOptions(object):
16221622
if suffix.startswith('rename'):
16231623
mod_type = 'rename'
16241624
match_type = option_string[len('--path-rename-'):] or 'match'
1625-
values = values.split(b':', 1)
1625+
values = values.split(b':')
1626+
if len(values) != 2:
1627+
raise SystemExit(_("Error: --path-rename expects one colon in its"
1628+
" argument: <old_name:new_name>."))
16261629
if values[0] and values[1] and not (
16271630
values[0].endswith(b'/') == values[1].endswith(b'/')):
16281631
raise SystemExit(_("Error: With --path-rename, if OLD_NAME and "

0 commit comments

Comments
 (0)