Code

commit, merge: initialize static strbuf
[git.git] / builtin-log.c
index 543855b7ad11bd0355d88bc1502030509875e0c7..f4975cf35f7f1555739f7657ee62ed983d18cb84 100644 (file)
@@ -230,30 +230,26 @@ static int cmd_log_walk(struct rev_info *rev)
        return 0;
 }
 
-static int git_log_config(const char *var, const char *value)
+static int git_log_config(const char *var, const char *value, void *cb)
 {
        if (!strcmp(var, "format.pretty"))
                return git_config_string(&fmt_pretty, var, value);
-       if (!strcmp(var, "format.subjectprefix")) {
-               if (!value)
-                       config_error_nonbool(var);
-               fmt_patch_subject_prefix = xstrdup(value);
-               return 0;
-       }
+       if (!strcmp(var, "format.subjectprefix"))
+               return git_config_string(&fmt_patch_subject_prefix, var, value);
        if (!strcmp(var, "log.date"))
                return git_config_string(&default_date_mode, var, value);
        if (!strcmp(var, "log.showroot")) {
                default_show_root = git_config_bool(var, value);
                return 0;
        }
-       return git_diff_ui_config(var, value);
+       return git_diff_ui_config(var, value, cb);
 }
 
 int cmd_whatchanged(int argc, const char **argv, const char *prefix)
 {
        struct rev_info rev;
 
-       git_config(git_log_config);
+       git_config(git_log_config, NULL);
 
        if (diff_use_color_default == -1)
                diff_use_color_default = git_use_color_default;
@@ -317,7 +313,7 @@ static int show_object(const unsigned char *sha1, int show_tag_object,
 
 static int show_tree_object(const unsigned char *sha1,
                const char *base, int baselen,
-               const char *pathname, unsigned mode, int stage)
+               const char *pathname, unsigned mode, int stage, void *context)
 {
        printf("%s%s\n", pathname, S_ISDIR(mode) ? "/" : "");
        return 0;
@@ -329,7 +325,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
        struct object_array_entry *objects;
        int i, count, ret = 0;
 
-       git_config(git_log_config);
+       git_config(git_log_config, NULL);
 
        if (diff_use_color_default == -1)
                diff_use_color_default = git_use_color_default;
@@ -360,7 +356,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
                                        t->tag,
                                        diff_get_color_opt(&rev.diffopt, DIFF_RESET));
                        ret = show_object(o->sha1, 1, &rev);
-                       objects[i].item = (struct object *)t->tagged;
+                       objects[i].item = parse_object(t->tagged->sha1);
                        i--;
                        break;
                }
@@ -370,7 +366,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
                                        name,
                                        diff_get_color_opt(&rev.diffopt, DIFF_RESET));
                        read_tree_recursive((struct tree *)o, "", 0, 0, NULL,
-                                       show_tree_object);
+                                       show_tree_object, NULL);
                        break;
                case OBJ_COMMIT:
                        rev.pending.nr = rev.pending.alloc = 0;
@@ -393,7 +389,7 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
 {
        struct rev_info rev;
 
-       git_config(git_log_config);
+       git_config(git_log_config, NULL);
 
        if (diff_use_color_default == -1)
                diff_use_color_default = git_use_color_default;
@@ -426,7 +422,7 @@ int cmd_log(int argc, const char **argv, const char *prefix)
 {
        struct rev_info rev;
 
-       git_config(git_log_config);
+       git_config(git_log_config, NULL);
 
        if (diff_use_color_default == -1)
                diff_use_color_default = git_use_color_default;
@@ -481,7 +477,7 @@ static void add_header(const char *value)
        extra_hdr[extra_hdr_nr++] = xstrndup(value, len);
 }
 
-static int git_format_config(const char *var, const char *value)
+static int git_format_config(const char *var, const char *value, void *cb)
 {
        if (!strcmp(var, "format.headers")) {
                if (!value)
@@ -489,12 +485,8 @@ static int git_format_config(const char *var, const char *value)
                add_header(value);
                return 0;
        }
-       if (!strcmp(var, "format.suffix")) {
-               if (!value)
-                       return config_error_nonbool(var);
-               fmt_patch_suffix = xstrdup(value);
-               return 0;
-       }
+       if (!strcmp(var, "format.suffix"))
+               return git_config_string(&fmt_patch_suffix, var, value);
        if (!strcmp(var, "format.cc")) {
                if (!value)
                        return config_error_nonbool(var);
@@ -514,7 +506,7 @@ static int git_format_config(const char *var, const char *value)
                return 0;
        }
 
-       return git_log_config(var, value);
+       return git_log_config(var, value, cb);
 }
 
 
@@ -781,7 +773,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        char *add_signoff = NULL;
        struct strbuf buf;
 
-       git_config(git_format_config);
+       git_config(git_format_config, NULL);
        init_revisions(&rev, prefix);
        rev.commit_format = CMIT_FMT_EMAIL;
        rev.verbose_header = 1;
@@ -1090,7 +1082,7 @@ static int add_pending_commit(const char *arg, struct rev_info *revs, int flags)
 }
 
 static const char cherry_usage[] =
-"git-cherry [-v] <upstream> [<head>] [<limit>]";
+"git cherry [-v] <upstream> [<head>] [<limit>]";
 int cmd_cherry(int argc, const char **argv, const char *prefix)
 {
        struct rev_info revs;