Skip to content

Commit bf154a8

Browse files
bk2204gitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8dca7f3 commit bf154a8

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

t/helper/test-repository.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ static void test_parse_commit_in_graph(const char *gitdir, const char *worktree,
1919

2020
memset(the_repository, 0, sizeof(*the_repository));
2121

22-
/* TODO: Needed for temporary hack in hashcmp, see 183a638b7da. */
23-
repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
24-
2522
if (repo_init(&r, gitdir, worktree))
2623
die("Couldn't init repo");
2724

25+
repo_set_hash_algo(the_repository, hash_algo_by_ptr(r.hash_algo));
26+
2827
c = lookup_commit(&r, commit_oid);
2928

3029
if (!parse_commit_in_graph(&r, c))
@@ -50,12 +49,11 @@ static void test_get_commit_tree_in_graph(const char *gitdir,
5049

5150
memset(the_repository, 0, sizeof(*the_repository));
5251

53-
/* TODO: Needed for temporary hack in hashcmp, see 183a638b7da. */
54-
repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
55-
5652
if (repo_init(&r, gitdir, worktree))
5753
die("Couldn't init repo");
5854

55+
repo_set_hash_algo(the_repository, hash_algo_by_ptr(r.hash_algo));
56+
5957
c = lookup_commit(&r, commit_oid);
6058

6159
/*

0 commit comments

Comments
 (0)