MCPcopy Create free account
hub / github.com/git/git / execute_commands_atomic

Function execute_commands_atomic

builtin/receive-pack.c:1985–2026  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1983}
1984
1985static 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
2018failure:
2019 for (cmd = commands; cmd; cmd = cmd->next)
2020 if (!cmd->error_string)
2021 cmd->error_string = reported_error;
2022
2023cleanup:
2024 ref_transaction_free(transaction);
2025 strbuf_release(&err);
2026}
2027
2028static void execute_commands(struct command *commands,
2029 const char *unpacker_error,

Callers 1

execute_commandsFunction · 0.85

Calls 8

get_main_ref_storeFunction · 0.85
rp_errorFunction · 0.85
should_process_cmdFunction · 0.85
ref_transaction_commitFunction · 0.85
ref_transaction_freeFunction · 0.85
strbuf_releaseFunction · 0.85
updateFunction · 0.70

Tested by

no test coverage detected