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

Function parse_objectish

builtin/fast-import.c:2646–2691  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2644}
2645
2646static int parse_objectish(struct branch *b, const char *objectish)
2647{
2648 struct branch *s;
2649 struct object_id oid;
2650
2651 oidcpy(&oid, &b->branch_tree.versions[1].oid);
2652
2653 s = lookup_branch(objectish);
2654 if (b == s)
2655 die(_("can't create a branch from itself: %s"), b->name);
2656 else if (s) {
2657 struct object_id *t = &s->branch_tree.versions[1].oid;
2658 oidcpy(&b->oid, &s->oid);
2659 oidcpy(&b->branch_tree.versions[0].oid, t);
2660 oidcpy(&b->branch_tree.versions[1].oid, t);
2661 } else if (*objectish == ':') {
2662 uintmax_t idnum = parse_mark_ref_eol(objectish);
2663 struct object_entry *oe = find_mark(marks, idnum);
2664 if (oe->type != OBJ_COMMIT)
2665 die(_("mark :%" PRIuMAX " not a commit"), idnum);
2666 if (!oideq(&b->oid, &oe->idx.oid)) {
2667 oidcpy(&b->oid, &oe->idx.oid);
2668 if (oe->pack_id != MAX_PACK_ID) {
2669 unsigned long size;
2670 char *buf = gfi_unpack_entry(oe, &size);
2671 parse_from_commit(b, buf, size);
2672 free(buf);
2673 } else
2674 parse_from_existing(b);
2675 }
2676 } else if (!repo_get_oid(the_repository, objectish, &b->oid)) {
2677 parse_from_existing(b);
2678 if (is_null_oid(&b->oid))
2679 b->delete = 1;
2680 }
2681 else
2682 die(_("invalid ref name or SHA1 expression: %s"), objectish);
2683
2684 if (b->branch_tree.tree && !oideq(&oid, &b->branch_tree.versions[1].oid)) {
2685 release_tree_content_recursive(b->branch_tree.tree);
2686 b->branch_tree.tree = NULL;
2687 }
2688
2689 read_next_command();
2690 return 1;
2691}
2692
2693static int parse_from(struct branch *b)
2694{

Callers 2

parse_fromFunction · 0.85

Calls 13

oidcpyFunction · 0.85
lookup_branchFunction · 0.85
parse_mark_ref_eolFunction · 0.85
find_markFunction · 0.85
oideqFunction · 0.85
gfi_unpack_entryFunction · 0.85
parse_from_commitFunction · 0.85
parse_from_existingFunction · 0.85
repo_get_oidFunction · 0.85
is_null_oidFunction · 0.85
read_next_commandFunction · 0.85

Tested by

no test coverage detected