From fa515c8d103ef0377ae5c9689f1f7cdcdea81ea5 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Mon, 3 Sep 2018 20:38:58 -0700 Subject: [PATCH] filter-repo: protect against truncated fast-import input Use the 'feature done' ability to mark when the fast-import stream is finished, so that an aborted run (due to running into some kind of bug while filtering, whether a bug in the code, or an error in the repo or flags specified for the case under consideration) won't cause the repo to be rewritten. Signed-off-by: Elijah Newren --- git-filter-repo | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/git-filter-repo b/git-filter-repo index 3e97c9a..7160d1a 100755 --- a/git-filter-repo +++ b/git-filter-repo @@ -1074,6 +1074,7 @@ def fast_export_output(source_repo, extra_args = None): _IDS._avoid_ids_below(biggest_mark) # Create and return the git process + extra_args.append('--use-done-feature') return subprocess.Popen(["git", "fast-export", "--topo-order"] + extra_args, stdout=subprocess.PIPE, cwd=source_repo) @@ -1371,7 +1372,8 @@ def run_fast_filter(): input = sys.stdin fe_orig = None else: - fep_cmd = ['git', 'fast-export', '--no-data'] + args.revisions + fep_cmd = ['git', 'fast-export', + '--no-data', '--use-done-feature'] + args.revisions fep = subprocess.Popen(fep_cmd, stdout=subprocess.PIPE) input = fep.stdout if args.dry_run or args.debug: