diff --git a/builtin/verify-pack.c b/builtin/verify-pack.c index 011dddd2dc3292..5b663905aea3d9 100644 --- a/builtin/verify-pack.c +++ b/builtin/verify-pack.c @@ -1,6 +1,7 @@ #include "builtin.h" #include "config.h" #include "gettext.h" +#include "hash.h" #include "run-command.h" #include "parse-options.h" #include "strbuf.h" @@ -77,6 +78,9 @@ int cmd_verify_pack(int argc, const char **argv, const char *prefix) OPT_END() }; + if (!the_hash_algo) + repo_set_hash_algo(the_repository, GIT_HASH_SHA1); + git_config(git_default_config, NULL); argc = parse_options(argc, argv, prefix, verify_pack_options, verify_pack_usage, 0); diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh index 4ad023c846d06a..d6f45d89234748 100755 --- a/t/t5300-pack-object.sh +++ b/t/t5300-pack-object.sh @@ -322,6 +322,10 @@ test_expect_success 'verify-pack catches a corrupted sum of the index file itsel fi ' +test_expect_success 'verify-pack outside a repository' ' + nongit git verify-pack -v "$(pwd)/test-1-${packname_1}.idx" +' + test_expect_success 'build pack index for an existing pack' ' cat test-1-${packname_1}.pack >test-3.pack && git index-pack -o tmp.idx test-3.pack &&