@matheusbsbs / matheus-bagliano / commits / 6244b24906
Fork 0

Close the index file between writing and committing

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>

Johannes Schindelin committed Jul 8, 2006 at 10:56 UTC 6244b24906f9efa4c1d573fa79e73eaf8e557551
7 files changed +8 -7
builtin-add.c
+1 -1
@@ -181,7 +181,7 @@ int cmd_add(int argc, const char **argv, char **envp)
181
182 if (active_cache_changed) {
183 if (write_cache(newfd, active_cache, active_nr) ||
184 - commit_lock_file(&lock_file))
184 + close(newfd) || commit_lock_file(&lock_file))
185 die("Unable to write new index file");
186 }
187
builtin-apply.c
+1 -1
@@ -2323,7 +2323,7 @@ int cmd_apply(int argc, const char **argv, char **envp)
2323
2324 if (write_index) {
2325 if (write_cache(newfd, active_cache, active_nr) ||
2326 - commit_lock_file(&lock_file))
2326 + close(newfd) || commit_lock_file(&lock_file))
2327 die("Unable to write new index file");
2328 }
2329
builtin-read-tree.c
+1 -1
@@ -1038,7 +1038,7 @@ int cmd_read_tree(int argc, const char **argv, char **envp)
1038 }
1039
1040 if (write_cache(newfd, active_cache, active_nr) ||
1041 - commit_lock_file(&lock_file))
1041 + close(newfd) || commit_lock_file(&lock_file))
1042 die("unable to write new index file");
1043 return 0;
1044 }
builtin-rm.c
+1 -1
@@ -147,7 +147,7 @@ int cmd_rm(int argc, const char **argv, char **envp)
147
148 if (active_cache_changed) {
149 if (write_cache(newfd, active_cache, active_nr) ||
150 - commit_lock_file(&lock_file))
150 + close(newfd) || commit_lock_file(&lock_file))
151 die("Unable to write new index file");
152 }
153
builtin-update-index.c
+1 -1
@@ -648,7 +648,7 @@ int cmd_update_index(int argc, const char **argv, char **envp)
648 finish:
649 if (active_cache_changed) {
650 if (write_cache(newfd, active_cache, active_nr) ||
651 - commit_lock_file(lock_file))
651 + close(newfd) || commit_lock_file(lock_file))
652 die("Unable to write new index file");
653 }
654
builtin-write-tree.c
+2 -1
@@ -35,7 +35,8 @@ int write_tree(unsigned char *sha1, int missing_ok, const char *prefix)
35 missing_ok, 0) < 0)
36 die("git-write-tree: error building trees");
37 if (0 <= newfd) {
38 - if (!write_cache(newfd, active_cache, active_nr))
38 + if (!write_cache(newfd, active_cache, active_nr)
39 + && !close(newfd))
40 commit_lock_file(lock_file);
41 }
42 /* Not being able to write is fine -- we are only interested
checkout-index.c
+1 -1
@@ -311,7 +311,7 @@ int main(int argc, char **argv)
311
312 if (0 <= newfd &&
313 (write_cache(newfd, active_cache, active_nr) ||
314 - commit_lock_file(&lock_file)))
314 + close(newfd) || commit_lock_file(&lock_file)))
315 die("Unable to write new index file");
316 return 0;
317 }