aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-07-22 14:43:03 -0700
committerJunio C Hamano <gitster@pobox.com>2011-07-22 14:43:03 -0700
commit4f9aba9c26d18d44e3a51b57d0e548a0cb39fcd9 (patch)
tree97172e91ce0fa00b20af42bccd04724421d4aa57
parentf50d0a7f4040f8a53360d9f6aa8a91bbab2fe39f (diff)
parent25d33546d474c7c28b72013c262fc23337cb3b21 (diff)
downloadgit-4f9aba9c26d18d44e3a51b57d0e548a0cb39fcd9.tar.gz
git-4f9aba9c26d18d44e3a51b57d0e548a0cb39fcd9.tar.xz
Merge branch 'jc/checkout-reflog-fix'
* jc/checkout-reflog-fix: checkout: do not write bogus reflog entry out
-rw-r--r--builtin/checkout.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index f152adf9a..d647a3130 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -716,10 +716,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/");
@@ -742,6 +744,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;
}