Skip to content

Commit d1a13d3

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ba69f92 commit d1a13d3

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

send-pack.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ static int pack_objects(int fd, struct ref *refs, struct sha1_array *extra, stru
7272
struct child_process po = CHILD_PROCESS_INIT;
7373
FILE *po_in;
7474
int i;
75+
int rc;
7576

7677
i = 4;
7778
if (args->use_thin_pack)
@@ -125,8 +126,20 @@ static int pack_objects(int fd, struct ref *refs, struct sha1_array *extra, stru
125126
po.out = -1;
126127
}
127128

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);
129141
return -1;
142+
}
130143
return 0;
131144
}
132145

0 commit comments

Comments
 (0)