sub-process: refactor handshake to common function
[gitweb.git] / builtin / config.c
index 1fc6471f37a061318ea16442a15c378c49648188..70ff231e9c5bce550e7af20ddfe91b8b68ee32ae 100644 (file)
@@ -215,8 +215,7 @@ static int get_value(const char *key_, const char *regex_)
                key_regexp = (regex_t*)xmalloc(sizeof(regex_t));
                if (regcomp(key_regexp, key, REG_EXTENDED)) {
                        error("invalid key pattern: %s", key_);
-                       free(key_regexp);
-                       key_regexp = NULL;
+                       FREE_AND_NULL(key_regexp);
                        ret = CONFIG_INVALID_PATTERN;
                        goto free_strings;
                }
@@ -236,8 +235,7 @@ static int get_value(const char *key_, const char *regex_)
                regexp = (regex_t*)xmalloc(sizeof(regex_t));
                if (regcomp(regexp, regex_, REG_EXTENDED)) {
                        error("invalid pattern: %s", regex_);
-                       free(regexp);
-                       regexp = NULL;
+                       FREE_AND_NULL(regexp);
                        ret = CONFIG_INVALID_PATTERN;
                        goto free_strings;
                }
@@ -497,6 +495,9 @@ int cmd_config(int argc, const char **argv, const char *prefix)
                usage_with_options(builtin_config_usage, builtin_config_options);
        }
 
+       if (use_local_config && nongit)
+               die(_("--local can only be used inside a git repository"));
+
        if (given_config_source.file &&
                        !strcmp(given_config_source.file, "-")) {
                given_config_source.file = NULL;