Merge branch 'ps/undecided-is-not-necessarily-sha1'
Before discovering the repository details, We used to assume SHA-1 as the "default" hash function, which has been corrected. Hopefully this will smoke out codepaths that rely on such an unwarranted assumptions. * ps/undecided-is-not-necessarily-sha1: repository: stop setting SHA1 as the default object hash oss-fuzz/commit-graph: set up hash algorithm builtin/shortlog: don't set up revisions without repo builtin/diff: explicitly set hash algo when there is no repo builtin/bundle: abort "verify" early when there is no repository builtin/blame: don't access potentially unitialized `the_hash_algo` builtin/rev-parse: allow shortening to more than 40 hex characters remote-curl: fix parsing of detached SHA256 heads attr: fix BUG() when parsing attrs outside of repo attr: don't recompute default attribute source parse-options-cb: only abbreviate hashes when hash algo is known path: move `validate_headref()` to its only user path: harden validation of HEAD with non-standard hashes
This commit is contained in:
20
repository.c
20
repository.c
@ -26,26 +26,6 @@ void initialize_repository(struct repository *repo)
|
||||
repo->parsed_objects = parsed_object_pool_new();
|
||||
ALLOC_ARRAY(repo->index, 1);
|
||||
index_state_init(repo->index, repo);
|
||||
|
||||
/*
|
||||
* Unfortunately, we need to keep this hack around for the time being:
|
||||
*
|
||||
* - Not setting up the hash algorithm for `the_repository` leads to
|
||||
* crashes because `the_hash_algo` is a macro that expands to
|
||||
* `the_repository->hash_algo`. So if Git commands try to access
|
||||
* `the_hash_algo` without a Git directory we crash.
|
||||
*
|
||||
* - Setting up the hash algorithm to be SHA1 by default breaks other
|
||||
* commands when running with SHA256.
|
||||
*
|
||||
* This is another point in case why having global state is a bad idea.
|
||||
* Eventually, we should remove this hack and stop setting the hash
|
||||
* algorithm in this function altogether. Instead, it should only ever
|
||||
* be set via our repository setup procedures. But that requires more
|
||||
* work.
|
||||
*/
|
||||
if (repo == the_repository)
|
||||
repo_set_hash_algo(repo, GIT_HASH_SHA1);
|
||||
}
|
||||
|
||||
static void expand_base_dir(char **out, const char *in,
|
||||
|
Reference in New Issue
Block a user