From 0f4a0865ce0024015f42533f29fcb69f4000e99a Mon Sep 17 00:00:00 2001 From: chib xue Date: Fri, 4 Sep 2026 22:17:38 +0800 Subject: [PATCH] git-gui: ignore broken-pipe error when closing cat-file pipe commit_committree opens "git cat-file commit " to read the tree line for the empty-commit check, but needs only that first line. It then closes the pipe while the rest of the commit object (often several kilobytes of commit message) is still unread. On Linux this is harmless: the child process dies of SIGPIPE when it keeps writing, and Tcl's [close] does not report that as an error. On Windows there is no SIGPIPE: the native git.exe gets a broken-pipe error when writing and exits with a non-zero status, so Tcl's [close] raises "child process exited abnormally". That aborts the commit and the index lock is released with nothing committed. The failure only shows up once the parent's commit object is larger than the pipe buffer (about 8 KiB on Windows): in testing with Git for Windows 2.52, objects up to ~6.5 KiB always succeed while objects of ~9 KiB and up fail 10 out of 10 times. Wrap the [close] in a [catch], as is done for other pipes elsewhere in git-gui. Signed-off-by: chib xue --- lib/commit.tcl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/commit.tcl b/lib/commit.tcl index 89eb8c7b739131..0ffc3ec0284024 100644 --- a/lib/commit.tcl +++ b/lib/commit.tcl @@ -386,7 +386,9 @@ proc commit_committree {fd_wt curHEAD msg_p} { set fd_ot [git_read [list cat-file commit $PARENT]] fconfigure $fd_ot -encoding iso8859-1 set old_tree [gets $fd_ot] - close $fd_ot + # Ignore a failure at close time: on Windows the child may + # die writing the unread tail of the commit object. + catch {close $fd_ot} if {[string equal -length 5 {tree } $old_tree] && [string length $old_tree] == [expr {$hashlength + 5}]} {