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
This commit is contained in:
Junio C Hamano
2024-12-23 09:32:12 -08:00
2 changed files with 27 additions and 0 deletions

View File

@ -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)