git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/3] abbrev: auto size the default abbreviation

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 2, 2016, 01:33 UTC
Message-ID
<xmqqmvhimzrh.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20161003222701.za5njew33rqc5b6g@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 11 quoted lines
> On Fri, Sep 30, 2016 at 05:19:37PM -0700, Junio C Hamano wrote:
>
>> Introduce a mechanism, where we estimate the number of objects in
>> the repository upon the first request to abbreviate an object name
>> with the default setting and come up with a sane default for the
>> repository.  Based on the expectation that we would see collision in
>> a repository with 2^(2N) objects when using object names shortened
>> to first N bits, use sufficient number of hexdigits to cover the
>> number of objects in the repository.  Each hexdigit (4-bits) we add
>> to the shortened name allows us to have four times (2-bits) as many
>> objects in the repository.

I was idly browsing the draft release notes and then documentation and noticed that, even though the new default is to auto-scale, there is no mention of that in the documentation and there is no way to explicitly ask for auto-scaling.

I wonder if we want to have something like this. I actually am inclined to drop the change to config.c and remove the new mention of "auto" in the documentation.

 Documentation/config.txt |  9 +++++----
 config.c                 | 14 ++++++++++----
 2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index a0ab66aae7..b02f8a4025 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -783,10 +783,11 @@ core.sparseCheckout::
 	linkgit:git-read-tree[1] for more information.
 
 core.abbrev::
-	Set the length object names are abbreviated to.  If unspecified,
-	many commands abbreviate to 7 hexdigits, which may not be enough
-	for abbreviated object names to stay unique for sufficiently long
-	time.
+	Set the length object names are abbreviated to.  If
+	unspecified or set to "auto", an appropriate value is
+	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.
 
 add.ignoreErrors::
 add.ignore-errors (deprecated)::
diff --git a/config.c b/config.c
index 83fdecb1bc..c363cca4a9 100644
--- a/config.c
+++ b/config.c
@@ -834,10 +834,16 @@ static int git_default_core_config(const char *var, const char *value)
 	}
 
 	if (!strcmp(var, "core.abbrev")) {
-		int abbrev = git_config_int(var, value);
-		if (abbrev < minimum_abbrev || abbrev > 40)
-			return -1;
-		default_abbrev = abbrev;
+		if (!value)
+			return config_error_nonbool(var);
+		if (!strcasecmp(value, "auto"))
+			default_abbrev = -1;
+		else {
+			int abbrev = git_config_int(var, value);
+			if (abbrev < minimum_abbrev || abbrev > 40)
+				return -1;
+			default_abbrev = abbrev;
+		}
 		return 0;
 	}
 
Previous: Jeff KingNext: Jeff King
Message 12 of 13 in “auto-sizing default abbreviation length”
  1. 0/3 auto-sizing default abbreviation lengthJunio C Hamano, Oct 1, 2016
  2. 1/3 abbrev: add FALLBACK_DEFAULT_ABBREV to prepare for auto sizingJunio C Hamano, Oct 1, 2016
  3. 2/3 abbrev: prepare for new world orderJunio C Hamano, Oct 1, 2016
  4. 3/3 abbrev: auto size the default abbreviationJunio C Hamano, Oct 1, 2016
  5. Jeff KingOct 3, 2016
  6. Linus TorvaldsOct 3, 2016
  7. Jeff KingOct 3, 2016
  8. Junio C HamanoOct 3, 2016
  9. Jeff KingOct 3, 2016
  10. Junio C HamanoOct 4, 2016
  11. Jeff KingOct 4, 2016
  12. Junio C HamanoNov 2, 2016
  13. Jeff KingNov 2, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.