@matheusbsbs / matheus-bagliano / commits / aeeae1b771
Fork 0

revision traversal: allow UNINTERESTING objects to be missing

Most of the existing codepaths were meant to treat missing uninteresting objects to be a silently ignored non-error, but there were a few places in handle_commit() and add_parents_to_list(), which are two key functions in the revision traversal machinery, that cared: - When a tag refers to an object that we do not have, we barfed. We ignore such a tag if it is painted as UNINTERESTING with this change. - When digging deeper into the ancestry chain of a commit that is already painted as UNINTERESTING, in order to paint its parents UNINTERESTING, we barfed if parse_parent() for a parent commit object failed. We can ignore such a parent commit object. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Jan 27, 2009 at 23:19 UTC aeeae1b771020f1ac6692f89563e3f8689c704e7
2 files changed +44 -3
revision.c
+7 -3
@@ -183,8 +183,11 @@ static struct commit *handle_commit(struct rev_info *revs, struct object *object
183 if (!tag->tagged)
184 die("bad tag");
185 object = parse_object(tag->tagged->sha1);
186 - if (!object)
186 + if (!object) {
187 + if (flags & UNINTERESTING)
188 + return NULL;
189 die("bad object %s", sha1_to_hex(tag->tagged->sha1));
190 + }
191 }
192
193 /*
@@ -479,9 +482,10 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit,
482 while (parent) {
483 struct commit *p = parent->item;
484 parent = parent->next;
485 + if (p)
486 + p->object.flags |= UNINTERESTING;
487 if (parse_commit(p) < 0)
483 - return -1;
484 - p->object.flags |= UNINTERESTING;
488 + continue;
489 if (p->parents)
490 mark_parents_uninteresting(p);
491 if (p->object.flags & SEEN)
t/t5519-push-alternates.sh
+37
@@ -103,4 +103,41 @@ test_expect_success 'bob works and pushes' '
103 )
104 '
105
106 +test_expect_success 'alice works and pushes yet again' '
107 + (
108 + # Alice does not care what Bob does. She does not
109 + # even have to be aware of his existence. She just
110 + # keeps working and pushing
111 + cd alice-work &&
112 + echo more and more alice >file &&
113 + git commit -a -m sixth.1 &&
114 + echo more and more alice >>file &&
115 + git commit -a -m sixth.2 &&
116 + echo more and more alice >>file &&
117 + git commit -a -m sixth.3 &&
118 + git push ../alice-pub
119 + )
120 +'
121 +
122 +test_expect_success 'bob works and pushes again' '
123 + (
124 + cd alice-pub &&
125 + git cat-file commit master >../bob-work/commit
126 + )
127 + (
128 + # This time Bob does not pull from Alice, and
129 + # the master branch at her public repository points
130 + # at a commit Bob does not fully know about, but
131 + # he happens to have the commit object (but not the
132 + # necessary tree) in his repository from Alice.
133 + # This should not prevent the push by Bob from
134 + # succeeding.
135 + cd bob-work &&
136 + git hash-object -t commit -w commit &&
137 + echo even more bob >file &&
138 + git commit -a -m seventh &&
139 + git push ../bob-pub
140 + )
141 +'
142 +
143 test_done