]> asedeno.scripts.mit.edu Git - git.git/blobdiff - config.c
Merge branch 'mw/send-email'
[git.git] / config.c
index e799f40db74fd1f40849dcec21e997f165a52e35..3e72778e94267044780a180145eae0a6a229e3a3 100644 (file)
--- a/config.c
+++ b/config.c
@@ -408,21 +408,29 @@ int git_default_config(const char *var, const char *value)
        }
 
        if (!strcmp(var, "user.name")) {
+               if (!value)
+                       return config_error_nonbool(var);
                strlcpy(git_default_name, value, sizeof(git_default_name));
                return 0;
        }
 
        if (!strcmp(var, "user.email")) {
+               if (!value)
+                       return config_error_nonbool(var);
                strlcpy(git_default_email, value, sizeof(git_default_email));
                return 0;
        }
 
        if (!strcmp(var, "i18n.commitencoding")) {
+               if (!value)
+                       return config_error_nonbool(var);
                git_commit_encoding = xstrdup(value);
                return 0;
        }
 
        if (!strcmp(var, "i18n.logoutputencoding")) {
+               if (!value)
+                       return config_error_nonbool(var);
                git_log_output_encoding = xstrdup(value);
                return 0;
        }
@@ -434,23 +442,29 @@ int git_default_config(const char *var, const char *value)
        }
 
        if (!strcmp(var, "core.pager")) {
+               if (!value)
+                       return config_error_nonbool(var);
                pager_program = xstrdup(value);
                return 0;
        }
 
        if (!strcmp(var, "core.editor")) {
+               if (!value)
+                       return config_error_nonbool(var);
                editor_program = xstrdup(value);
                return 0;
        }
 
        if (!strcmp(var, "core.excludesfile")) {
                if (!value)
-                       die("core.excludesfile without value");
+                       return config_error_nonbool(var);
                excludes_file = xstrdup(value);
                return 0;
        }
 
        if (!strcmp(var, "core.whitespace")) {
+               if (!value)
+                       return config_error_nonbool(var);
                whitespace_rule_cfg = parse_whitespace_rule(value);
                return 0;
        }
@@ -484,9 +498,9 @@ const char *git_etc_gitconfig(void)
                system_wide = ETC_GITCONFIG;
                if (!is_absolute_path(system_wide)) {
                        /* interpret path relative to exec-dir */
-                       const char *exec_path = git_exec_path();
-                       system_wide = prefix_path(exec_path, strlen(exec_path),
-                                               system_wide);
+                       struct strbuf d = STRBUF_INIT;
+                       strbuf_addf(&d, "%s/%s", git_exec_path(), system_wide);
+                       system_wide = strbuf_detach(&d, NULL);
                }
        }
        return system_wide;
@@ -1079,3 +1093,12 @@ int git_config_rename_section(const char *old_name, const char *new_name)
        free(config_filename);
        return ret;
 }
+
+/*
+ * Call this to report error for your variable that should not
+ * get a boolean value (i.e. "[my] var" means "true").
+ */
+int config_error_nonbool(const char *var)
+{
+       return error("Missing value for '%s'", var);
+}