From 85b1980d17d9a2f3bf36ff63b7e4ff6a17e5c523 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Sat, 21 Mar 2009 11:50:20 -0600 Subject: [PATCH] filter-repo: avoid using mark ids referred to in an --import-marks file Signed-off-by: Elijah Newren --- git-filter-repo | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/git-filter-repo b/git-filter-repo index 976785d..2b28a90 100755 --- a/git-filter-repo +++ b/git-filter-repo @@ -73,6 +73,10 @@ current_stream_number = 0 def record_id_rename(old_id, new_id, handle_transitivity = False): ids.record_rename(old_id, new_id, handle_transitivity) +def avoid_ids_below(skip_value): + '''Make sure that we don't use ids <= skip_value ''' + ids.count = max(ids.count, skip_value) + class GitElement(object): def __init__(self): self.type = None @@ -476,6 +480,13 @@ class FastExportFilter(object): def FastExportOutput(source_repo, extra_args = []): if not extra_args: extra_args = ["--all"] + for arg in extra_args: + if arg.startswith("--import-marks"): + filename = arg[len("--import-marks="):] + lines = open(filename,'r').read().strip().splitlines() + if lines: + biggest_mark = max([int(line.split()[0][1:]) for line in lines]) + avoid_ids_below(biggest_mark) return Popen(["git", "fast-export", "--topo-order"] + extra_args, stdout = PIPE, cwd = source_repo)