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

Function read_graft_line

commit.c:249–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247}
248
249struct commit_graft *read_graft_line(struct strbuf *line)
250{
251 /* The format is just "Commit Parent1 Parent2 ...\n" */
252 int i, phase;
253 const char *tail = NULL;
254 struct commit_graft *graft = NULL;
255 struct object_id dummy_oid, *oid;
256
257 strbuf_rtrim(line);
258 if (!line->len || line->buf[0] == '#')
259 return NULL;
260 /*
261 * phase 0 verifies line, counts hashes in line and allocates graft
262 * phase 1 fills graft
263 */
264 for (phase = 0; phase < 2; phase++) {
265 oid = graft ? &graft->oid : &dummy_oid;
266 if (parse_oid_hex(line->buf, oid, &tail))
267 goto bad_graft_data;
268 for (i = 0; *tail != '\0'; i++) {
269 oid = graft ? &graft->parent[i] : &dummy_oid;
270 if (!isspace(*tail++) || parse_oid_hex(tail, oid, &tail))
271 goto bad_graft_data;
272 }
273 if (!graft) {
274 graft = xmalloc(st_add(sizeof(*graft),
275 st_mult(sizeof(struct object_id), i)));
276 graft->nr_parent = i;
277 }
278 }
279 return graft;
280
281bad_graft_data:
282 error("bad graft data: %s", line->buf);
283 assert(!graft);
284 return NULL;
285}
286
287static int read_graft_file(struct repository *r, const char *graft_file)
288{

Callers 2

read_graft_fileFunction · 0.85
read_ancestryFunction · 0.85

Calls 6

strbuf_rtrimFunction · 0.85
parse_oid_hexFunction · 0.85
st_addFunction · 0.85
st_multFunction · 0.85
errorFunction · 0.85
xmallocFunction · 0.70

Tested by

no test coverage detected