diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-05-22 15:34:46 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-05-22 15:34:46 -0700 |
commit | 423b5a104422d56645baf8229bfb496fa49c2a56 (patch) | |
tree | a7e020cab3c1a4d7c5b4eb04da55788e25bd6b81 /builtin/checkout.c | |
parent | 963c0407f47f5c2c73deb67613f0ac5a0615889c (diff) | |
parent | 6b179adfe93d13c2f993668cd12eec52860486ac (diff) | |
download | git-423b5a104422d56645baf8229bfb496fa49c2a56.tar.gz git-423b5a104422d56645baf8229bfb496fa49c2a56.tar.xz |
Merge branch 'fc/git-complete-helper' into fc/git-prompt-script
By Michael Haggerty (17) and others
via Junio C Hamano (36) and Jeff King (1)
* fc/git-complete-helper: (54 commits)
completion: add new __git_complete helper
Update draft release notes to 1.7.11 (11th batch)
Git 1.7.10.2
document submdule.$name.update=none option for gitmodules
The tenth batch of topics
Update draft release notes to 1.7.10.2
checkout: do not corrupt HEAD on empty repo
apply: remove lego in i18n string in gitdiff_verify_name
dir: convert to strbuf
status: refactor colopts handling
status: respect "-b" for porcelain format
status: fix null termination with "-b"
status: refactor null_termination option
commit: refactor option parsing
Documentation/git-config: describe and clarify "--local <file>" option
reflog-walk: tell explicit --date=default from not having --date at all
clone: fix progress-regression
grep.c: remove redundant line of code
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/checkout.c')
-rw-r--r-- | builtin/checkout.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c index 23fc56d88..3ddda34f7 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -672,10 +672,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); @@ -685,16 +685,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); @@ -731,7 +732,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); @@ -1091,7 +1092,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) if (opts.writeout_stage) die(_("--ours/--theirs is incompatible with switching branches.")); - if (!new.commit) { + if (!new.commit && opts.new_branch) { unsigned char rev[20]; int flag; |