Code

Merge branch 'np/pack-safer'
[git.git] / config.c
index 18d305c890d3f4ba00962cfa4033ff9ed68cf95b..67cc1dcad0b52f0186c0c9564af43853d8994797 100644 (file)
--- a/config.c
+++ b/config.c
@@ -649,7 +649,7 @@ int git_config(config_fn_t fn, void *data)
                free(user_config);
        }
 
-       repo_config = xstrdup(git_path("config"));
+       repo_config = git_pathdup("config");
        ret += git_config_from_file(fn, repo_config, data);
        free(repo_config);
        return ret;
@@ -753,9 +753,8 @@ static int store_write_section(int fd, const char* key)
 {
        const char *dot;
        int i, success;
-       struct strbuf sb;
+       struct strbuf sb = STRBUF_INIT;
 
-       strbuf_init(&sb, 0);
        dot = memchr(key, '.', store.baselen);
        if (dot) {
                strbuf_addf(&sb, "[%.*s \"", (int)(dot - key), key);
@@ -780,7 +779,7 @@ static int store_write_pair(int fd, const char* key, const char* value)
        int i, success;
        int length = strlen(key + store.baselen + 1);
        const char *quote = "";
-       struct strbuf sb;
+       struct strbuf sb = STRBUF_INIT;
 
        /*
         * Check to see if the value needs to be surrounded with a dq pair.
@@ -797,7 +796,6 @@ static int store_write_pair(int fd, const char* key, const char* value)
        if (i && value[i - 1] == ' ')
                quote = "\"";
 
-       strbuf_init(&sb, 0);
        strbuf_addf(&sb, "\t%.*s = %s",
                    length, key + store.baselen + 1, quote);
 
@@ -891,7 +889,7 @@ int git_config_set_multivar(const char* key, const char* value,
        if (config_exclusive_filename)
                config_filename = xstrdup(config_exclusive_filename);
        else
-               config_filename = xstrdup(git_path("config"));
+               config_filename = git_pathdup("config");
 
        /*
         * Since "key" actually contains the section name and the real
@@ -1151,7 +1149,7 @@ int git_config_rename_section(const char *old_name, const char *new_name)
        if (config_exclusive_filename)
                config_filename = xstrdup(config_exclusive_filename);
        else
-               config_filename = xstrdup(git_path("config"));
+               config_filename = git_pathdup("config");
        out_fd = hold_lock_file_for_update(lock, config_filename, 0);
        if (out_fd < 0) {
                ret = error("could not lock config file %s", config_filename);