Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-04-02 03:16:23 +0400
committerJunio C Hamano <gitster@pobox.com>2011-04-02 03:16:51 +0400
commitd12d8ec9d728b0ce148f5a5caa68c858ef180d30 (patch)
tree5d980402593b9fede13d01367e720068eb5fd638 /builtin
parent6cb0186a41335f5e82d1e91abf4ce70938d0a020 (diff)
parent0cb6ad3c3d8e9c738686ef8dc6f173f725e509bc (diff)
Merge "checkout ambiguous ref bugfix" into maint
* commit '0cb6ad3': checkout: fix bug with ambiguous refs
Diffstat (limited to 'builtin')
-rw-r--r--builtin/checkout.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index cd7f56e6c4..e98576f22e 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -678,7 +678,7 @@ static const char *unique_tracking_name(const char *name)
int cmd_checkout(int argc, const char **argv, const char *prefix)
{
struct checkout_opts opts;
- unsigned char rev[20];
+ unsigned char rev[20], branch_rev[20];
const char *arg;
struct branch_info new;
struct tree *source_tree = NULL;
@@ -832,18 +832,21 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
argc--;
new.name = arg;
- if ((new.commit = lookup_commit_reference_gently(rev, 1))) {
- setup_branch_path(&new);
+ setup_branch_path(&new);
- if ((check_ref_format(new.path) == CHECK_REF_FORMAT_OK) &&
- resolve_ref(new.path, rev, 1, NULL))
- ;
- else
- new.path = NULL;
+ if (check_ref_format(new.path) == CHECK_REF_FORMAT_OK &&
+ resolve_ref(new.path, branch_rev, 1, NULL))
+ hashcpy(rev, branch_rev);
+ else
+ new.path = NULL; /* not an existing branch */
+
+ if (!(new.commit = lookup_commit_reference_gently(rev, 1))) {
+ /* not a commit */
+ source_tree = parse_tree_indirect(rev);
+ } else {
parse_commit(new.commit);
source_tree = new.commit->tree;
- } else
- source_tree = parse_tree_indirect(rev);
+ }
if (!source_tree) /* case (1): want a tree */
die("reference is not a tree: %s", arg);