summaryrefslogtreecommitdiff
path: root/t/helper
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2020-02-22 20:17:36 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-02-24 17:33:27 (GMT)
commitbf154a878281b6a971ece0fb6d917938298be60d (patch)
tree37bdeed2ca5d55540cc6fccb4ef1013fa95805b5 /t/helper
parent8dca7f30e4e5da31b375ecaeeac995305c9c0c5c (diff)
downloadgit-bf154a878281b6a971ece0fb6d917938298be60d.zip
git-bf154a878281b6a971ece0fb6d917938298be60d.tar.gz
git-bf154a878281b6a971ece0fb6d917938298be60d.tar.bz2
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>
Diffstat (limited to 't/helper')
-rw-r--r--t/helper/test-repository.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/t/helper/test-repository.c b/t/helper/test-repository.c
index ecc768e..56f0e3c 100644
--- a/t/helper/test-repository.c
+++ b/t/helper/test-repository.c
@@ -19,12 +19,11 @@ static void test_parse_commit_in_graph(const char *gitdir, const char *worktree,
memset(the_repository, 0, sizeof(*the_repository));
- /* TODO: Needed for temporary hack in hashcmp, see 183a638b7da. */
- repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
-
if (repo_init(&r, gitdir, worktree))
die("Couldn't init repo");
+ repo_set_hash_algo(the_repository, hash_algo_by_ptr(r.hash_algo));
+
c = lookup_commit(&r, commit_oid);
if (!parse_commit_in_graph(&r, c))
@@ -50,12 +49,11 @@ static void test_get_commit_tree_in_graph(const char *gitdir,
memset(the_repository, 0, sizeof(*the_repository));
- /* TODO: Needed for temporary hack in hashcmp, see 183a638b7da. */
- repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
-
if (repo_init(&r, gitdir, worktree))
die("Couldn't init repo");
+ repo_set_hash_algo(the_repository, hash_algo_by_ptr(r.hash_algo));
+
c = lookup_commit(&r, commit_oid);
/*