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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---

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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]