* 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. */
| 1125 | * for the user to do so without resorting to reflog. |
| 1126 | */ |
| 1127 | static 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 | |
| 1157 | static int switch_branches(const struct checkout_opts *opts, |
| 1158 | struct branch_info *new_branch_info) |
no test coverage detected