MCPcopy Index your code
hub / github.com/git/git / commit_is_complete

Function commit_is_complete

reflog.c:184–271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182}
183
184static int commit_is_complete(struct commit *commit)
185{
186 struct object_array study;
187 struct object_array found;
188 int is_incomplete = 0;
189 int i;
190
191 /* early return */
192 if (commit->object.flags & SEEN)
193 return 1;
194 if (commit->object.flags & INCOMPLETE)
195 return 0;
196 /*
197 * Find all commits that are reachable and are not marked as
198 * SEEN. Then make sure the trees and blobs contained are
199 * complete. After that, mark these commits also as SEEN.
200 * If some of the objects that are needed to complete this
201 * commit are missing, mark this commit as INCOMPLETE.
202 */
203 memset(&study, 0, sizeof(study));
204 memset(&found, 0, sizeof(found));
205 add_object_array(&commit->object, NULL, &study);
206 add_object_array(&commit->object, NULL, &found);
207 commit->object.flags |= STUDYING;
208 while (study.nr) {
209 struct commit *c;
210 struct commit_list *parent;
211
212 c = (struct commit *)object_array_pop(&study);
213 if (!c->object.parsed && !parse_object(the_repository, &c->object.oid))
214 c->object.flags |= INCOMPLETE;
215
216 if (c->object.flags & INCOMPLETE) {
217 is_incomplete = 1;
218 break;
219 }
220 else if (c->object.flags & SEEN)
221 continue;
222 for (parent = c->parents; parent; parent = parent->next) {
223 struct commit *p = parent->item;
224 if (p->object.flags & STUDYING)
225 continue;
226 p->object.flags |= STUDYING;
227 add_object_array(&p->object, NULL, &study);
228 add_object_array(&p->object, NULL, &found);
229 }
230 }
231 if (!is_incomplete) {
232 /*
233 * make sure all commits in "found" array have all the
234 * necessary objects.
235 */
236 for (i = 0; i < found.nr; i++) {
237 struct commit *c =
238 (struct commit *)found.objects[i].item;
239 if (!tree_is_complete(get_commit_tree_oid(c))) {
240 is_incomplete = 1;
241 c->object.flags |= INCOMPLETE;

Callers 1

keep_entryFunction · 0.85

Calls 6

add_object_arrayFunction · 0.85
object_array_popFunction · 0.85
parse_objectFunction · 0.85
tree_is_completeFunction · 0.85
get_commit_tree_oidFunction · 0.85
object_array_clearFunction · 0.85

Tested by

no test coverage detected