static struct strategy *get_strategy(const char *name)
{
int i;
+ struct strbuf err;
if (!name)
return NULL;
for (i = 0; i < ARRAY_SIZE(all_strategy); i++)
if (!strcmp(name, all_strategy[i].name))
return &all_strategy[i];
- return NULL;
+
+ strbuf_init(&err, 0);
+ for (i = 0; i < ARRAY_SIZE(all_strategy); i++)
+ strbuf_addf(&err, " %s", all_strategy[i].name);
+ fprintf(stderr, "Could not find merge strategy '%s'.\n", name);
+ fprintf(stderr, "Available strategies are:%s.\n", err.buf);
+ exit(1);
}
static void append_strategy(struct strategy *s)
static int option_parse_strategy(const struct option *opt,
const char *name, int unset)
{
- int i;
- struct strategy *s;
-
if (unset)
return 0;
- s = get_strategy(name);
-
- if (s)
- append_strategy(s);
- else {
- struct strbuf err;
- strbuf_init(&err, 0);
- for (i = 0; i < ARRAY_SIZE(all_strategy); i++)
- strbuf_addf(&err, " %s", all_strategy[i].name);
- fprintf(stderr, "Could not find merge strategy '%s'.\n", name);
- fprintf(stderr, "Available strategies are:%s.\n", err.buf);
- exit(1);
- }
+ append_strategy(get_strategy(name));
return 0;
}
struct strbuf truname = STRBUF_INIT;
strbuf_addstr(&truname, "refs/heads/");
strbuf_addstr(&truname, remote);
- strbuf_setlen(&truname, len+11);
+ strbuf_setlen(&truname, truname.len - len);
if (resolve_ref(truname.buf, buf_sha, 0, 0)) {
strbuf_addf(msg,
"%s\t\tbranch '%s'%s of .\n",
sha1_to_hex(remote_head->sha1),
- truname.buf,
+ truname.buf + 11,
(early ? " (early part)" : ""));
return;
}
sha1_to_hex(remote_head->sha1), remote);
}
-int git_merge_config(const char *k, const char *v, void *cb)
+static int git_merge_config(const char *k, const char *v, void *cb)
{
if (branch && !prefixcmp(k, "branch.") &&
!prefixcmp(k + 7, branch) &&
memset(&trees, 0, sizeof(trees));
memset(&opts, 0, sizeof(opts));
memset(&t, 0, sizeof(t));
+ memset(&dir, 0, sizeof(dir));
dir.show_ignored = 1;
dir.exclude_per_dir = ".gitignore";
opts.dir = &dir;
memset(&list, 0, sizeof(list));
split_merge_strategies(string, &list, &list_nr, &list_alloc);
- if (list != NULL) {
- for (i = 0; i < list_nr; i++) {
- struct strategy *s;
-
- s = get_strategy(list[i].name);
- if (s)
- append_strategy(s);
- }
+ if (list) {
+ for (i = 0; i < list_nr; i++)
+ append_strategy(get_strategy(list[i].name));
return;
}
for (i = 0; i < ARRAY_SIZE(all_strategy); i++)