{"thread":{"id":"4312","subject":"Fix \"--abbrev=xyz\" for revision listing","startedAt":"2006-05-27T19:24:30Z","lastAt":"2006-05-27T19:24:30Z","messageCount":1,"participants":["Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"20812","messageId":"Pine.LNX.4.64.0605271218310.5623@g5.osdl.org","threadId":"4312","inReplyTo":null,"subject":"Fix \"--abbrev=xyz\" for revision listing","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-05-27T19:24:30Z","receivedAt":"2006-05-27T19:24:30Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\nThe revision argument parsing was happily parsing \"--abbrev\", but it \ndidn't parse \"--abbrev=<n>\".\n\nWhich was hidden by the fact that the diff options _would_ parse \n--abbrev=<n>, so it would actually silently parse it, it just \nwouldn't use it for the same things that a plain \"--abbrev\" was \nused for.\n\nWhich seems a bit insane.\n\nWith this patch, if you do \"git log --abbrev=10\" it will abbreviate the \nmerge parent commit ID's to ten hex characters, which was probably what \nyou expected.\n\nSigned-off-by: Linus Torvalds <torvalds@osdl.org>\n---\ndiff --git a/revision.c b/revision.c\nindex 2294b16..42c077a 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -733,6 +733,14 @@ int setup_revisions(int argc, const char\n \t\t\t\trevs->abbrev = DEFAULT_ABBREV;\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strncmp(arg, \"--abbrev=\", 9)) {\n+\t\t\t\trevs->abbrev = strtoul(arg + 9, NULL, 10);\n+\t\t\t\tif (revs->abbrev < MINIMUM_ABBREV)\n+\t\t\t\t\trevs->abbrev = MINIMUM_ABBREV;\n+\t\t\t\telse if (revs->abbrev > 40)\n+\t\t\t\t\trevs->abbrev = 40;\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tif (!strcmp(arg, \"--abbrev-commit\")) {\n \t\t\t\trevs->abbrev_commit = 1;\n \t\t\t\tcontinue;\n"}]}