diff --git a/git_handler.py b/git_handler.py index aa2dadf0414402514e4a7a7a236465efd4ee4834_Z2l0X2hhbmRsZXIucHk=..d7b8768d005a05c88e7c75820d30ce47518eb60a_Z2l0X2hhbmRsZXIucHk= 100644 --- a/git_handler.py +++ b/git_handler.py @@ -360,8 +360,8 @@ def generate_pack_contents(self, want, have): graph_walker = SimpleFetchGraphWalker(want, self.git.get_parents) next = graph_walker.next() - shas = [] + shas = set() while next: if next in have: graph_walker.ack(next) else: @@ -364,6 +364,6 @@ while next: if next in have: graph_walker.ack(next) else: - shas.append(next) + shas.add(next) next = graph_walker.next() @@ -369,5 +369,7 @@ next = graph_walker.next() - + + seen = [] + # so now i have the shas, need to turn them into a list of # tuples (sha, path) for ALL the objects i'm sending # TODO : don't send blobs or trees they already have @@ -377,4 +379,7 @@ for (mode, name, sha) in tree.entries(): if mode == 57344: # TODO : properly handle submodules continue + if sha in seen: + continue + obj = self.git.get_object(sha) @@ -380,4 +385,5 @@ obj = self.git.get_object(sha) + seen.append(sha) if isinstance (obj, Blob): changes.append((obj, path + name)) elif isinstance(obj, Tree): @@ -381,7 +387,7 @@ if isinstance (obj, Blob): changes.append((obj, path + name)) elif isinstance(obj, Tree): - changes.extend (get_objects (obj, path + name + '/')) + changes.extend(get_objects(obj, path + name + '/')) return changes objects = []