Skip to content

Commit 25c0890

Browse files
committed
Merge branch 'jk/receive-pack-unpack-error-to-pusher' into maint
"git receive-pack" (the counterpart to "git push") did not give progress output while processing objects it received to the puser when run over the smart-http 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
2 parents 9b4030c + 74eb32d commit 25c0890

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

builtin/receive-pack.c

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ static void execute_commands(struct command *commands, const char *unpacker_erro
701701

702702
if (unpacker_error) {
703703
for (cmd = commands; cmd; cmd = cmd->next)
704-
cmd->error_string = "n/a (unpacker error)";
704+
cmd->error_string = "unpacker error";
705705
return;
706706
}
707707

@@ -801,7 +801,7 @@ static const char *parse_pack_header(struct pack_header *hdr)
801801

802802
static const char *pack_lockfile;
803803

804-
static const char *unpack(void)
804+
static const char *unpack(int err_fd)
805805
{
806806
struct pack_header hdr;
807807
const char *hdr_err;
@@ -821,6 +821,7 @@ static const char *unpack(void)
821821

822822
if (ntohl(hdr.hdr_entries) < unpack_limit) {
823823
int code, i = 0;
824+
struct child_process child;
824825
const char *unpacker[5];
825826
unpacker[i++] = "unpack-objects";
826827
if (quiet)
@@ -829,7 +830,12 @@ static const char *unpack(void)
829830
unpacker[i++] = "--strict";
830831
unpacker[i++] = hdr_arg;
831832
unpacker[i++] = NULL;
832-
code = run_command_v_opt(unpacker, RUN_GIT_CMD);
833+
memset(&child, 0, sizeof(child));
834+
child.argv = unpacker;
835+
child.no_stdout = 1;
836+
child.err = err_fd;
837+
child.git_cmd = 1;
838+
code = run_command(&child);
833839
if (!code)
834840
return NULL;
835841
return "unpack-objects abnormal exit";
@@ -854,6 +860,7 @@ static const char *unpack(void)
854860
memset(&ip, 0, sizeof(ip));
855861
ip.argv = keeper;
856862
ip.out = -1;
863+
ip.err = err_fd;
857864
ip.git_cmd = 1;
858865
status = start_command(&ip);
859866
if (status) {
@@ -870,6 +877,26 @@ static const char *unpack(void)
870877
}
871878
}
872879

880+
static const char *unpack_with_sideband(void)
881+
{
882+
struct async muxer;
883+
const char *ret;
884+
885+
if (!use_sideband)
886+
return unpack(0);
887+
888+
memset(&muxer, 0, sizeof(muxer));
889+
muxer.proc = copy_to_sideband;
890+
muxer.in = -1;
891+
if (start_async(&muxer))
892+
return NULL;
893+
894+
ret = unpack(muxer.in);
895+
896+
finish_async(&muxer);
897+
return ret;
898+
}
899+
873900
static void report(struct command *commands, const char *unpack_status)
874901
{
875902
struct command *cmd;
@@ -967,7 +994,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
967994
const char *unpack_status = NULL;
968995

969996
if (!delete_only(commands))
970-
unpack_status = unpack();
997+
unpack_status = unpack_with_sideband();
971998
execute_commands(commands, unpack_status);
972999
if (pack_lockfile)
9731000
unlink_or_warn(pack_lockfile);

t/t5504-fetch-receive-strict.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ test_expect_success 'push with !receive.fsckobjects' '
8989

9090
cat >exp <<EOF
9191
To dst
92-
! refs/heads/master:refs/heads/test [remote rejected] (n/a (unpacker error))
92+
! refs/heads/master:refs/heads/test [remote rejected] (unpacker error)
9393
EOF
9494

9595
test_expect_success 'push with receive.fsckobjects' '

0 commit comments

Comments
 (0)