git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 5/7] receive-pack: move execute_commands_non_atomic before execute_commands

From
Stefan Beller <sbeller@google.com>
Date
Dec 19, 2014, 19:38 UTC
Message-ID
<1419017941-7090-6-git-send-email-sbeller@google.com>
In-Reply-To
<1419017941-7090-1-git-send-email-sbeller@google.com>

This way we don't need to declare the function first and implement it later, but rather we put the implementation directly at the place where the function was declared.

The reason I did not move it up in the first place is better readability of the diff as the execute_commands_non_atomic function is taking lots of code that was once in execute_commands.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
Notes:
    This patch is new with v6 of the series
    
    As execute_commands_non_atomic is larger than execute_commands, the diff
    is not moving around execute_commands_non_atomic, but execute_commands.
    These two functions were one after the other and switch places that way.
 builtin/receive-pack.c | 86 ++++++++++++++++++++++++--------------------------
 1 file changed, 41 insertions(+), 45 deletions(-)
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 710cd7f..d47e73b 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -1047,10 +1047,6 @@ static void reject_updates_to_hidden(struct command *commands)
 	}
 }
 
-static void execute_commands_non_atomic(struct command *commands,
-				    struct shallow_info *si);
-
-
 static void execute_commands_atomic(struct command *commands,
 				    struct shallow_info *si)
 {
@@ -1109,47 +1105,6 @@ failure:
 		      "the reported refs above");
 }
 
-static void execute_commands(struct command *commands,
-			     const char *unpacker_error,
-			     struct shallow_info *si)
-{
-	struct command *cmd;
-	unsigned char sha1[20];
-	struct iterate_data data;
-
-	if (unpacker_error) {
-		for (cmd = commands; cmd; cmd = cmd->next)
-			cmd->error_string = "unpacker error";
-		return;
-	}
-
-	data.cmds = commands;
-	data.si = si;
-	if (check_everything_connected(iterate_receive_command_list, 0, &data))
-		set_connectivity_errors(commands, si);
-
-	reject_updates_to_hidden(commands);
-
-	if (run_receive_hook(commands, "pre-receive", 0)) {
-		for (cmd = commands; cmd; cmd = cmd->next) {
-			if (!cmd->error_string)
-				cmd->error_string = "pre-receive hook declined";
-		}
-		return;
-	}
-
-	check_aliased_updates(commands);
-
-	free(head_name_to_free);
-	head_name = head_name_to_free = resolve_refdup("HEAD", 0, sha1, NULL);
-
-	if (use_atomic) {
-		execute_commands_atomic(commands, si);
-	} else {
-		execute_commands_non_atomic(commands, si);
-	}
-}
-
 static void execute_commands_non_atomic(struct command *commands,
 					struct shallow_info *si)
 {
@@ -1195,6 +1150,47 @@ static void execute_commands_non_atomic(struct command *commands,
 	strbuf_release(&err);
 }
 
+static void execute_commands(struct command *commands,
+			     const char *unpacker_error,
+			     struct shallow_info *si)
+{
+	struct command *cmd;
+	unsigned char sha1[20];
+	struct iterate_data data;
+
+	if (unpacker_error) {
+		for (cmd = commands; cmd; cmd = cmd->next)
+			cmd->error_string = "unpacker error";
+		return;
+	}
+
+	data.cmds = commands;
+	data.si = si;
+	if (check_everything_connected(iterate_receive_command_list, 0, &data))
+		set_connectivity_errors(commands, si);
+
+	reject_updates_to_hidden(commands);
+
+	if (run_receive_hook(commands, "pre-receive", 0)) {
+		for (cmd = commands; cmd; cmd = cmd->next) {
+			if (!cmd->error_string)
+				cmd->error_string = "pre-receive hook declined";
+		}
+		return;
+	}
+
+	check_aliased_updates(commands);
+
+	free(head_name_to_free);
+	head_name = head_name_to_free = resolve_refdup("HEAD", 0, sha1, NULL);
+
+	if (use_atomic) {
+		execute_commands_atomic(commands, si);
+	} else {
+		execute_commands_non_atomic(commands, si);
+	}
+}
+
 static struct command **queue_command(struct command **tail,
 				      const char *line,
 				      int linelen)
-- 
2.2.1.62.g3f15098
Previous: Eric SunshineNext: Junio C Hamano
Message 12 of 20 in “[PATCHv6 0/7] atomic pushes”
  1. Stefan BellerDec 19, 2014
  2. 1/7 receive-pack.c: add protocol support to negotiate atomic-pushStefan Beller, Dec 19, 2014
  3. Eric SunshineDec 22, 2014
  4. Stefan BellerDec 23, 2014
  5. Michael HaggertyDec 24, 2014
  6. Junio C HamanoDec 30, 2014
  7. 2/7 send-pack: Rename ref_update_to_be_sent to check_to_send_updateStefan Beller, Dec 19, 2014
  8. 3/7 send-pack.c: add --atomic command line argumentStefan Beller, Dec 19, 2014
  9. Eric SunshineDec 22, 2014
  10. 4/7 receive-pack.c: receive-pack.c: use a single ref_transaction for atomic pushesStefan Beller, Dec 19, 2014
  11. Eric SunshineDec 23, 2014
  12. 5/7 receive-pack: move execute_commands_non_atomic before execute_commandsStefan Beller, Dec 19, 2014
  13. Junio C HamanoDec 22, 2014
  14. Stefan BellerDec 24, 2014
  15. 6/7 push.c: add an --atomic argumentStefan Beller, Dec 19, 2014
  16. Michael HaggertyDec 26, 2014
  17. Stefan BellerDec 29, 2014
  18. Junio C HamanoDec 29, 2014
  19. 7/7 t5543-atomic-push.sh: add basic tests for atomic pushesStefan Beller, Dec 19, 2014
  20. Junio C HamanoDec 22, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.