Skip to content

Commit a9ecaa0

Browse files
Eric Wonggitster
authored andcommitted
core.abbrev=no disables abbreviations
This allows users to write hash-agnostic scripts and configs by disabling abbreviations. Using "-c core.abbrev=40" will be insufficient with SHA-256, and "-c core.abbrev=64" won't work with SHA-1 repos today. Signed-off-by: Eric Wong <[email protected]> [jc: tweaked implementation, added doc and a test] Signed-off-by: Junio C Hamano <[email protected]>
1 parent e197136 commit a9ecaa0

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

Documentation/config/core.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,4 +625,6 @@ core.abbrev::
625625
computed based on the approximate number of packed objects
626626
in your repository, which hopefully is enough for
627627
abbreviated object names to stay unique for some time.
628+
If set to "no", no abbreviation is made and the object names
629+
are shown in their full length.
628630
The minimum length is 4.

config.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,6 +1217,8 @@ static int git_default_core_config(const char *var, const char *value, void *cb)
12171217
return config_error_nonbool(var);
12181218
if (!strcasecmp(value, "auto"))
12191219
default_abbrev = -1;
1220+
else if (!git_parse_maybe_bool_text(value))
1221+
default_abbrev = the_hash_algo->hexsz;
12201222
else {
12211223
int abbrev = git_config_int(var, value);
12221224
if (abbrev < minimum_abbrev || abbrev > the_hash_algo->hexsz)

t/t3200-branch.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,9 @@ test_expect_success 'git branch --list -v with --abbrev' '
305305
306306
git branch -v --list --no-abbrev t >actual.noabbrev &&
307307
git branch -v --list --abbrev=0 t >actual.0abbrev &&
308+
git -c core.abbrev=no branch -v --list t >actual.noabbrev-conf &&
308309
test_cmp actual.noabbrev actual.0abbrev &&
310+
test_cmp actual.noabbrev actual.noabbrev-conf &&
309311
310312
git branch -v --list --abbrev=36 t >actual.36abbrev &&
311313
# how many hexdigits are used?

0 commit comments

Comments
 (0)