Skip to content

Commit 59ff92c

Browse files
pks-tgitster
authored andcommitted
parse-options-cb: stop clamping "--abbrev=" to hash length
The `OPT__ABBREV()` option allows the user to specify the length that object hashes shall be abbreviated to. This length needs to be in the range of `(MIN_ABBREV, the_hash_algo->hexsz)`, which is why we clamp the value as required. While this makes sense in the case of `MIN_ABBREV`, it is unnecessary for the upper boundary as the value is eventually passed down to `repo_find_unnique_abbrev_r()`, which handles values larger than the current hash length just fine. In the preceding commit, we have changed parsing of the "core.abbrev" config to stop clamping to the upper boundary. Let's do the same here so that the code becomes simpler, we are consistent with how we treat the "core.abbrev" config and so that we stop depending on `the_repository`. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 524c018 commit 59ff92c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

parse-options-cb.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ int parse_opt_abbrev_cb(const struct option *opt, const char *arg, int unset)
3030
opt->long_name);
3131
if (v && v < MINIMUM_ABBREV)
3232
v = MINIMUM_ABBREV;
33-
else if (startup_info->have_repository && v > the_hash_algo->hexsz)
34-
v = the_hash_algo->hexsz;
3533
}
3634
*(int *)(opt->value) = v;
3735
return 0;

t/t4202-log.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,12 +1243,24 @@ test_expect_success '--abbrev-commit with core.abbrev=false' '
12431243
test_cmp expect actual
12441244
'
12451245

1246+
test_expect_success '--abbrev-commit with --no-abbrev' '
1247+
git log --no-abbrev >expect &&
1248+
git log --abbrev-commit --no-abbrev >actual &&
1249+
test_cmp expect actual
1250+
'
1251+
12461252
test_expect_success '--abbrev-commit with core.abbrev=9000' '
12471253
git log --no-abbrev >expect &&
12481254
git -c core.abbrev=9000 log --abbrev-commit >actual &&
12491255
test_cmp expect actual
12501256
'
12511257

1258+
test_expect_success '--abbrev-commit with --abbrev=9000' '
1259+
git log --no-abbrev >expect &&
1260+
git log --abbrev-commit --abbrev=9000 >actual &&
1261+
test_cmp expect actual
1262+
'
1263+
12521264
test_expect_success 'show added path under "--follow -M"' '
12531265
# This tests for a regression introduced in v1.7.2-rc0~103^2~2
12541266
test_create_repo regression &&

0 commit comments

Comments
 (0)