Reduce the number of connects when fetching
[gitweb.git] / config.c
index 857deb6c85091057f663d2eb7143f3717bd82687..0b0c9bd050023e15d3f49623ea036894cb5c521a 100644 (file)
--- a/config.c
+++ b/config.c
@@ -485,8 +485,9 @@ const char *git_etc_gitconfig(void)
                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);
+                       system_wide = strdup(prefix_filename(exec_path,
+                                                            strlen(exec_path),
+                                                            system_wide));
                }
        }
        return system_wide;
@@ -955,14 +956,12 @@ int git_config_set_multivar(const char* key, const char* value,
                munmap(contents, contents_sz);
        }
 
-       if (close(fd) || commit_lock_file(lock) < 0) {
+       if (commit_lock_file(lock) < 0) {
                fprintf(stderr, "Cannot commit config file!\n");
                ret = 4;
                goto out_free;
        }
 
-       /* fd is closed, so don't try to close it below. */
-       fd = -1;
        /*
         * lock is committed, so don't try to roll it back below.
         * NOTE: Since lockfile.c keeps a linked list of all created
@@ -973,8 +972,6 @@ int git_config_set_multivar(const char* key, const char* value,
        ret = 0;
 
 out_free:
-       if (0 <= fd)
-               close(fd);
        if (lock)
                rollback_lock_file(lock);
        free(config_filename);
@@ -1072,7 +1069,7 @@ int git_config_rename_section(const char *old_name, const char *new_name)
        }
        fclose(config_file);
  unlock_and_out:
-       if (close(out_fd) || commit_lock_file(lock) < 0)
+       if (commit_lock_file(lock) < 0)
                        ret = error("Cannot commit config file!");
  out:
        free(config_filename);