]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/log.c
format-patch: use enum variables
[thirdparty/git.git] / builtin / log.c
index 7c8767d3bc781e132fdcb54edbfab2c856380e62..d212a8305d32c81003ce0f03ee245658c3141272 100644 (file)
@@ -47,7 +47,7 @@ static int default_follow;
 static int default_show_signature;
 static int decoration_style;
 static int decoration_given;
-static int use_mailmap_config;
+static int use_mailmap_config = 1;
 static const char *fmt_patch_subject_prefix = "PATCH";
 static const char *fmt_pretty;
 
@@ -63,9 +63,14 @@ struct line_opt_callback_data {
        struct string_list args;
 };
 
+static int session_is_interactive(void)
+{
+       return isatty(1) || pager_in_use();
+}
+
 static int auto_decoration_style(void)
 {
-       return (isatty(1) || pager_in_use()) ? DECORATE_SHORT_REFS : 0;
+       return session_is_interactive() ? DECORATE_SHORT_REFS : 0;
 }
 
 static int parse_decoration_style(const char *value)
@@ -155,7 +160,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
                         struct rev_info *rev, struct setup_revision_opt *opt)
 {
        struct userformat_want w;
-       int quiet = 0, source = 0, mailmap = 0;
+       int quiet = 0, source = 0, mailmap;
        static struct line_opt_callback_data line_cb = {NULL, NULL, STRING_LIST_INIT_DUP};
        static struct string_list decorate_refs_exclude = STRING_LIST_INIT_NODUP;
        static struct string_list decorate_refs_include = STRING_LIST_INIT_NODUP;
@@ -759,24 +764,28 @@ static void add_header(const char *value)
        item->string[len] = '\0';
 }
 
-#define THREAD_SHALLOW 1
-#define THREAD_DEEP 2
-static int thread;
+enum cover_setting {
+       COVER_UNSET,
+       COVER_OFF,
+       COVER_ON,
+       COVER_AUTO
+};
+
+enum thread_level {
+       THREAD_UNSET,
+       THREAD_SHALLOW,
+       THREAD_DEEP
+};
+
+static enum thread_level thread;
 static int do_signoff;
 static int base_auto;
 static char *from;
 static const char *signature = git_version_string;
 static const char *signature_file;
-static int config_cover_letter;
+static enum cover_setting config_cover_letter;
 static const char *config_output_directory;
 
-enum {
-       COVER_UNSET,
-       COVER_OFF,
-       COVER_ON,
-       COVER_AUTO
-};
-
 static int git_format_config(const char *var, const char *value, void *cb)
 {
        struct rev_info *rev = cb;
@@ -830,7 +839,7 @@ static int git_format_config(const char *var, const char *value, void *cb)
                        thread = THREAD_SHALLOW;
                        return 0;
                }
-               thread = git_config_bool(var, value) && THREAD_SHALLOW;
+               thread = git_config_bool(var, value) ? THREAD_SHALLOW : THREAD_UNSET;
                return 0;
        }
        if (!strcmp(var, "format.signoff")) {
@@ -1243,9 +1252,9 @@ static int output_directory_callback(const struct option *opt, const char *arg,
 
 static int thread_callback(const struct option *opt, const char *arg, int unset)
 {
-       int *thread = (int *)opt->value;
+       enum thread_level *thread = (enum thread_level *)opt->value;
        if (unset)
-               *thread = 0;
+               *thread = THREAD_UNSET;
        else if (!arg || !strcmp(arg, "shallow"))
                *thread = THREAD_SHALLOW;
        else if (!strcmp(arg, "deep"))