]> git.ipfire.org Git - thirdparty/git.git/commitdiff
core.abbrev=no disables abbreviations
authorEric Wong <e@80x24.org>
Tue, 1 Sep 2020 07:43:55 +0000 (07:43 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Dec 2020 21:40:09 +0000 (13:40 -0800)
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 <e@80x24.org>
[jc: tweaked implementation, added doc and a test]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config/core.txt
config.c
t/t3200-branch.sh

index 74619a9c03bb17d0f6c007fc3f9b8c052b957c65..15da9a4ed41a13266fa9da26e3d2bf4958a4d046 100644 (file)
@@ -625,4 +625,6 @@ core.abbrev::
        computed based on the approximate number of packed objects
        in your repository, which hopefully is enough for
        abbreviated object names to stay unique for some time.
+       If set to "no", no abbreviation is made and the object names
+       are shown in their full length.
        The minimum length is 4.
index 2bdff4457be7d5b1e1fd5f6acb558ac41b946a8c..4cb8c14a9bafce5d3405acb4e35fb204bedaef7a 100644 (file)
--- a/config.c
+++ b/config.c
@@ -1217,6 +1217,8 @@ static int git_default_core_config(const char *var, const char *value, void *cb)
                        return config_error_nonbool(var);
                if (!strcasecmp(value, "auto"))
                        default_abbrev = -1;
+               else if (!git_parse_maybe_bool_text(value))
+                       default_abbrev = the_hash_algo->hexsz;
                else {
                        int abbrev = git_config_int(var, value);
                        if (abbrev < minimum_abbrev || abbrev > the_hash_algo->hexsz)
index 4c0734157ba0b88432ec583321bdb2143f0c4461..d9ed1f7c94c098fbf3401a1c44d4ca759fa88621 100755 (executable)
@@ -305,7 +305,9 @@ test_expect_success 'git branch --list -v with --abbrev' '
 
        git branch -v --list --no-abbrev t >actual.noabbrev &&
        git branch -v --list --abbrev=0 t >actual.0abbrev &&
+       git -c core.abbrev=no branch -v --list t >actual.noabbrev-conf &&
        test_cmp actual.noabbrev actual.0abbrev &&
+       test_cmp actual.noabbrev actual.noabbrev-conf &&
 
        git branch -v --list --abbrev=36 t >actual.36abbrev &&
        # how many hexdigits are used?