aboutsummaryrefslogtreecommitdiff
path: root/tempfile.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-09-24 10:30:46 -0700
committerJunio C Hamano <gitster@pobox.com>2018-09-24 10:30:46 -0700
commit48a81ed29795da3e4cc40d4e5ea535878e4f2d9f (patch)
tree0bbe3588f5728fa03ae0ef69dc9111ef91479a83 /tempfile.c
parent9715f10e4206c681313d45efa239a594a0027e60 (diff)
parent6c003d6ffb7ebd1599e73921cab5e01d7428001d (diff)
downloadgit-48a81ed29795da3e4cc40d4e5ea535878e4f2d9f.tar.xz
Merge branch 'jk/reopen-tempfile-truncate'
Fix for a long-standing bug that leaves the index file corrupt when it shrinks during a partial commit. * jk/reopen-tempfile-truncate: reopen_tempfile(): truncate opened file
Diffstat (limited to 'tempfile.c')
-rw-r--r--tempfile.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tempfile.c b/tempfile.c
index 139ecd97f8..d43ad8c191 100644
--- a/tempfile.c
+++ b/tempfile.c
@@ -279,7 +279,7 @@ int reopen_tempfile(struct tempfile *tempfile)
BUG("reopen_tempfile called for an inactive object");
if (0 <= tempfile->fd)
BUG("reopen_tempfile called for an open object");
- tempfile->fd = open(tempfile->filename.buf, O_WRONLY);
+ tempfile->fd = open(tempfile->filename.buf, O_WRONLY|O_TRUNC);
return tempfile->fd;
}