From: Junio C Hamano Date: Tue, 18 Oct 2011 04:37:10 +0000 (-0700) Subject: Merge branch 'ph/push-to-delete-nothing' X-Git-Tag: v1.7.8-rc0~62 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=cdc2b2f32cbeab0e2496a59a03a52043f59ebea9;p=git.git Merge branch 'ph/push-to-delete-nothing' * ph/push-to-delete-nothing: receive-pack: don't pass non-existent refs to post-{receive,update} hooks Conflicts: builtin/receive-pack.c --- cdc2b2f32cbeab0e2496a59a03a52043f59ebea9 diff --cc builtin/receive-pack.c index e2d3f9466,b73f18a57..261b610d2 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@@ -262,47 -264,6 +263,51 @@@ static int run_and_feed_hook(const cha return finish_command(&proc); } +struct receive_hook_feed_state { + struct command *cmd; ++ int skip_broken; + struct strbuf buf; +}; + +static int feed_receive_hook(void *state_, const char **bufp, size_t *sizep) +{ + struct receive_hook_feed_state *state = state_; + struct command *cmd = state->cmd; + - while (cmd && cmd->error_string) ++ while (cmd && ++ state->skip_broken && (cmd->error_string || cmd->did_not_exist)) + cmd = cmd->next; + if (!cmd) + return -1; /* EOF */ + strbuf_reset(&state->buf); + strbuf_addf(&state->buf, "%s %s %s\n", + sha1_to_hex(cmd->old_sha1), sha1_to_hex(cmd->new_sha1), + cmd->ref_name); + state->cmd = cmd->next; + if (bufp) { + *bufp = state->buf.buf; + *sizep = state->buf.len; + } + return 0; +} + - static int run_receive_hook(struct command *commands, const char *hook_name) ++static int run_receive_hook(struct command *commands, const char *hook_name, ++ int skip_broken) +{ + struct receive_hook_feed_state state; + int status; + + strbuf_init(&state.buf, 0); + state.cmd = commands; ++ state.skip_broken = skip_broken; + if (feed_receive_hook(&state, NULL, NULL)) + return 0; + state.cmd = commands; + status = run_and_feed_hook(hook_name, feed_receive_hook, &state); + strbuf_release(&state.buf); + return status; +} + static int run_update_hook(struct command *cmd) { static const char update_hook[] = "hooks/update"; @@@ -667,12 -596,7 +677,12 @@@ static void execute_commands(struct com return; } - if (run_receive_hook(commands, pre_receive_hook)) { + cmd = commands; + if (check_everything_connected(iterate_receive_command_list, + 0, &cmd)) + set_connectivity_errors(commands); + - if (run_receive_hook(commands, pre_receive_hook)) { ++ if (run_receive_hook(commands, pre_receive_hook, 0)) { for (cmd = commands; cmd; cmd = cmd->next) cmd->error_string = "pre-receive hook declined"; return; @@@ -940,7 -859,7 +950,7 @@@ int cmd_receive_pack(int argc, const ch unlink_or_warn(pack_lockfile); if (report_status) report(commands, unpack_status); -- run_receive_hook(commands, post_receive_hook); ++ run_receive_hook(commands, post_receive_hook, 1); run_update_post_hook(commands); if (auto_gc) { const char *argv_gc_auto[] = {