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

Function add_non_note

notes.c:352–395  ·  view source on GitHub ↗

note: takes ownership of path string */

Source from the content-addressed store, hash-verified

350
351/* note: takes ownership of path string */
352static void add_non_note(struct notes_tree *t, char *path,
353 unsigned int mode, const unsigned char *sha1)
354{
355 struct non_note *p = t->prev_non_note, *n;
356 n = (struct non_note *) xmalloc(sizeof(struct non_note));
357 n->next = NULL;
358 n->path = path;
359 n->mode = mode;
360 oidread(&n->oid, sha1, the_repository->hash_algo);
361 t->prev_non_note = n;
362
363 if (!t->first_non_note) {
364 t->first_non_note = n;
365 return;
366 }
367
368 if (non_note_cmp(p, n) < 0)
369 ; /* do nothing */
370 else if (non_note_cmp(t->first_non_note, n) <= 0)
371 p = t->first_non_note;
372 else {
373 /* n sorts before t->first_non_note */
374 n->next = t->first_non_note;
375 t->first_non_note = n;
376 return;
377 }
378
379 /* n sorts equal or after p */
380 while (p->next && non_note_cmp(p->next, n) <= 0)
381 p = p->next;
382
383 if (non_note_cmp(p, n) == 0) { /* n ~= p; overwrite p with n */
384 assert(strcmp(p->path, n->path) == 0);
385 p->mode = n->mode;
386 oidcpy(&p->oid, &n->oid);
387 free(n);
388 t->prev_non_note = p;
389 return;
390 }
391
392 /* n sorts between p and p->next */
393 n->next = p->next;
394 p->next = n;
395}
396
397static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,
398 struct int_node *node, unsigned int n)

Callers 1

load_subtreeFunction · 0.85

Calls 4

oidreadFunction · 0.85
non_note_cmpFunction · 0.85
oidcpyFunction · 0.85
xmallocFunction · 0.70

Tested by

no test coverage detected