aboutsummaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-05-08 16:40:23 -0700
committerJunio C Hamano <junkio@cox.net>2006-05-08 16:40:23 -0700
commit45f75a0167b4a4693f2c6005bf7db231ca91ecc8 (patch)
treed7cb273a493d3b37aad4a41284cd8e2fb68f80c4 /config.c
parentfd60acaced6de16ebfb66959067e2b29f99a133e (diff)
parent31fff305bcc6db3b8082eac7fc9e441b27964fea (diff)
downloadgit-45f75a0167b4a4693f2c6005bf7db231ca91ecc8.tar.gz
git-45f75a0167b4a4693f2c6005bf7db231ca91ecc8.tar.xz
Merge branch 'fix'
* fix: Separate object name errors from usage errors Documentation: {caret} fixes (git-rev-list.txt) Fix "git diff --stat" with long filenames Fix repo-config set-multivar error return path.
Diffstat (limited to 'config.c')
-rw-r--r--config.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/config.c b/config.c
index 61eacefbe..0f518c957 100644
--- a/config.c
+++ b/config.c
@@ -422,7 +422,7 @@ int git_config_set_multivar(const char* key, const char* value,
const char* value_regex, int multi_replace)
{
int i;
- int fd, in_fd;
+ int fd = -1, in_fd;
int ret;
char* config_filename = strdup(git_path("config"));
char* lock_file = strdup(git_path("config.lock"));
@@ -480,15 +480,11 @@ int git_config_set_multivar(const char* key, const char* value,
if ( ENOENT != errno ) {
error("opening %s: %s", config_filename,
strerror(errno));
- close(fd);
- unlink(lock_file);
ret = 3; /* same as "invalid config file" */
goto out_free;
}
/* if nothing to unset, error out */
if (value == NULL) {
- close(fd);
- unlink(lock_file);
ret = 5;
goto out_free;
}
@@ -516,8 +512,6 @@ int git_config_set_multivar(const char* key, const char* value,
fprintf(stderr, "Invalid pattern: %s\n",
value_regex);
free(store.value_regex);
- close(fd);
- unlink(lock_file);
ret = 6;
goto out_free;
}
@@ -553,8 +547,6 @@ int git_config_set_multivar(const char* key, const char* value,
/* if nothing to unset, or too many matches, error out */
if ((store.seen == 0 && value == NULL) ||
(store.seen > 1 && multi_replace == 0)) {
- close(fd);
- unlink(lock_file);
ret = 5;
goto out_free;
}
@@ -603,8 +595,6 @@ int git_config_set_multivar(const char* key, const char* value,
unlink(config_filename);
}
- close(fd);
-
if (rename(lock_file, config_filename) < 0) {
fprintf(stderr, "Could not rename the lock file?\n");
ret = 4;
@@ -614,10 +604,14 @@ int git_config_set_multivar(const char* key, const char* value,
ret = 0;
out_free:
+ if (0 <= fd)
+ close(fd);
if (config_filename)
free(config_filename);
- if (lock_file)
+ if (lock_file) {
+ unlink(lock_file);
free(lock_file);
+ }
return ret;
}