Merge branch 'jk/receive-pack-unpack-error-to-pusher'
authorJunio C Hamano <gitster@pobox.com>
Mon, 1 Oct 2012 19:58:34 +0000 (12:58 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 1 Oct 2012 19:58:34 +0000 (12:58 -0700)
Send errors from "unpack-objects" and "index-pack" back to the "git
push" over the git and smart-http protocols, just like it is done
for a push over the ssh protocol.

* jk/receive-pack-unpack-error-to-pusher:
receive-pack: drop "n/a" on unpacker errors
receive-pack: send pack-processing stderr over sideband
receive-pack: redirect unpack-objects stdout to /dev/null

1  2 
builtin/receive-pack.c
diff --combined builtin/receive-pack.c
index 9145f1a5950fcd363a5e65e817df5c61bd769c01,165a633204bed5ffc279e3af703a3d275e3e3822..ff781febcad92dfccd8a3d97d0414526ded36943
@@@ -480,6 -480,7 +480,6 @@@ static const char *update(struct comman
            !prefixcmp(name, "refs/heads/")) {
                struct object *old_object, *new_object;
                struct commit *old_commit, *new_commit;
 -              struct commit_list *bases, *ent;
  
                old_object = parse_object(old_sha1);
                new_object = parse_object(new_sha1);
                }
                old_commit = (struct commit *)old_object;
                new_commit = (struct commit *)new_object;
 -              bases = get_merge_bases(old_commit, new_commit, 1);
 -              for (ent = bases; ent; ent = ent->next)
 -                      if (!hashcmp(old_sha1, ent->item->object.sha1))
 -                              break;
 -              free_commit_list(bases);
 -              if (!ent) {
 +              if (!in_merge_bases(old_commit, new_commit)) {
                        rp_error("denying non-fast-forward %s"
                                 " (you should pull first)", name);
                        return "non-fast-forward";
@@@ -695,7 -701,7 +695,7 @@@ static void execute_commands(struct com
  
        if (unpacker_error) {
                for (cmd = commands; cmd; cmd = cmd->next)
-                       cmd->error_string = "n/a (unpacker error)";
+                       cmd->error_string = "unpacker error";
                return;
        }
  
@@@ -795,7 -801,7 +795,7 @@@ static const char *parse_pack_header(st
  
  static const char *pack_lockfile;
  
- static const char *unpack(void)
+ static const char *unpack(int err_fd)
  {
        struct pack_header hdr;
        const char *hdr_err;
  
        if (ntohl(hdr.hdr_entries) < unpack_limit) {
                int code, i = 0;
+               struct child_process child;
                const char *unpacker[5];
                unpacker[i++] = "unpack-objects";
                if (quiet)
                        unpacker[i++] = "--strict";
                unpacker[i++] = hdr_arg;
                unpacker[i++] = NULL;
-               code = run_command_v_opt(unpacker, RUN_GIT_CMD);
+               memset(&child, 0, sizeof(child));
+               child.argv = unpacker;
+               child.no_stdout = 1;
+               child.err = err_fd;
+               child.git_cmd = 1;
+               code = run_command(&child);
                if (!code)
                        return NULL;
                return "unpack-objects abnormal exit";
                memset(&ip, 0, sizeof(ip));
                ip.argv = keeper;
                ip.out = -1;
+               ip.err = err_fd;
                ip.git_cmd = 1;
                status = start_command(&ip);
                if (status) {
        }
  }
  
+ static const char *unpack_with_sideband(void)
+ {
+       struct async muxer;
+       const char *ret;
+       if (!use_sideband)
+               return unpack(0);
+       memset(&muxer, 0, sizeof(muxer));
+       muxer.proc = copy_to_sideband;
+       muxer.in = -1;
+       if (start_async(&muxer))
+               return NULL;
+       ret = unpack(muxer.in);
+       finish_async(&muxer);
+       return ret;
+ }
  static void report(struct command *commands, const char *unpack_status)
  {
        struct command *cmd;
@@@ -961,7 -994,7 +988,7 @@@ int cmd_receive_pack(int argc, const ch
                const char *unpack_status = NULL;
  
                if (!delete_only(commands))
-                       unpack_status = unpack();
+                       unpack_status = unpack_with_sideband();
                execute_commands(commands, unpack_status);
                if (pack_lockfile)
                        unlink_or_warn(pack_lockfile);