summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2012-05-14 11:42:22 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2012-05-14 11:42:22 -0700
commita912913e864ea67f4544d3fb4d52e20bd3a6075e (patch)
treee97e376dce372d745eeaf8435c9b79e41b19cf1c /builtin
parentMerge branch 'ef/maint-clone-progress-fix' into maint (diff)
parentcheckout (detached): truncate list of orphaned commits at the new HEAD (diff)
downloadtgif-a912913e864ea67f4544d3fb4d52e20bd3a6075e.tar.xz
Merge branch 'js/checkout-detach-count' into maint
When checking out another commit from an already detached state, we used to report all commits that are not reachable from any of the refs as lossage, but some of them might be reachable from the new HEAD, and there is no need to warn about them. By Johannes Sixt * js/checkout-detach-count: checkout (detached): truncate list of orphaned commits at the new HEAD t2020-checkout-detach: check for the number of orphaned commits
Diffstat (limited to 'builtin')
-rw-r--r--builtin/checkout.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 6b9061f26f..160f678b8c 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -671,10 +671,10 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)
* HEAD. If it is not reachable from any ref, this is the last chance
* for the user to do so without resorting to reflog.
*/
-static void orphaned_commit_warning(struct commit *commit)
+static void orphaned_commit_warning(struct commit *old, struct commit *new)
{
struct rev_info revs;
- struct object *object = &commit->object;
+ struct object *object = &old->object;
struct object_array refs;
init_revisions(&revs, NULL);
@@ -684,16 +684,17 @@ static void orphaned_commit_warning(struct commit *commit)
add_pending_object(&revs, object, sha1_to_hex(object->sha1));
for_each_ref(add_pending_uninteresting_ref, &revs);
+ add_pending_sha1(&revs, "HEAD", new->object.sha1, UNINTERESTING);
refs = revs.pending;
revs.leak_pending = 1;
if (prepare_revision_walk(&revs))
die(_("internal error in revision walk"));
- if (!(commit->object.flags & UNINTERESTING))
- suggest_reattach(commit, &revs);
+ if (!(old->object.flags & UNINTERESTING))
+ suggest_reattach(old, &revs);
else
- describe_detached_head(_("Previous HEAD position was"), commit);
+ describe_detached_head(_("Previous HEAD position was"), old);
clear_commit_marks_for_object_array(&refs, ALL_REV_FLAGS);
free(refs.objects);
@@ -730,7 +731,7 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
}
if (!opts->quiet && !old.path && old.commit && new->commit != old.commit)
- orphaned_commit_warning(old.commit);
+ orphaned_commit_warning(old.commit, new->commit);
update_refs_for_switch(opts, &old, new);