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

Function orphaned_commit_warning

builtin/checkout.c:1127–1155  ·  view source on GitHub ↗

* We are about to leave commit that was at the tip of a detached * HEAD. If it is not reachable from any ref, this is the last chance * for the user to do so without resorting to reflog. */

Source from the content-addressed store, hash-verified

1125 * for the user to do so without resorting to reflog.
1126 */
1127static void orphaned_commit_warning(struct commit *old_commit, struct commit *new_commit)
1128{
1129 struct rev_info revs;
1130 struct object *object = &old_commit->object;
1131
1132 repo_init_revisions(the_repository, &revs, NULL);
1133 setup_revisions(0, NULL, &revs, NULL);
1134
1135 object->flags &= ~UNINTERESTING;
1136 add_pending_object(&revs, object, oid_to_hex(&object->oid));
1137
1138 refs_for_each_ref(get_main_ref_store(the_repository),
1139 add_pending_uninteresting_ref, &revs);
1140 if (new_commit)
1141 add_pending_oid(&revs, "HEAD",
1142 &new_commit->object.oid,
1143 UNINTERESTING);
1144
1145 if (prepare_revision_walk(&revs))
1146 die(_("internal error in revision walk"));
1147 if (!(old_commit->object.flags & UNINTERESTING))
1148 suggest_reattach(old_commit, &revs);
1149 else
1150 describe_detached_head(_("Previous HEAD position was"), old_commit);
1151
1152 /* Clean up objects used, as they will be reused. */
1153 repo_clear_commit_marks(the_repository, ALL_REV_FLAGS);
1154 release_revisions(&revs);
1155}
1156
1157static int switch_branches(const struct checkout_opts *opts,
1158 struct branch_info *new_branch_info)

Callers 1

switch_branchesFunction · 0.85

Calls 13

repo_init_revisionsFunction · 0.85
setup_revisionsFunction · 0.85
add_pending_objectFunction · 0.85
oid_to_hexFunction · 0.85
refs_for_each_refFunction · 0.85
get_main_ref_storeFunction · 0.85
add_pending_oidFunction · 0.85
prepare_revision_walkFunction · 0.85
suggest_reattachFunction · 0.85
describe_detached_headFunction · 0.85
repo_clear_commit_marksFunction · 0.85
release_revisionsFunction · 0.85

Tested by

no test coverage detected