@matheusbsbs / matheus-bagliano / commits / bf154a8782
Fork 0

t/helper: make repository tests hash independent

This test currently hard-codes the hash algorithm as SHA-1 when calling repo_set_hash_algo so that the_hash_algo is properly initialized. However, this does not work with SHA-256 repositories. Read the repository value that repo_init has read into the local repository variable and set the algorithm based on that value. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Feb 22, 2020 at 20:17 UTC bf154a878281b6a971ece0fb6d917938298be60d
1 file changed +4 -6
t/helper/test-repository.c
+4 -6
@@ -19,12 +19,11 @@ static void test_parse_commit_in_graph(const char *gitdir, const char *worktree,
19
20 memset(the_repository, 0, sizeof(*the_repository));
21
22 - /* TODO: Needed for temporary hack in hashcmp, see 183a638b7da. */
23 - repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
24 -
22 if (repo_init(&r, gitdir, worktree))
23 die("Couldn't init repo");
24
25 + repo_set_hash_algo(the_repository, hash_algo_by_ptr(r.hash_algo));
26 +
27 c = lookup_commit(&r, commit_oid);
28
29 if (!parse_commit_in_graph(&r, c))
@@ -50,12 +49,11 @@ static void test_get_commit_tree_in_graph(const char *gitdir,
49
50 memset(the_repository, 0, sizeof(*the_repository));
51
53 - /* TODO: Needed for temporary hack in hashcmp, see 183a638b7da. */
54 - repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
55 -
52 if (repo_init(&r, gitdir, worktree))
53 die("Couldn't init repo");
54
55 + repo_set_hash_algo(the_repository, hash_algo_by_ptr(r.hash_algo));
56 +
57 c = lookup_commit(&r, commit_oid);
58
59 /*