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

Function dwim_reverse_initial

blame.c:2688–2724  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2686}
2687
2688static struct commit *dwim_reverse_initial(struct rev_info *revs,
2689 const char **name_p)
2690{
2691 /*
2692 * DWIM "git blame --reverse ONE -- PATH" as
2693 * "git blame --reverse ONE..HEAD -- PATH" but only do so
2694 * when it makes sense.
2695 */
2696 struct object *obj;
2697 struct commit *head_commit;
2698 struct object_id head_oid;
2699
2700 if (revs->pending.nr != 1)
2701 return NULL;
2702
2703 /* Is that sole rev a committish? */
2704 obj = revs->pending.objects[0].item;
2705 obj = deref_tag(revs->repo, obj, NULL, 0);
2706 if (!obj || obj->type != OBJ_COMMIT)
2707 return NULL;
2708
2709 /* Do we have HEAD? */
2710 if (!refs_resolve_ref_unsafe(get_main_ref_store(the_repository), "HEAD", RESOLVE_REF_READING, &head_oid, NULL))
2711 return NULL;
2712 head_commit = lookup_commit_reference_gently(revs->repo,
2713 &head_oid, 1);
2714 if (!head_commit)
2715 return NULL;
2716
2717 /* Turn "ONE" into "ONE..HEAD" then */
2718 obj->flags |= UNINTERESTING;
2719 add_pending_object(revs, &head_commit->object, "HEAD");
2720
2721 if (name_p)
2722 *name_p = revs->pending.objects[0].name;
2723 return (struct commit *)obj;
2724}
2725
2726static struct commit *find_single_initial(struct rev_info *revs,
2727 const char **name_p)

Callers 1

find_single_initialFunction · 0.85

Calls 5

deref_tagFunction · 0.85
refs_resolve_ref_unsafeFunction · 0.85
get_main_ref_storeFunction · 0.85
add_pending_objectFunction · 0.85

Tested by

no test coverage detected