MCPcopy Create free account
hub / github.com/git/git / mark_object

Function mark_object

builtin/fsck.c:125–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123static struct object_array pending;
124
125static int mark_object(struct object *obj, enum object_type type,
126 void *data, struct fsck_options *options)
127{
128 struct object *parent = data;
129
130 /*
131 * The only case data is NULL or type is OBJ_ANY is when
132 * mark_object_reachable() calls us. All the callers of
133 * that function has non-NULL obj hence ...
134 */
135 if (!obj) {
136 /* ... these references to parent->fld are safe here */
137 printf_ln(_("broken link from %7s %s"),
138 printable_type(options->repo, &parent->oid, parent->type),
139 describe_object(&parent->oid));
140 printf_ln(_("broken link from %7s %s"),
141 (type == OBJ_ANY ? _("unknown") : type_name(type)),
142 _("unknown"));
143 errors_found |= ERROR_REACHABLE;
144 return 1;
145 }
146
147 if (type != OBJ_ANY && obj->type != type)
148 /* ... and the reference to parent is safe here */
149 objerror(options->repo, parent, _("wrong object type in link"));
150
151 if (obj->flags & REACHABLE)
152 return 0;
153 obj->flags |= REACHABLE;
154
155 if (is_promisor_object(options->repo, &obj->oid))
156 /*
157 * Further recursion does not need to be performed on this
158 * object since it is a promisor object (so it does not need to
159 * be added to "pending").
160 */
161 return 0;
162
163 if (!(obj->flags & HAS_OBJ)) {
164 if (parent && !odb_has_object(options->repo->objects, &obj->oid,
165 ODB_HAS_OBJECT_RECHECK_PACKED)) {
166 printf_ln(_("broken link from %7s %s\n"
167 " to %7s %s"),
168 printable_type(options->repo, &parent->oid, parent->type),
169 describe_object(&parent->oid),
170 printable_type(options->repo, &obj->oid, obj->type),
171 describe_object(&obj->oid));
172 errors_found |= ERROR_REACHABLE;
173 }
174 return 1;
175 }
176
177 add_object_array(obj, NULL, &pending);
178 return 0;
179}
180
181static void mark_object_reachable(struct object *obj)
182{

Callers 1

mark_object_reachableFunction · 0.70

Calls 8

printf_lnFunction · 0.85
printable_typeFunction · 0.85
describe_objectFunction · 0.85
type_nameFunction · 0.85
objerrorFunction · 0.85
is_promisor_objectFunction · 0.85
odb_has_objectFunction · 0.85
add_object_arrayFunction · 0.85

Tested by

no test coverage detected