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>
This commit is contained in:

committed by
Junio C Hamano

parent
a0c2089c1d
commit
6244b24906
@ -181,7 +181,7 @@ int cmd_add(int argc, const char **argv, char **envp)
|
|||||||
|
|
||||||
if (active_cache_changed) {
|
if (active_cache_changed) {
|
||||||
if (write_cache(newfd, active_cache, active_nr) ||
|
if (write_cache(newfd, active_cache, active_nr) ||
|
||||||
commit_lock_file(&lock_file))
|
close(newfd) || commit_lock_file(&lock_file))
|
||||||
die("Unable to write new index file");
|
die("Unable to write new index file");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2323,7 +2323,7 @@ int cmd_apply(int argc, const char **argv, char **envp)
|
|||||||
|
|
||||||
if (write_index) {
|
if (write_index) {
|
||||||
if (write_cache(newfd, active_cache, active_nr) ||
|
if (write_cache(newfd, active_cache, active_nr) ||
|
||||||
commit_lock_file(&lock_file))
|
close(newfd) || commit_lock_file(&lock_file))
|
||||||
die("Unable to write new index file");
|
die("Unable to write new index file");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1038,7 +1038,7 @@ int cmd_read_tree(int argc, const char **argv, char **envp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (write_cache(newfd, active_cache, active_nr) ||
|
if (write_cache(newfd, active_cache, active_nr) ||
|
||||||
commit_lock_file(&lock_file))
|
close(newfd) || commit_lock_file(&lock_file))
|
||||||
die("unable to write new index file");
|
die("unable to write new index file");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ int cmd_rm(int argc, const char **argv, char **envp)
|
|||||||
|
|
||||||
if (active_cache_changed) {
|
if (active_cache_changed) {
|
||||||
if (write_cache(newfd, active_cache, active_nr) ||
|
if (write_cache(newfd, active_cache, active_nr) ||
|
||||||
commit_lock_file(&lock_file))
|
close(newfd) || commit_lock_file(&lock_file))
|
||||||
die("Unable to write new index file");
|
die("Unable to write new index file");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -648,7 +648,7 @@ int cmd_update_index(int argc, const char **argv, char **envp)
|
|||||||
finish:
|
finish:
|
||||||
if (active_cache_changed) {
|
if (active_cache_changed) {
|
||||||
if (write_cache(newfd, active_cache, active_nr) ||
|
if (write_cache(newfd, active_cache, active_nr) ||
|
||||||
commit_lock_file(lock_file))
|
close(newfd) || commit_lock_file(lock_file))
|
||||||
die("Unable to write new index file");
|
die("Unable to write new index file");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,8 @@ int write_tree(unsigned char *sha1, int missing_ok, const char *prefix)
|
|||||||
missing_ok, 0) < 0)
|
missing_ok, 0) < 0)
|
||||||
die("git-write-tree: error building trees");
|
die("git-write-tree: error building trees");
|
||||||
if (0 <= newfd) {
|
if (0 <= newfd) {
|
||||||
if (!write_cache(newfd, active_cache, active_nr))
|
if (!write_cache(newfd, active_cache, active_nr)
|
||||||
|
&& !close(newfd))
|
||||||
commit_lock_file(lock_file);
|
commit_lock_file(lock_file);
|
||||||
}
|
}
|
||||||
/* Not being able to write is fine -- we are only interested
|
/* Not being able to write is fine -- we are only interested
|
||||||
|
@ -311,7 +311,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (0 <= newfd &&
|
if (0 <= newfd &&
|
||||||
(write_cache(newfd, active_cache, active_nr) ||
|
(write_cache(newfd, active_cache, active_nr) ||
|
||||||
commit_lock_file(&lock_file)))
|
close(newfd) || commit_lock_file(&lock_file)))
|
||||||
die("Unable to write new index file");
|
die("Unable to write new index file");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user