X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=config.c;h=0b0c9bd050023e15d3f49623ea036894cb5c521a;hb=4f395eed33816be70181a818cbce4bb7235b83be;hp=857deb6c85091057f663d2eb7143f3717bd82687;hpb=144126abf99f2eac48e63b7ea85a8f3f99f814db;p=git.git diff --git a/config.c b/config.c index 857deb6c8..0b0c9bd05 100644 --- 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);