t4015: separate common setup and per-test expectation
[gitweb.git] / builtin / log.c
index dd9f2436caa0a85575b3289aec5275263850ac3e..734aab3a73185964d18c82fe5eb31008bbc409b7 100644 (file)
@@ -368,6 +368,8 @@ static int cmd_log_walk(struct rev_info *rev)
 
 static int git_log_config(const char *var, const char *value, void *cb)
 {
+       const char *slot_name;
+
        if (!strcmp(var, "format.pretty"))
                return git_config_string(&fmt_pretty, var, value);
        if (!strcmp(var, "format.subjectprefix"))
@@ -388,8 +390,8 @@ static int git_log_config(const char *var, const char *value, void *cb)
                default_show_root = git_config_bool(var, value);
                return 0;
        }
-       if (starts_with(var, "color.decorate."))
-               return parse_decorate_color_config(var, 15, value);
+       if (skip_prefix(var, "color.decorate.", &slot_name))
+               return parse_decorate_color_config(var, slot_name, value);
        if (!strcmp(var, "log.mailmap")) {
                use_mailmap_config = git_config_bool(var, value);
                return 0;
@@ -864,6 +866,7 @@ static void add_branch_description(struct strbuf *buf, const char *branch_name)
                strbuf_addbuf(buf, &desc);
                strbuf_addch(buf, '\n');
        }
+       strbuf_release(&desc);
 }
 
 static char *find_branch_name(struct rev_info *rev)
@@ -1397,7 +1400,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                if (check_head) {
                        unsigned char sha1[20];
                        const char *ref, *v;
-                       ref = resolve_ref_unsafe("HEAD", sha1, 1, NULL);
+                       ref = resolve_ref_unsafe("HEAD", RESOLVE_REF_READING,
+                                                sha1, NULL);
                        if (ref && skip_prefix(ref, "refs/heads/", &v))
                                branch_name = xstrdup(v);
                        else
@@ -1439,7 +1443,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                        continue;
 
                nr++;
-               list = xrealloc(list, nr * sizeof(list[0]));
+               REALLOC_ARRAY(list, nr);
                list[nr - 1] = commit;
        }
        if (nr == 0)