Thread (22 messages) 22 messages, 4 authors, 10d ago

[PATCH v3 1/2] merge-ll: catch close() errors when writing external tempfiles

flat view
COOLING10d

From: Jeff King <hidden>
Date: 2026-09-29 05:12:56
Subsystem: the rest · Maintainer: Linus Torvalds

When writing out tempfiles for an external merge driver, we catch the
case that write() fails, but not the follow-up close(). This close()
would usually succeed, but the system could report a delayed write error
(e.g., on a network file system).

Since we're adding a new error message here, we'll also make the
existing one match it: mark it for translation and mention the actual
path. The exact wording here was picked to match some existing
translated messages.

Signed-off-by: Jeff King <redacted>
---
Since v2, this is hopefully written in a more obviously-correct way,
rather than the short-circuit OR.

 merge-ll.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/merge-ll.c b/merge-ll.c
index ef5287dee8..62d402199d 100644
--- a/merge-ll.c
+++ b/merge-ll.c
@@ -181,8 +181,9 @@ static void create_temp(mmfile_t *src, char *path, size_t len)
 	xsnprintf(path, len, ".merge_file_XXXXXX");
 	fd = xmkstemp(path);
 	if (write_in_full(fd, src->ptr, src->size) < 0)
-		die_errno("unable to write temp-file");
-	close(fd);
+		die_errno(_("unable to write %s"), path);
+	if (close(fd) < 0)
+		die_errno(_("unable to close %s"), path);
 }
 
 /*
-- 
2.56.0.rc2.338.gcaacf6bdf7
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help