t/helper: stop setting up `the_repository` repeatedly
The "repository" test helper sets up `the_repository` twice. In fact though, we don't even have to set it up even once: all we need is to set up its hash algorithm, because we still depend on some subsystems that aren't free of `the_repository`. Refactor the code accordingly. This prepares for a subsequent change, where setting up the repository repeatedly will lead to a `BUG()`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>main
parent
8dc22e87f0
commit
eea83c010c
|
|
@ -17,10 +17,6 @@ static void test_parse_commit_in_graph(const char *gitdir, const char *worktree,
|
|||
struct commit *c;
|
||||
struct commit_list *parent;
|
||||
|
||||
setup_git_env(gitdir);
|
||||
|
||||
repo_clear(the_repository);
|
||||
|
||||
if (repo_init(&r, gitdir, worktree))
|
||||
die("Couldn't init repo");
|
||||
|
||||
|
|
@ -47,10 +43,6 @@ static void test_get_commit_tree_in_graph(const char *gitdir,
|
|||
struct commit *c;
|
||||
struct tree *tree;
|
||||
|
||||
setup_git_env(gitdir);
|
||||
|
||||
repo_clear(the_repository);
|
||||
|
||||
if (repo_init(&r, gitdir, worktree))
|
||||
die("Couldn't init repo");
|
||||
|
||||
|
|
@ -75,24 +67,20 @@ static void test_get_commit_tree_in_graph(const char *gitdir,
|
|||
|
||||
int cmd__repository(int argc, const char **argv)
|
||||
{
|
||||
int nongit_ok = 0;
|
||||
|
||||
setup_git_directory_gently(&nongit_ok);
|
||||
|
||||
if (argc < 2)
|
||||
die("must have at least 2 arguments");
|
||||
if (!strcmp(argv[1], "parse_commit_in_graph")) {
|
||||
struct object_id oid;
|
||||
if (argc < 5)
|
||||
die("not enough arguments");
|
||||
if (parse_oid_hex(argv[4], &oid, &argv[4]))
|
||||
if (parse_oid_hex_any(argv[4], &oid, &argv[4]) == GIT_HASH_UNKNOWN)
|
||||
die("cannot parse oid '%s'", argv[4]);
|
||||
test_parse_commit_in_graph(argv[2], argv[3], &oid);
|
||||
} else if (!strcmp(argv[1], "get_commit_tree_in_graph")) {
|
||||
struct object_id oid;
|
||||
if (argc < 5)
|
||||
die("not enough arguments");
|
||||
if (parse_oid_hex(argv[4], &oid, &argv[4]))
|
||||
if (parse_oid_hex_any(argv[4], &oid, &argv[4]) == GIT_HASH_UNKNOWN)
|
||||
die("cannot parse oid '%s'", argv[4]);
|
||||
test_get_commit_tree_in_graph(argv[2], argv[3], &oid);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue