Merge branch 'jc/checkout-reflog-fix' into maint
* jc/checkout-reflog-fix: checkout: do not write bogus reflog entry out
This commit is contained in:
commit
a1ee40f3a2
@ -715,10 +715,12 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
|
|||||||
unsigned char rev[20];
|
unsigned char rev[20];
|
||||||
int flag;
|
int flag;
|
||||||
memset(&old, 0, sizeof(old));
|
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);
|
old.commit = lookup_commit_reference_gently(rev, 1);
|
||||||
if (!(flag & REF_ISSYMREF))
|
if (!(flag & REF_ISSYMREF)) {
|
||||||
|
free((char *)old.path);
|
||||||
old.path = NULL;
|
old.path = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (old.path && !prefixcmp(old.path, "refs/heads/"))
|
if (old.path && !prefixcmp(old.path, "refs/heads/"))
|
||||||
old.name = old.path + strlen("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);
|
update_refs_for_switch(opts, &old, new);
|
||||||
|
|
||||||
ret = post_checkout_hook(old.commit, new->commit, 1);
|
ret = post_checkout_hook(old.commit, new->commit, 1);
|
||||||
|
free((char *)old.path);
|
||||||
return ret || opts->writeout_error;
|
return ret || opts->writeout_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user