Skip to content

Commit 3e1bff2

Browse files
committed
Revert "filter-repo: fix ugly bug with mixing path filtering and renaming"
This reverts commit df6c865. The motivating example was wrong; path renaming should not be involved in path filtering, it only says how paths should be renamed if they happen to be selected. A subsequent commit will improve the documentation. Signed-off-by: Elijah Newren <[email protected]>
1 parent a4c1225 commit 3e1bff2

File tree

2 files changed

+9
-43
lines changed

2 files changed

+9
-43
lines changed

git-filter-repo

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,20 +2026,16 @@ EXAMPLES
20262026
args.path_changes = []
20272027
args.inclusive = False
20282028
else:
2029-
# Check for incompatible --path-rename (or equivalent specification
2030-
# from --paths-from-file) used together with either
2031-
# --use-base-name or --invert-paths.
2032-
if args.use_base_name or not args.inclusive:
2033-
if any(x[0] == 'rename' for x in args.path_changes):
2034-
raise SystemExit(_("Error: path renaming is incompatible with "
2035-
"both --use-base-name and --invert-paths"))
2036-
2037-
# If we only have renaming paths (i.e. we have no filtering paths),
2038-
# then no path should be filtered out. Based on how newname() works,
2039-
# the easiest way to achieve that is setting args.inclusive to False.
2029+
# Similarly, if we have no filtering paths, then no path should be
2030+
# filtered out. Based on how newname() works, the easiest way to
2031+
# achieve that is setting args.inclusive to False.
20402032
if not any(x[0] == 'filter' for x in args.path_changes):
20412033
args.inclusive = False
2042-
2034+
# Also check for incompatible --use-base-name and --path-rename flags.
2035+
if args.use_base_name:
2036+
if any(x[0] == 'rename' for x in args.path_changes):
2037+
raise SystemExit(_("Error: --use-base-name and --path-rename are "
2038+
"incompatible."))
20432039
# Also throw some sanity checks on git version here;
20442040
# PERF: remove these checks once new enough git versions are common
20452041
p = subproc.Popen('git fast-export -h'.split(),
@@ -3279,11 +3275,8 @@ class RepoFilter(object):
32793275
assert match_type in ('match','regex') # glob was translated to regex
32803276
if match_type == 'match' and filename_matches(match, full_pathname):
32813277
full_pathname = full_pathname.replace(match, repl, 1)
3282-
wanted = filtering_is_inclusive
32833278
if match_type == 'regex':
32843279
full_pathname = match.sub(repl, full_pathname)
3285-
if full_pathname != pathname:
3286-
wanted = filtering_is_inclusive
32873280
return full_pathname if (wanted == filtering_is_inclusive) else None
32883281

32893282
args = self._args

t/t9390-filter-repo.sh

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -178,33 +178,6 @@ test_expect_success '--paths-from-file' '
178178
)
179179
'
180180

181-
test_expect_success 'Mixing filtering and renaming paths' '
182-
test_create_repo path_filtering_and_renaming &&
183-
(
184-
cd path_filtering_and_renaming &&
185-
186-
>.gitignore &&
187-
mkdir -p src/main/java/com/org/{foo,bar} &&
188-
mkdir -p src/main/resources &&
189-
test_seq 1 10 >src/main/java/com/org/foo/uptoten &&
190-
test_seq 11 20 >src/main/java/com/org/bar/uptotwenty &&
191-
test_seq 1 7 >src/main/java/com/org/uptoseven &&
192-
test_seq 1 5 >src/main/resources/uptofive &&
193-
git add . &&
194-
git commit -m Initial &&
195-
196-
git filter-repo --path .gitignore --path src/main/resources --path-rename src/main/java/com/org/foo/:src/main/java/com/org/ --force &&
197-
198-
cat <<-EOF >expect &&
199-
.gitignore
200-
src/main/java/com/org/uptoten
201-
src/main/resources/uptofive
202-
EOF
203-
git ls-files >actual &&
204-
test_cmp expect actual
205-
)
206-
'
207-
208181
test_expect_success 'setup metasyntactic repo' '
209182
test_create_repo metasyntactic &&
210183
(
@@ -1120,7 +1093,7 @@ test_expect_success 'other startup error cases and requests for help' '
11201093
test_i18ngrep ": --analyze is incompatible with --stdin" err &&
11211094
11221095
test_must_fail git filter-repo --path-rename foo:bar --use-base-name 2>err &&
1123-
test_i18ngrep ": path renaming is incompatible with both --use-base-name and --invert-paths" err &&
1096+
test_i18ngrep ": --use-base-name and --path-rename are incompatible" err &&
11241097
11251098
test_must_fail git filter-repo --path-rename foo:bar/ 2>err &&
11261099
test_i18ngrep "either ends with a slash then both must." err &&

0 commit comments

Comments
 (0)