diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-08-16 12:41:12 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-08-16 12:41:12 -0700 |
commit | a1ee40f3a2c626ad2b66e9fadf9a4064c3c5118c (patch) | |
tree | 18cfc2f3bb0537e52a6bb8ce04a68566bd6db3f0 | |
parent | Merge branch 'jc/maint-reset-unmerged-path' into maint (diff) | |
parent | Merge commit 'v1.7.6' into jc/checkout-reflog-fix (diff) | |
download | tgif-a1ee40f3a2c626ad2b66e9fadf9a4064c3c5118c.tar.xz |
Merge branch 'jc/checkout-reflog-fix' into maint
* jc/checkout-reflog-fix:
checkout: do not write bogus reflog entry out
-rw-r--r-- | builtin/checkout.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c index af1e7b579a..ca855d716c 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -715,10 +715,12 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new) unsigned char rev[20]; int flag; memset(&old, 0, sizeof(old)); - old.path = resolve_ref("HEAD", rev, 0, &flag); + old.path = xstrdup(resolve_ref("HEAD", rev, 0, &flag)); old.commit = lookup_commit_reference_gently(rev, 1); - if (!(flag & REF_ISSYMREF)) + if (!(flag & REF_ISSYMREF)) { + free((char *)old.path); old.path = NULL; + } if (old.path && !prefixcmp(old.path, "refs/heads/")) old.name = old.path + strlen("refs/heads/"); @@ -741,6 +743,7 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new) update_refs_for_switch(opts, &old, new); ret = post_checkout_hook(old.commit, new->commit, 1); + free((char *)old.path); return ret || opts->writeout_error; } |