summaryrefslogtreecommitdiff
path: root/pack-write.c
diff options
context:
space:
mode:
authorChristian Couder <christian.couder@gmail.com>2021-01-14 15:50:16 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-01-15 01:02:22 (GMT)
commit7c99bc23fcd69eeebf8a92263b5d90673c510a6a (patch)
tree5e582f9e9d3c4828da2b81181c2222e80fa7893c /pack-write.c
parent33add2ad7d6921489aa0cafd4a865504c3709512 (diff)
downloadgit-7c99bc23fcd69eeebf8a92263b5d90673c510a6a.zip
git-7c99bc23fcd69eeebf8a92263b5d90673c510a6a.tar.gz
git-7c99bc23fcd69eeebf8a92263b5d90673c510a6a.tar.bz2
pack-write: die on error in write_promisor_file()
write_promisor_file() already uses xfopen(), so it would die if the file cannot be opened for writing. To be consistent with this behavior and not overlook issues, let's also die if there are errors when we are actually writing to the file. Suggested-by: Jeff King <peff@peff.net> Suggested-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pack-write.c')
-rw-r--r--pack-write.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/pack-write.c b/pack-write.c
index db3ff99..e9bb3fd 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -371,11 +371,15 @@ void finish_tmp_packfile(struct strbuf *name_buffer,
void write_promisor_file(const char *promisor_name, struct ref **sought, int nr_sought)
{
- int i;
+ int i, err;
FILE *output = xfopen(promisor_name, "w");
for (i = 0; i < nr_sought; i++)
fprintf(output, "%s %s\n", oid_to_hex(&sought[i]->old_oid),
sought[i]->name);
- fclose(output);
+
+ err = ferror(output);
+ err |= fclose(output);
+ if (err)
+ die(_("could not write '%s' promisor file"), promisor_name);
}