aboutsummaryrefslogtreecommitdiff
path: root/builtin/merge.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-12-19 16:05:50 -0800
committerJunio C Hamano <gitster@pobox.com>2011-12-19 16:05:50 -0800
commit2e05710a161e6287f239fae42b86b0cb46190834 (patch)
treea2dd4d1acc86d20f7888ee4f09f7d54d600ff33e /builtin/merge.c
parentb8fc5abd73e2e81c396844c09e8003de320709e5 (diff)
parent8cad4744ee37ebec1d9491a1381ec1771a1ba795 (diff)
downloadgit-2e05710a161e6287f239fae42b86b0cb46190834.tar.gz
git-2e05710a161e6287f239fae42b86b0cb46190834.tar.xz
Merge branch 'nd/resolve-ref'
* nd/resolve-ref: Rename resolve_ref() to resolve_ref_unsafe() Convert resolve_ref+xstrdup to new resolve_refdup function revert: convert resolve_ref() to read_ref_full()
Diffstat (limited to 'builtin/merge.c')
-rw-r--r--builtin/merge.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/builtin/merge.c b/builtin/merge.c
index 98ed54a5f..24579409c 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1100,6 +1100,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
struct commit_list *common = NULL;
const char *best_strategy = NULL, *wt_strategy = NULL;
struct commit_list **remotes = &remoteheads;
+ void *branch_to_free;
if (argc == 2 && !strcmp(argv[1], "-h"))
usage_with_options(builtin_merge_usage, builtin_merge_options);
@@ -1108,12 +1109,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
* Check if we are _not_ on a detached HEAD, i.e. if there is a
* current branch.
*/
- branch = resolve_ref("HEAD", head_sha1, 0, &flag);
- if (branch) {
- if (!prefixcmp(branch, "refs/heads/"))
- branch += 11;
- branch = xstrdup(branch);
- }
+ branch = branch_to_free = resolve_refdup("HEAD", head_sha1, 0, &flag);
+ if (branch && !prefixcmp(branch, "refs/heads/"))
+ branch += 11;
if (!branch || is_null_sha1(head_sha1))
head_commit = NULL;
else
@@ -1524,6 +1522,6 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
ret = suggest_conflicts(option_renormalize);
done:
- free((char *)branch);
+ free(branch_to_free);
return ret;
}