| 1983 | } |
| 1984 | |
| 1985 | static void execute_commands_atomic(struct command *commands, |
| 1986 | struct shallow_info *si) |
| 1987 | { |
| 1988 | struct command *cmd; |
| 1989 | struct strbuf err = STRBUF_INIT; |
| 1990 | const char *reported_error = "atomic push failure"; |
| 1991 | |
| 1992 | transaction = ref_store_transaction_begin(get_main_ref_store(the_repository), |
| 1993 | 0, &err); |
| 1994 | if (!transaction) { |
| 1995 | rp_error("%s", err.buf); |
| 1996 | strbuf_reset(&err); |
| 1997 | reported_error = "transaction failed to start"; |
| 1998 | goto failure; |
| 1999 | } |
| 2000 | |
| 2001 | for (cmd = commands; cmd; cmd = cmd->next) { |
| 2002 | if (!should_process_cmd(cmd) || cmd->run_proc_receive) |
| 2003 | continue; |
| 2004 | |
| 2005 | cmd->error_string = update(cmd, si); |
| 2006 | |
| 2007 | if (cmd->error_string) |
| 2008 | goto failure; |
| 2009 | } |
| 2010 | |
| 2011 | if (ref_transaction_commit(transaction, &err)) { |
| 2012 | rp_error("%s", err.buf); |
| 2013 | reported_error = "atomic transaction failed"; |
| 2014 | goto failure; |
| 2015 | } |
| 2016 | goto cleanup; |
| 2017 | |
| 2018 | failure: |
| 2019 | for (cmd = commands; cmd; cmd = cmd->next) |
| 2020 | if (!cmd->error_string) |
| 2021 | cmd->error_string = reported_error; |
| 2022 | |
| 2023 | cleanup: |
| 2024 | ref_transaction_free(transaction); |
| 2025 | strbuf_release(&err); |
| 2026 | } |
| 2027 | |
| 2028 | static void execute_commands(struct command *commands, |
| 2029 | const char *unpacker_error, |
no test coverage detected