diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-05-07 06:53:44 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-05-07 07:50:50 +0200 |
commit | c8aed5e8dadf913e041cde72d704aa91f378b71b (patch) | |
tree | e041b723c3f0ef2237b8322fcf4731b090958334 /gettext.h | |
parent | oss-fuzz/commit-graph: set up hash algorithm (diff) | |
download | git-c8aed5e8dadf913e041cde72d704aa91f378b71b.tar.xz git-c8aed5e8dadf913e041cde72d704aa91f378b71b.zip |
repository: stop setting SHA1 as the default object hash
During the startup of Git, we call `initialize_the_repository()` to set
up `the_repository` as well as `the_index`. Part of this setup is also
to set the default object hash of the repository to SHA1. This has the
effect that `the_hash_algo` is getting initialized to SHA1, as well.
This default hash algorithm eventually gets overridden by most Git
commands via `setup_git_directory()`, which also detects the actual hash
algorithm used by the repository.
There are some commands though that don't access a repository at all, or
at a later point only, and thus retain the default hash function for
some amount of time. As some of the the preceding commits demonstrate,
this can lead to subtle issues when we access `the_hash_algo` when no
repository has been set up.
Address this issue by dropping the set up of the default hash algorithm
completely. The effect of this is that `the_hash_algo` will map to a
`NULL` pointer and thus cause Git to crash when something tries to
access the hash algorithm without it being properly initialized. It thus
forces all Git commands to explicitly set up the hash algorithm in case
there is no repository.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'gettext.h')
0 files changed, 0 insertions, 0 deletions