Skip to content

Commit fa48d71

Browse files
committed
Add rough cut of 'blobbase'
Like interactive rebase for blobs Signed-off-by: Stuart MacDonald <[email protected]>
1 parent c1d8461 commit fa48d71

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

git-filter-repo

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,6 +2029,12 @@ EXAMPLES
20292029
contents.add_argument('--strip-blobs-with-ids', metavar='BLOB-ID-FILENAME',
20302030
help=_("Read git object ids from each line of the given file, and "
20312031
"strip all of them from history"))
2032+
contents.add_argument('--blobbase', metavar='BLOB-SHAS-AND-PATHS',
2033+
help=_("Process an annotated blob-shas-and-paths.txt file. 'blobbase' "
2034+
"because it uses a command system similar to git's interactive "
2035+
"rebase. Commands: k, keep <sha> = keep blob; s, strip <sha> = "
2036+
"strip blob. Keep is the default if no command has been "
2037+
"specified."))
20322038

20332039
refrename = parser.add_argument_group(title=_("Renaming of refs "
20342040
"(see also --refname-callback)"))
@@ -2444,6 +2450,16 @@ EXAMPLES
24442450
args.strip_blobs_with_ids = set(f.read().split())
24452451
else:
24462452
args.strip_blobs_with_ids = set()
2453+
# blobbase leverages args.strip_blobs_with_ids
2454+
if args.blobbase:
2455+
# Commands: k, keep = keep blob; s, strip = strip blob. No command means keep.
2456+
with open(args.blobbase, 'br') as f:
2457+
# Header lines start with "===" or "Format:"
2458+
# Blank lines are blank, comments start with "#"
2459+
# Not annotating a blob is interpreted as "keep", keep is keep
2460+
# All this has to do is find the strip lines which are distinct from the above lines
2461+
# git.git:sequencer.c:parse_insn_line() does not require the command to be in the first column
2462+
args.strip_blobs_with_ids.update(parts[1] for parts in (line.split() for line in f) if len(parts) >= 2 and parts[0].decode()[0:1] == 's')
24472463
if (args.partial or args.refs) and not args.replace_refs:
24482464
args.replace_refs = 'update-no-add'
24492465
args.repack = not (args.partial or args.refs or args.no_gc)
@@ -2874,6 +2890,7 @@ class RepoAnalyze(object):
28742890
# List of filenames and sizes in descending order
28752891
with open(os.path.join(reportdir, b"blob-shas-and-paths.txt"), 'bw') as f:
28762892
f.write(("=== %s ===\n" % _("Files by sha and associated pathnames in reverse size")).encode())
2893+
f.write(("=== %s ===\n" % _("To use blobbase, prefix lines with commands: k, keep = keep blob; s, strip = strip blob. No command means keep.")).encode())
28772894
f.write(_("Format: sha, unpacked size, packed size, filename(s) object stored as\n").encode())
28782895
for sha, size in sorted(stats['packed_size'].items(),
28792896
key=lambda x:(x[1],x[0]), reverse=True):

0 commit comments

Comments
 (0)