aboutsummaryrefslogtreecommitdiffstats
path: root/parse-options-cb.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-05-13 12:24:54 -0700
committerJunio C Hamano <gitster@pobox.com>2024-05-13 12:24:54 -0700
commit17bc3a4767f2de77b9eb4a8a7b7da966ffbe7ec0 (patch)
tree3e91636cac7d4405f77b8722efce98d488671e9c /parse-options-cb.c
parent3e4a232f6e3bd3b7dd920bb07b21cf1c8b4e1a7f (diff)
parentc8aed5e8dadf913e041cde72d704aa91f378b71b (diff)
downloadgit-17bc3a4767f2de77b9eb4a8a7b7da966ffbe7ec0.tar.gz
Merge branch 'ps/undecided-is-not-necessarily-sha1' into jc/undecided-is-not-necessarily-sha1-fix
* 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 'parse-options-cb.c')
-rw-r--r--parse-options-cb.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/parse-options-cb.c b/parse-options-cb.c
index bdc7fae497..d99d688d3c 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -7,6 +7,7 @@
#include "environment.h"
#include "gettext.h"
#include "object-name.h"
+#include "setup.h"
#include "string-list.h"
#include "strvec.h"
#include "oid-array.h"
@@ -29,7 +30,7 @@ int parse_opt_abbrev_cb(const struct option *opt, const char *arg, int unset)
opt->long_name);
if (v && v < MINIMUM_ABBREV)
v = MINIMUM_ABBREV;
- else if (v > the_hash_algo->hexsz)
+ else if (startup_info->have_repository && v > the_hash_algo->hexsz)
v = the_hash_algo->hexsz;
}
*(int *)(opt->value) = v;