Don't ignore a pack-refs write failure
authorJim Meyering <jim@meyering.net>
Sun, 24 Jun 2007 19:13:11 +0000 (21:13 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 27 Jun 2007 04:49:44 +0000 (21:49 -0700)
Without this, if the size of refs_file at that point is ever an exact
multiple of BUFSIZ, then an EIO or ENOSPC error on the final write would
not be diagnosed.

It's not worth worrying about EPIPE here.
Although theoretically possible that someone kill this process
with a manual SIGPIPE, it's not at all likely.

Signed-off-by: Jim Meyering <jim@meyering.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-pack-refs.c

index 1952950c9a4bf13dc728bb8d6a79493dad36df06..758499238f6d4110eb3740b77c92753edc8e5760 100644 (file)
@@ -105,6 +105,8 @@ static int pack_refs(unsigned int flags)
        fprintf(cbdata.refs_file, "# pack-refs with: peeled \n");
 
        for_each_ref(handle_one_ref, &cbdata);
+       if (ferror(cbdata.refs_file))
+               die("failed to write ref-pack file");
        if (fflush(cbdata.refs_file) || fsync(fd) || fclose(cbdata.refs_file))
                die("failed to write ref-pack file (%s)", strerror(errno));
        if (commit_lock_file(&packed) < 0)