summaryrefslogtreecommitdiffstats
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-12-23 18:32:12 +0100
committerJunio C Hamano <gitster@pobox.com>2024-12-23 18:32:12 +0100
commit002a8a9d3697866aec32cc9293e4d9b436bb028f (patch)
tree0ed05e99fd451ae595d4eb4c4fd4513db677561f /builtin
parentMerge branch 'ps/build-sign-compare' (diff)
parentt5300: add test for 'show-index --object-format' (diff)
downloadgit-002a8a9d3697866aec32cc9293e4d9b436bb028f.tar.xz
git-002a8a9d3697866aec32cc9293e4d9b436bb028f.zip
Merge branch 'as/show-index-uninitialized-hash'
Regression fix for 'show-index' when run outside of a repository. * as/show-index-uninitialized-hash: t5300: add test for 'show-index --object-format' show-index: fix uninitialized hash function
Diffstat (limited to 'builtin')
-rw-r--r--builtin/show-index.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/builtin/show-index.c b/builtin/show-index.c
index 3152d3c74b..756d632b51 100644
--- a/builtin/show-index.c
+++ b/builtin/show-index.c
@@ -40,6 +40,15 @@ int cmd_show_index(int argc,
repo_set_hash_algo(the_repository, hash_algo);
}
+ /*
+ * Fallback to SHA1 if we are running outside of a repository.
+ *
+ * TODO: Figure out and implement a way to detect the hash algorithm in use by the
+ * the index file passed in and use that instead.
+ */
+ if (!the_hash_algo)
+ repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
+
hashsz = the_hash_algo->rawsz;
if (fread(top_index, 2 * 4, 1, stdin) != 1)