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

Fix "--abbrev=xyz" for revision listing

From
Linus Torvalds <torvalds@osdl.org>
Date
May 27, 2006, 19:24 UTC
Message-ID
<Pine.LNX.4.64.0605271218310.5623@g5.osdl.org>

The revision argument parsing was happily parsing "--abbrev", but it didn't parse "--abbrev=<n>".

Which was hidden by the fact that the diff options _would_ parse --abbrev=<n>, so it would actually silently parse it, it just wouldn't use it for the same things that a plain "--abbrev" was used for.

Which seems a bit insane.

With this patch, if you do "git log --abbrev=10" it will abbreviate the merge parent commit ID's to ten hex characters, which was probably what you expected.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---
diff --git a/revision.c b/revision.c
index 2294b16..42c077a 100644
--- a/revision.c
+++ b/revision.c
@@ -733,6 +733,14 @@ int setup_revisions(int argc, const char
 				revs->abbrev = DEFAULT_ABBREV;
 				continue;
 			}
+			if (!strncmp(arg, "--abbrev=", 9)) {
+				revs->abbrev = strtoul(arg + 9, NULL, 10);
+				if (revs->abbrev < MINIMUM_ABBREV)
+					revs->abbrev = MINIMUM_ABBREV;
+				else if (revs->abbrev > 40)
+					revs->abbrev = 40;
+				continue;
+			}
 			if (!strcmp(arg, "--abbrev-commit")) {
 				revs->abbrev_commit = 1;
 				continue;
Message 1 of 1 in “Fix "--abbrev=xyz" for revision listing”
  1. Linus TorvaldsMay 27, 2006

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.