Skip to content

Commit cdb7b77

Browse files
committed
filter-repo: repack with --source or --target
When using --source or --target in combination with filtering paths, users were surprised out how large the resulting repository was. The usage of --source and --target were turning off repacking; while we don't want repacking for partial history rewrites and --source and --target turn on some of the other features we want with partial history rewrites, repacking is something that we still want turned on. Reported-by: Alexey Volkov <[email protected]> Signed-off-by: Elijah Newren <[email protected]>
1 parent 2bfb9cf commit cdb7b77

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

git-filter-repo

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2183,6 +2183,7 @@ EXAMPLES
21832183
args.strip_blobs_with_ids = set()
21842184
if (args.partial or args.refs) and not args.replace_refs:
21852185
args.replace_refs = 'update-no-add'
2186+
args.repack = not (args.partial or args.refs)
21862187
if args.refs or args.source or args.target:
21872188
args.partial = True
21882189
if not args.refs:
@@ -3890,9 +3891,8 @@ class RepoFilter(object):
38903891
self._save_marks_files()
38913892

38923893
# Notify user how long it took, before doing a gc and such
3893-
repack = (not self._args.partial)
38943894
msg = "New history written in {:.2f} seconds..."
3895-
if repack:
3895+
if self._args.repack:
38963896
msg = "New history written in {:.2f} seconds; now repacking/cleaning..."
38973897
print(msg.format(time.time()-start))
38983898

@@ -3914,9 +3914,11 @@ class RepoFilter(object):
39143914
# Write out data about run
39153915
self._record_metadata(self.results_tmp_dir(), self._orig_refs)
39163916

3917-
# If repack, then nuke the reflogs and repack. If reset, do a reset --hard
3917+
# Final cleanup:
3918+
# If we need a repack, then nuke the reflogs and repack.
3919+
# If we need a reset, do a reset --hard
39183920
reset = not GitUtils.is_repository_bare(target_working_dir)
3919-
RepoFilter.cleanup(target_working_dir, repack, reset,
3921+
RepoFilter.cleanup(target_working_dir, self._args.repack, reset,
39203922
run_quietly=self._args.quiet,
39213923
show_debuginfo=self._args.debug)
39223924

0 commit comments

Comments
 (0)