mirror of
https://github.com/git/git
synced 2024-10-01 06:05:20 +00:00
Merge branch 'ps/abbrev-length-before-setup-fix'
Setting core.abbrev too early before the repository set-up (typically in "git clone") caused segfault, which as been corrected. * ps/abbrev-length-before-setup-fix: object-name: don't try to abbreviate to lengths greater than hexsz parse-options-cb: stop clamping "--abbrev=" to hash length config: fix segfault when parsing "core.abbrev" without repo
This commit is contained in:
commit
4401639f96
4
config.c
4
config.c
|
@ -1460,10 +1460,10 @@ static int git_default_core_config(const char *var, const char *value,
|
|||
if (!strcasecmp(value, "auto"))
|
||||
default_abbrev = -1;
|
||||
else if (!git_parse_maybe_bool_text(value))
|
||||
default_abbrev = the_hash_algo->hexsz;
|
||||
default_abbrev = GIT_MAX_HEXSZ;
|
||||
else {
|
||||
int abbrev = git_config_int(var, value, ctx->kvi);
|
||||
if (abbrev < minimum_abbrev || abbrev > the_hash_algo->hexsz)
|
||||
if (abbrev < minimum_abbrev)
|
||||
return error(_("abbrev length out of range: %d"), abbrev);
|
||||
default_abbrev = abbrev;
|
||||
}
|
||||
|
|
|
@ -837,7 +837,7 @@ int repo_find_unique_abbrev_r(struct repository *r, char *hex,
|
|||
}
|
||||
|
||||
oid_to_hex_r(hex, oid);
|
||||
if (len == hexsz || !len)
|
||||
if (len >= hexsz || !len)
|
||||
return hexsz;
|
||||
|
||||
mad.repo = r;
|
||||
|
|
|
@ -30,8 +30,6 @@ 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 (startup_info->have_repository && v > the_hash_algo->hexsz)
|
||||
v = the_hash_algo->hexsz;
|
||||
}
|
||||
*(int *)(opt->value) = v;
|
||||
return 0;
|
||||
|
|
|
@ -1237,6 +1237,30 @@ test_expect_success 'log.abbrevCommit configuration' '
|
|||
test_cmp expect.whatchanged.full actual
|
||||
'
|
||||
|
||||
test_expect_success '--abbrev-commit with core.abbrev=false' '
|
||||
git log --no-abbrev >expect &&
|
||||
git -c core.abbrev=false log --abbrev-commit >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success '--abbrev-commit with --no-abbrev' '
|
||||
git log --no-abbrev >expect &&
|
||||
git log --abbrev-commit --no-abbrev >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success '--abbrev-commit with core.abbrev=9000' '
|
||||
git log --no-abbrev >expect &&
|
||||
git -c core.abbrev=9000 log --abbrev-commit >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success '--abbrev-commit with --abbrev=9000' '
|
||||
git log --no-abbrev >expect &&
|
||||
git log --abbrev-commit --abbrev=9000 >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'show added path under "--follow -M"' '
|
||||
# This tests for a regression introduced in v1.7.2-rc0~103^2~2
|
||||
test_create_repo regression &&
|
||||
|
|
|
@ -46,6 +46,13 @@ test_expect_success 'output from clone' '
|
|||
test $(grep Clon output | wc -l) = 1
|
||||
'
|
||||
|
||||
test_expect_success 'output from clone with core.abbrev does not crash' '
|
||||
rm -fr dst &&
|
||||
echo "Cloning into ${SQ}dst${SQ}..." >expect &&
|
||||
git -c core.abbrev=12 clone -n "file://$(pwd)/src" dst >actual 2>&1 &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'clone does not keep pack' '
|
||||
|
||||
rm -fr dst &&
|
||||
|
|
Loading…
Reference in a new issue