Henrik Austad <henrik@austad.us> writes:I am not surprised. That one discarded an implementation of "git checkout" in Bourne shell, with a complete reimplementation in C. I haven't looked at the code very closely, but I think this should fix it. Thorough reviewing (not just running the test suite) is much appreciated. -- >8 -- Subject: git-checkout: do not allow switching to a tree-ish "git checkout -b newbranch $commit^{tree}" mistakenly created a new branch rooted at the current HEAD, because in that case, the two structure fields used to see if the command was invoked without any argument (hence it needs to default to checking out the HEAD), were populated incorrectly. Upon seeing a command line argument that we took as a rev, we should store that string in new.name, even if that does not name a commit. Signed-off-by: Junio C Hamano <gitster@pobox.com> --- builtin-checkout.c | 2 +- t/t2011-checkout-invalid-head.sh | 4 ++++ 2 files changed, 5 insertions(+), 1 deletions(-) diff --git c/builtin-checkout.c w/builtin-checkout.c index c2c0561..b5dd9c0 100644 --- c/builtin-checkout.c +++ w/builtin-checkout.c @@ -681,8 +681,8 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) argv++; argc--; + new.name = arg; if ((new.commit = lookup_commit_reference_gently(rev, 1))) { - new.name = arg; setup_branch_path(&new); if (resolve_ref(new.path, rev, 1, NULL)) new.commit = lookup_commit_reference(rev); diff --git c/t/t2011-checkout-invalid-head.sh w/t/t2011-checkout-invalid-head.sh index 764bb0a..798790d 100755 --- c/t/t2011-checkout-invalid-head.sh +++ w/t/t2011-checkout-invalid-head.sh @@ -15,4 +15,8 @@ test_expect_success 'checkout master from invalid HEAD' ' git checkout master -- ' +test_expect_success 'checkout should not start branch from a tree' ' + test_must_fail git checkout -b newbranch master^{tree} +' + test_done -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
| Greg KH | Og dreams of kernels |
| Jens Axboe | [PATCH 31/33] Fusion: sg chaining support |
| Arnd Bergmann | Re: finding your own dead "CONFIG_" variables |
| Mark Brown | [PATCH 2/2] Subject: natsemi: Allow users to disable workaround for DspCfg reset |
| Tony Breeds | [LGUEST] Look in object dir for .config |
git: | |
| Brian Downing | Re: Git in a Nutshell guide |
| John Benes | Re: master has some toys |
| Matthias Lederhofer | [PATCH 4/7] introduce GIT_WORK_TREE to specify the work tree |
| Alexander Sulfrian | [RFC/PATCH] RE: git calls SSH_ASKPASS even if DISPLAY is not set |
| Junio C Hamano | Re: Rss produ |
