{"thread":{"id":"3817","subject":"[PATCH] rev-list: honor --abbrev=<n> when doing --pretty=oneline","startedAt":"2006-04-07T00:44:55Z","lastAt":"2006-04-07T03:13:56Z","messageCount":3,"participants":["Eric Wong","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"18439","messageId":"20060407004455.GF15743@hand.yhbt.net","threadId":"3817","inReplyTo":null,"subject":"[PATCH] rev-list: honor --abbrev=<n> when doing --pretty=oneline","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-04-07T00:44:55Z","receivedAt":"2006-04-07T00:44:55Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"This should make --pretty=oneline a whole lot more readable for\npeople using 80-column terminals.\n\nNote that --abbrev=DEFAULT_ABBREV was on by default before, but\nit only affected the printing of the Merge: header).  Let me\nknow if anybody doesn't want the default behavior to change.\nAlso note that --abbrev without arguments is not supported by\nrev-list, but --no-abbrev is supported if you want the old\nbehavior.\n\nOriginally I made abbrev affect the commit sha1 output\nregardless of the pretty setting, but that broke some tests and\nI figured it's most/only useful for --pretty=oneline (at least\nthat's why *I* want it :)\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n\n---\n\n rev-list.c |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\nc4da073e8256499950e25e2c20ea0b3ec4c29b46\ndiff --git a/rev-list.c b/rev-list.c\nindex 22141e2..392209d 100644\n--- a/rev-list.c\n+++ b/rev-list.c\n@@ -52,7 +52,10 @@ static void show_commit(struct commit *c\n \t\tfputs(commit_prefix, stdout);\n \tif (commit->object.flags & BOUNDARY)\n \t\tputchar('-');\n-\tfputs(sha1_to_hex(commit->object.sha1), stdout);\n+\tif (abbrev && commit_format == CMIT_FMT_ONELINE)\n+\t\tfputs(find_unique_abbrev(commit->object.sha1, abbrev), stdout);\n+\telse\n+\t\tfputs(sha1_to_hex(commit->object.sha1), stdout);\n \tif (revs.parents) {\n \t\tstruct commit_list *parents = commit->parents;\n \t\twhile (parents) {\n-- \n1.3.0.rc2.g454a-dirty\n"},{"id":"18440","messageId":"7v64lmuqa5.fsf@assigned-by-dhcp.cox.net","threadId":"3817","inReplyTo":"20060407004455.GF15743@hand.yhbt.net","subject":"Re: [PATCH] rev-list: honor --abbrev=<n> when doing --pretty=oneline","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-04-07T01:29:22Z","receivedAt":"2006-04-07T01:29:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Wong <normalperson@yhbt.net> writes:\n\n> Note that --abbrev=DEFAULT_ABBREV was on by default before, but\n> it only affected the printing of the Merge: header).  Let me\n> know if anybody doesn't want the default behavior to change.\n\nI've never felt need for abbreviating commit object names, so I\nonly had the abbrev variable to determine how the merge parents\nare shown.  If you want to abbreviate the commit object names as\nwell, you _could_ do independent precision for parents and\ncommits, but that would be overkil.  So I'd rather see a switch\nto turn abbreviation for commits on, perhaps like this:\n\n        $ git-rev-list --pretty=oneline --abbrev-commit -n 3 master\n        454a35b Add documentation for git-imap-send.\n        ba3c937 blame.c: fix completely broken ancestry traversal.\n        6cbd5d7 Tweaks to make asciidoc play nice.\n\n        $ git-rev-list --pretty=oneline --abbrev=4 --abbrev-commit -n 3 master\n        454a Add documentation for git-imap-send.\n        ba3c9 blame.c: fix completely broken ancestry traversal.\n        6cbd5 Tweaks to make asciidoc play nice.\n\nOtherwise you might break Porcelains and people's scripts that\nread from --pretty or --header output.\n\n-- >8 --\ndiff --git a/rev-list.c b/rev-list.c\nindex 22141e2..1301502 100644\n--- a/rev-list.c\n+++ b/rev-list.c\n@@ -30,6 +30,7 @@ static const char rev_list_usage[] =\n \"    --unpacked\\n\"\n \"    --header | --pretty\\n\"\n \"    --abbrev=nr | --no-abbrev\\n\"\n+\"    --abbrev-commit\\n\"\n \"  special purpose:\\n\"\n \"    --bisect\"\n ;\n@@ -39,6 +40,7 @@ struct rev_info revs;\n static int bisect_list = 0;\n static int verbose_header = 0;\n static int abbrev = DEFAULT_ABBREV;\n+static int abbrev_commit = 0;\n static int show_timestamp = 0;\n static int hdr_termination = 0;\n static const char *commit_prefix = \"\";\n@@ -52,7 +54,10 @@ static void show_commit(struct commit *c\n \t\tfputs(commit_prefix, stdout);\n \tif (commit->object.flags & BOUNDARY)\n \t\tputchar('-');\n-\tfputs(sha1_to_hex(commit->object.sha1), stdout);\n+\tif (abbrev_commit && abbrev)\n+\t\tfputs(find_unique_abbrev(commit->object.sha1, abbrev), stdout);\n+\telse\n+\t\tfputs(sha1_to_hex(commit->object.sha1), stdout);\n \tif (revs.parents) {\n \t\tstruct commit_list *parents = commit->parents;\n \t\twhile (parents) {\n@@ -317,6 +322,14 @@ int main(int argc, const char **argv)\n \t\t}\n \t\tif (!strcmp(arg, \"--no-abbrev\")) {\n \t\t\tabbrev = 0;\n+\t\t\tcontinue;\n+\t\t}\n+\t\tif (!strcmp(arg, \"--abbrev\")) {\n+\t\t\tabbrev = DEFAULT_ABBREV;\n+\t\t\tcontinue;\n+\t\t}\n+\t\tif (!strcmp(arg, \"--abbrev-commit\")) {\n+\t\t\tabbrev_commit = 1;\n \t\t\tcontinue;\n \t\t}\n \t\tif (!strncmp(arg, \"--abbrev=\", 9)) {\n"},{"id":"18442","messageId":"20060407031356.GA25525@hand.yhbt.net","threadId":"3817","inReplyTo":"7v64lmuqa5.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] rev-list: honor --abbrev=<n> when doing --pretty=oneline","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-04-07T03:13:56Z","receivedAt":"2006-04-07T03:13:56Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> Eric Wong <normalperson@yhbt.net> writes:\n> \n> > Note that --abbrev=DEFAULT_ABBREV was on by default before, but\n> > it only affected the printing of the Merge: header).  Let me\n> > know if anybody doesn't want the default behavior to change.\n> \n> I've never felt need for abbreviating commit object names, so I\n> only had the abbrev variable to determine how the merge parents\n> are shown.  If you want to abbreviate the commit object names as\n> well, you _could_ do independent precision for parents and\n> commits, but that would be overkil.  So I'd rather see a switch\n> to turn abbreviation for commits on, perhaps like this:\n> \n>         $ git-rev-list --pretty=oneline --abbrev-commit -n 3 master\n>         454a35b Add documentation for git-imap-send.\n>         ba3c937 blame.c: fix completely broken ancestry traversal.\n>         6cbd5d7 Tweaks to make asciidoc play nice.\n> \n>         $ git-rev-list --pretty=oneline --abbrev=4 --abbrev-commit -n 3 master\n>         454a Add documentation for git-imap-send.\n>         ba3c9 blame.c: fix completely broken ancestry traversal.\n>         6cbd5 Tweaks to make asciidoc play nice.\n> \n> Otherwise you might break Porcelains and people's scripts that\n> read from --pretty or --header output.\n> \n> -- >8 --\n\nSounds good, I like your patch.  I'm not thrilled with the length of the\n'--abbrev-commit' switch, but I guess that's what aliases are for :>\n\n-- \nEric Wong\n"}]}