send-pack: report signal death of pack-objects
If our pack-objects sub-process dies of a signal, then it likely didn't have a chance to write anything useful to stderr. The user may be left scratching their head why the push failed. Let's detect this situation and write something to stderr. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Mar 7, 2017 at 08:39 UTC
d1a13d3fcb252631361a961cb5e2bf10ed467cba
1 file changed
+14
-1
send-pack.c
+14
-1
@@ -72,6 +72,7 @@ static int pack_objects(int fd, struct ref *refs, struct sha1_array *extra, stru
72
struct child_process po = CHILD_PROCESS_INIT;
73
FILE *po_in;
74
int i;
75
+ int rc;
76
77
i = 4;
78
if (args->use_thin_pack)
@@ -125,8 +126,20 @@ static int pack_objects(int fd, struct ref *refs, struct sha1_array *extra, stru
126
po.out = -1;
127
}
128
128
- if (finish_command(&po))
129
+ rc = finish_command(&po);
130
+ if (rc) {
131
+ /*
132
+ * For a normal non-zero exit, we assume pack-objects wrote
133
+ * something useful to stderr. For death by signal, though,
134
+ * we should mention it to the user. The exception is SIGPIPE
135
+ * (141), because that's a normal occurence if the remote end
136
+ * hangs up (and we'll report that by trying to read the unpack
137
+ * status).
138
+ */
139
+ if (rc > 128 && rc != 141)
140
+ error("pack-objects died of signal %d", rc - 128);
141
return -1;
142
+ }
143
return 0;
144
}
145