7 static pid_t setup_sideband(int sideband, const char *me, int fd[2], int xd[2])
16 /* xd[] is talking with upload-pack; subprocess reads from
17 * xd[0], spits out band#2 to stderr, and feeds us band#1
21 die("%s: unable to set up pipe", me);
24 die("%s: unable to fork off sideband demultiplexer", me);
30 if (recv_sideband(me, xd[0], fd[1], 2))
40 static int get_pack(int xd[2], const char *me, int sideband, const char **argv)
46 side_pid = setup_sideband(sideband, me, fd, xd);
49 die("%s: unable to fork off %s", me, argv[0]);
55 die("%s exec failed", argv[0]);
59 while (waitpid(pid, &status, 0) < 0) {
61 die("waiting for %s: %s", argv[0], strerror(errno));
63 if (WIFEXITED(status)) {
64 int code = WEXITSTATUS(status);
66 die("%s died with error code %d", argv[0], code);
69 if (WIFSIGNALED(status)) {
70 int sig = WTERMSIG(status);
71 die("%s died of signal %d", argv[0], sig);
73 die("%s died of unnatural causes %d", argv[0], status);
76 int receive_unpack_pack(int xd[2], const char *me, int quiet, int sideband)
78 const char *argv[3] = { "unpack-objects", quiet ? "-q" : NULL, NULL };
79 return get_pack(xd, me, sideband, argv);
82 int receive_keep_pack(int xd[2], const char *me, int quiet, int sideband)
84 const char *argv[5] = { "index-pack", "--stdin", "--fix-thin",
85 quiet ? NULL : "-v", NULL };
86 return get_pack(xd, me, sideband, argv);