Skip to content

Commit

Permalink
Merge branch 'jc/checkout-reflog-fix' into maint
Browse files Browse the repository at this point in the history
* jc/checkout-reflog-fix:
  checkout: do not write bogus reflog entry out
  • Loading branch information
Junio C Hamano committed Aug 16, 2011
2 parents 7aa5089 + 25d3354 commit a1ee40f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions builtin/checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -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/");
Expand All @@ -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;
}

Expand Down

0 comments on commit a1ee40f

Please sign in to comment.