Skip to content

Commit 454fbbc

Browse files
author
Linus Torvalds
committed
git-rev-list: allow missing objects when the parent is marked UNINTERESTING
We still want the "top-most" uninteresting object to exist, so that we know that we have reached it.
1 parent 167a4a3 commit 454fbbc

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

rev-list.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ static void mark_tree_uninteresting(struct tree *tree)
203203
if (obj->flags & UNINTERESTING)
204204
return;
205205
obj->flags |= UNINTERESTING;
206+
if (!has_sha1_file(obj->sha1))
207+
return;
206208
if (parse_tree(tree) < 0)
207209
die("bad tree %s", sha1_to_hex(obj->sha1));
208210
entry = tree->entries;
@@ -224,6 +226,17 @@ static void mark_parents_uninteresting(struct commit *commit)
224226
while (parents) {
225227
struct commit *commit = parents->item;
226228
commit->object.flags |= UNINTERESTING;
229+
230+
/*
231+
* A missing commit is ok iff its parent is marked
232+
* uninteresting.
233+
*
234+
* We just mark such a thing parsed, so that when
235+
* it is popped next time around, we won't be trying
236+
* to parse it and get an error.
237+
*/
238+
if (!has_sha1_file(commit->object.sha1))
239+
commit->object.parsed = 1;
227240
parents = parents->next;
228241
}
229242
}
@@ -371,6 +384,8 @@ static struct commit *get_commit_reference(const char *name, unsigned int flags)
371384
object->flags |= flags;
372385
if (parse_commit(commit) < 0)
373386
die("unable to parse commit %s", name);
387+
if (flags & UNINTERESTING)
388+
mark_parents_uninteresting(commit);
374389
return commit;
375390
}
376391

0 commit comments

Comments
 (0)