[PATCH v5 0/2] show-index: fix uninitialized hash function
From: Abhijeet Sonar <hidden>
Date: 2024-11-04 19:30:28
In this iteration, I have fixed some typos along with a stylistisc issue
that were noted in v4.
I have also added an additional patch that adds a test for --object-format
option in show-index as it was noted we don't already have any.
Abhijeet Sonar (2):
show-index: fix uninitialized hash function
t5300: add test for 'show-index --object-format'
builtin/show-index.c | 9 +++++++++
t/t5300-pack-object.sh | 26 ++++++++++++++++++++++++++
2 files changed, 35 insertions(+)
Range-diff against v4:
1: c75175ad9b ! 1: 05ee1e2ea5 show-index: fix uninitialized hash function
@@ Commit message
In c8aed5e8da (repository: stop setting SHA1 as the default object
hash), we got rid of the default hash algorithm for the_repository.
Due to this change, it is now the responsibility of the callers to set
- thier own default when this is not present.
+ their own default when this is not present.
As stated in the docs, show-index should use SHA1 as the default hash
- algorithm when ran outsize of a repository. Make sure this promise is
+ algorithm when run outside a repository. Make sure this promise is
met by falling back to SHA1 when the_hash_algo is not present (i.e.
- when the command is ran outside of a repository). Also add a test that
- verifies this behaviour.
+ when the command is run outside a repository). Also add a test that
+ verifies this behavior.
Signed-off-by: Abhijeet Sonar [off-list ref]
@@ builtin/show-index.c: 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.
++ /*
++ * 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);
+
@@ builtin/show-index.c: int cmd_show_index(int argc,
if (fread(top_index, 2 * 4, 1, stdin) != 1)
- ## rm (new) ##
-@@
-+#!/bin/sh
-+
-+echo rm $@
-
## t/t5300-pack-object.sh ##
@@ t/t5300-pack-object.sh: test_expect_success 'index-pack --strict <pack> works in non-repo' '
test_path_is_file foo.idx
-: ---------- > 2: c8a28aae55 t5300: add test for 'show-index --object-format'
--
2.47.0.107.g34b6ce9b30