diff options
| author | Junio C Hamano <gitster@pobox.com> | 2024-05-30 14:15:10 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-05-30 14:15:11 -0700 |
| commit | a60c21b7206fff1a6ab561e29ac7312c437d2592 (patch) | |
| tree | 0539b0fce049505d99d73b986ed7c459c54ba1e6 /builtin/rev-parse.c | |
| parent | The eighth batch (diff) | |
| parent | repository: stop setting SHA1 as the default object hash (diff) | |
| download | git-a60c21b7206fff1a6ab561e29ac7312c437d2592.tar.gz git-a60c21b7206fff1a6ab561e29ac7312c437d2592.zip | |
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
Diffstat (limited to 'builtin/rev-parse.c')
| -rw-r--r-- | builtin/rev-parse.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index 2db047fff4..1e2919fd81 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -691,7 +691,6 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) const char *name = NULL; struct object_context unused; struct strbuf buf = STRBUF_INIT; - const int hexsz = the_hash_algo->hexsz; int seen_end_of_options = 0; enum format_type format = FORMAT_DEFAULT; @@ -867,8 +866,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) abbrev = strtoul(arg, NULL, 10); if (abbrev < MINIMUM_ABBREV) abbrev = MINIMUM_ABBREV; - else if (hexsz <= abbrev) - abbrev = hexsz; + else if ((int)the_hash_algo->hexsz <= abbrev) + abbrev = the_hash_algo->hexsz; continue; } if (!strcmp(arg, "--sq")) { |
