t/helper: remove dependency on `the_repository` in "proc-receive"

The "proc-receive" test helper implicitly relies on `the_repository` via `parse_oid_hex()`. This isn't necessary though, and in fact the whole command does not depend on `the_repository` at all. Stop setting up `the_repository` and use `parse_oid_hex_any()` to parse object IDs. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Jun 14, 2024 at 08:51 UTC 912d4756cde9513e500f345fcc9b7a2c43a47e65
1 file changed +3 -6
t/helper/test-proc-receive.c
+3 -6
@@ -3,8 +3,8 @@
3 #include "hex.h"
4 #include "parse-options.h"
5 #include "pkt-line.h"
6 -#include "setup.h"
6 #include "sigchain.h"
7 +#include "string-list.h"
8
9 static const char *proc_receive_usage[] = {
10 "test-tool proc-receive [<options>]",
@@ -92,9 +92,9 @@ static void proc_receive_read_commands(struct packet_reader *reader,
92 if (die_read_commands)
93 die("die with the --die-read-commands option");
94
95 - if (parse_oid_hex(reader->line, &old_oid, &p) ||
95 + if (parse_oid_hex_any(reader->line, &old_oid, &p) == GIT_HASH_UNKNOWN ||
96 *p++ != ' ' ||
97 - parse_oid_hex(p, &new_oid, &p) ||
97 + parse_oid_hex_any(p, &new_oid, &p) == GIT_HASH_UNKNOWN ||
98 *p++ != ' ')
99 die("protocol error: expected 'old new ref', got '%s'",
100 reader->line);
@@ -128,7 +128,6 @@ static void proc_receive_read_push_options(struct packet_reader *reader,
128
129 int cmd__proc_receive(int argc, const char **argv)
130 {
131 - int nongit_ok = 0;
131 struct packet_reader reader;
132 struct command *commands = NULL;
133 struct string_list push_options = STRING_LIST_INIT_DUP;
@@ -154,8 +153,6 @@ int cmd__proc_receive(int argc, const char **argv)
153 OPT_END()
154 };
155
157 - setup_git_directory_gently(&nongit_ok);
158 -
156 argc = parse_options(argc, argv, "test-tools", options, proc_receive_usage, 0);
157 if (argc > 0)
158 usage_msg_opt("Too many arguments.", proc_receive_usage, options);