@@ -8,18 +8,6 @@
static const char builtin_merge_recursive_usage[] =
"git %s <base>... -- <head> <remote> ...";
-static char *better_branch_name(const char *branch)
-{
- static char githead_env[8 + GIT_MAX_HEXSZ + 1];
- char *name;
-
- if (strlen(branch) != the_hash_algo->hexsz)
- return xstrdup(branch);
- xsnprintf(githead_env, sizeof(githead_env), "GITHEAD_%s", branch);
- name = getenv(githead_env);
- return xstrdup(name ? name : branch);
-}
-
int cmd_merge_recursive(int argc, const char **argv, const char *prefix)
{
const struct object_id *bases[21];
@@ -75,8 +63,8 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix)
if (get_oid(o.branch2, &h2))
die(_("could not resolve ref '%s'"), o.branch2);
- o.branch1 = better1 = better_branch_name(o.branch1);
- o.branch2 = better2 = better_branch_name(o.branch2);
+ o.branch1 = better1 = merge_get_better_branch_name(o.branch1);
+ o.branch2 = better2 = merge_get_better_branch_name(o.branch2);
if (o.verbosity >= 3)
printf(_("Merging %s with %s\n"), o.branch1, o.branch2);
@@ -1933,7 +1933,7 @@ int checkout_fast_forward(struct repository *r,
const struct object_id *from,
const struct object_id *to,
int overwrite_ignore);
-
+char *merge_get_better_branch_name(const char *branch);
int sane_execvp(const char *file, char *const argv[]);
@@ -109,3 +109,15 @@ int checkout_fast_forward(struct repository *r,
return error(_("unable to write new index file"));
return 0;
}
+
+char *merge_get_better_branch_name(const char *branch)
+{
+ static char githead_env[8 + GIT_MAX_HEXSZ + 1];
+ char *name;
+
+ if (strlen(branch) != the_hash_algo->hexsz)
+ return xstrdup(branch);
+ xsnprintf(githead_env, sizeof(githead_env), "GITHEAD_%s", branch);
+ name = getenv(githead_env);
+ return xstrdup(name ? name : branch);
+}
better_branch_name() will be used by merge-octopus once it is rewritten in C, so instead of duplicating it, this moves this function preventively inside an appropriate file in libgit.a. This function is also renamed to reflect its usage by merge strategies. Signed-off-by: Alban Gruin <alban.gruin@gmail.com> --- builtin/merge-recursive.c | 16 ++-------------- cache.h | 2 +- merge.c | 12 ++++++++++++ 3 files changed, 15 insertions(+), 15 deletions(-)