aboutsummaryrefslogtreecommitdiff
path: root/builtin-commit.c
diff options
context:
space:
mode:
authorBrandon Casey <casey@nrlssc.navy.mil>2008-01-16 13:12:46 -0600
committerJunio C Hamano <gitster@pobox.com>2008-01-16 15:35:35 -0800
commit4ed7cd3ab07f7c721daf4241fe1dac306fefd1fb (patch)
treee3b03a59cd0bca192fb396522f813210451404b8 /builtin-commit.c
parentd6cf61bfd4bccffcc8b095f8469dbe749d70abdf (diff)
downloadgit-4ed7cd3ab07f7c721daf4241fe1dac306fefd1fb.tar.gz
git-4ed7cd3ab07f7c721daf4241fe1dac306fefd1fb.tar.xz
Improve use of lockfile API
Remove remaining double close(2)'s. i.e. close() before commit_locked_index() or commit_lock_file(). Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-commit.c')
-rw-r--r--builtin-commit.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/builtin-commit.c b/builtin-commit.c
index 49541c058..02279360f 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -237,7 +237,8 @@ static char *prepare_index(int argc, const char **argv, const char *prefix)
int fd = hold_locked_index(&index_lock, 1);
add_files_to_cache(0, also ? prefix : NULL, pathspec);
refresh_cache(REFRESH_QUIET);
- if (write_cache(fd, active_cache, active_nr))
+ if (write_cache(fd, active_cache, active_nr) ||
+ close_lock_file(&index_lock))
die("unable to write new_index file");
commit_style = COMMIT_NORMAL;
return index_lock.filename;
@@ -298,7 +299,8 @@ static char *prepare_index(int argc, const char **argv, const char *prefix)
fd = hold_locked_index(&index_lock, 1);
add_remove_files(&partial);
refresh_cache(REFRESH_QUIET);
- if (write_cache(fd, active_cache, active_nr))
+ if (write_cache(fd, active_cache, active_nr) ||
+ close_lock_file(&index_lock))
die("unable to write new_index file");
fd = hold_lock_file_for_update(&false_lock,
@@ -308,7 +310,8 @@ static char *prepare_index(int argc, const char **argv, const char *prefix)
add_remove_files(&partial);
refresh_cache(REFRESH_QUIET);
- if (write_cache(fd, active_cache, active_nr))
+ if (write_cache(fd, active_cache, active_nr) ||
+ close_lock_file(&false_lock))
die("unable to write temporary index file");
return false_lock.filename;
}