{"thread":{"id":"43343","subject":"Re: [PATCH] remove \"[PATCH]\" prefix from shortlog output","startedAt":"2006-12-10T00:58:32Z","lastAt":"2006-12-11T03:17:57Z","messageCount":7,"participants":["Johannes Schindelin","Jakub Narebski","Junio C Hamano","Nicolas Pitre"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"298719","messageId":"Pine.LNX.4.64.0612091954010.2630@xanadu.home","threadId":"43343","inReplyTo":null,"subject":"[PATCH] remove \"[PATCH]\" prefix from shortlog output","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2006-12-10T00:58:32Z","receivedAt":"2006-12-10T00:58:32Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"This doesn't convey much information in the shortlog context.\nAnd the perl version did strip it as well.\n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n\n---\n\ndiff --git a/builtin-shortlog.c b/builtin-shortlog.c\nindex 7a2ddfe..6c4606b 100644\n--- a/builtin-shortlog.c\n+++ b/builtin-shortlog.c\n@@ -146,6 +146,11 @@ static void insert_author_oneline(struct path_list *list,\n \twhile (onelinelen > 0 && isspace(oneline[onelinelen - 1]))\n \t\tonelinelen--;\n \n+\tif (onelinelen > 8 && !strncasecmp(oneline, \"[PATCH] \", 8)) {\n+\t\toneline += 8;\n+\t\tonelinelen -= 8;\n+\t}\n+\n \tbuffer = xmalloc(onelinelen + 1);\n \tmemcpy(buffer, oneline, onelinelen);\n"},{"id":"296510","messageId":"Pine.LNX.4.63.0612102337090.28348@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"43343","inReplyTo":"Pine.LNX.4.64.0612091954010.2630@xanadu.home","subject":"Re: [PATCH] remove \"[PATCH]\" prefix from shortlog output","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-12-10T22:40:56Z","receivedAt":"2006-12-10T22:40:56Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 9 Dec 2006, Nicolas Pitre wrote:\n\n> This doesn't convey much information in the shortlog context.\n> And the perl version did strip it as well.\n\nFrom the current builtin-shortlog.c:128ff:\n\n        if (!strncmp(oneline, \"[PATCH\", 6)) {\n                char *eob = strchr(oneline, ']');\n\n                if (eob) {\n                        while (isspace(eob[1]) && eob[1] != '\\n')\n                                eob++;\n                        if (eob - oneline < onelinelen) {\n                                onelinelen -= eob - oneline;\n                                oneline = eob;\n                        }\n                }\n        }\n\nIt tries not only to strip \"[PATCH]\", but also \"[PATCH 0/n]\" and basically \nevery prefix beginning with \"[PATCH\" and ending in \"]\". I do not remember \nif I really tested that code, but it should work.\n\nCiao,\nDscho\n"},{"id":"294819","messageId":"eli3vr$j6v$1@sea.gmane.org","threadId":"43343","inReplyTo":"Pine.LNX.4.63.0612102337090.28348@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] remove \"[PATCH]\" prefix from shortlog output","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-12-10T23:10:02Z","receivedAt":"2006-12-10T23:10:02Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Johannes Schindelin wrote:\n\n> On Sat, 9 Dec 2006, Nicolas Pitre wrote:\n> \n>> This doesn't convey much information in the shortlog context.\n>> And the perl version did strip it as well.\n> \n> From the current builtin-shortlog.c:128ff:\n> \n>         if (!strncmp(oneline, \"[PATCH\", 6)) {\n>                 char *eob = strchr(oneline, ']');\n> \n>                 if (eob) {\n>                         while (isspace(eob[1]) && eob[1] != '\\n')\n>                                 eob++;\n>                         if (eob - oneline < onelinelen) {\n>                                 onelinelen -= eob - oneline;\n>                                 oneline = eob;\n>                         }\n>                 }\n>         }\n> \n> It tries not only to strip \"[PATCH]\", but also \"[PATCH 0/n]\" and basically \n> every prefix beginning with \"[PATCH\" and ending in \"]\". I do not remember \n> if I really tested that code, but it should work.\n\nWhat happens if you have \"[PATCH\" without closing \"]\"? Does it work (and\ndoesn't crash)? Does it strip anything?\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n\n"},{"id":"298279","messageId":"7vac1v2uom.fsf@assigned-by-dhcp.cox.net","threadId":"43343","inReplyTo":"Pine.LNX.4.63.0612102337090.28348@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] remove \"[PATCH]\" prefix from shortlog output","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-10T23:32:57Z","receivedAt":"2006-12-10T23:32:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> It tries not only to strip \"[PATCH]\", but also \"[PATCH 0/n]\" and basically \n> every prefix beginning with \"[PATCH\" and ending in \"]\". I do not remember \n> if I really tested that code, but it should work.\n\nThe problem is that you forgot that the lines are indented when\nacting as a filter.\n\nHow about this?  It also contains the extra whitespace removal\nfrom the author name.\n\ndiff --git a/builtin-shortlog.c b/builtin-shortlog.c\nindex 7a2ddfe..3fc43dd 100644\n--- a/builtin-shortlog.c\n+++ b/builtin-shortlog.c\n@@ -188,18 +188,25 @@ static void read_from_stdin(struct path_list *list)\n \t\t\t\tbob = buffer + strlen(buffer);\n \t\t\telse {\n \t\t\t\toffset = 8;\n-\t\t\t\tif (isspace(bob[-1]))\n+\t\t\t\twhile (buffer + offset < bob &&\n+\t\t\t\t       isspace(bob[-1]))\n \t\t\t\t\tbob--;\n \t\t\t}\n \n \t\t\twhile (fgets(buffer2, sizeof(buffer2), stdin) &&\n \t\t\t\t\tbuffer2[0] != '\\n')\n \t\t\t\t; /* chomp input */\n-\t\t\tif (fgets(buffer2, sizeof(buffer2), stdin))\n+\t\t\tif (fgets(buffer2, sizeof(buffer2), stdin)) {\n+\t\t\t\tint l2 = strlen(buffer2);\n+\t\t\t\tint i;\n+\t\t\t\tfor (i = 0; i < l2; i++)\n+\t\t\t\t\tif (!isspace(buffer2[i]))\n+\t\t\t\t\t\tbreak;\n \t\t\t\tinsert_author_oneline(list,\n \t\t\t\t\t\tbuffer + offset,\n \t\t\t\t\t\tbob - buffer - offset,\n-\t\t\t\t\t\tbuffer2, strlen(buffer2));\n+\t\t\t\t\t\tbuffer2 + i, l2 - i);\n+\t\t\t}\n \t\t}\n \t}\n }\n"},{"id":"294416","messageId":"Pine.LNX.4.63.0612110031480.1348@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"43343","inReplyTo":"eli3vr$j6v$1@sea.gmane.org","subject":"Re: [PATCH] remove \"[PATCH]\" prefix from shortlog output","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-12-10T23:35:32Z","receivedAt":"2006-12-10T23:35:32Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 11 Dec 2006, Jakub Narebski wrote:\n\n> Johannes Schindelin wrote:\n> \n> > On Sat, 9 Dec 2006, Nicolas Pitre wrote:\n> > \n> >> This doesn't convey much information in the shortlog context.\n> >> And the perl version did strip it as well.\n> > \n> > From the current builtin-shortlog.c:128ff:\n> > \n> >         if (!strncmp(oneline, \"[PATCH\", 6)) {\n> >                 char *eob = strchr(oneline, ']');\n> > \n> >                 if (eob) {\n> >                         while (isspace(eob[1]) && eob[1] != '\\n')\n> >                                 eob++;\n> >                         if (eob - oneline < onelinelen) {\n> >                                 onelinelen -= eob - oneline;\n> >                                 oneline = eob;\n> >                         }\n> >                 }\n> >         }\n> > \n> > It tries not only to strip \"[PATCH]\", but also \"[PATCH 0/n]\" and basically \n> > every prefix beginning with \"[PATCH\" and ending in \"]\". I do not remember \n> > if I really tested that code, but it should work.\n> \n> What happens if you have \"[PATCH\" without closing \"]\"? Does it work (and\n> doesn't crash)? Does it strip anything?\n\nUse the source, Luke!\n\nIf \"[PATCH\" is there, but \"]\" is not, then eob will be NULL, and nothing \nhappens.\n\nWell, actually it is not completely true: the code searches for \"]\" in the \n_complete_ commit message (which _is_ terminated by '\\0'). But only if it \nis found, _and_ it is in the first line, the substring is trimmed away.\n\nHth,\nDscho\n"},{"id":"298668","messageId":"Pine.LNX.4.63.0612110040260.1471@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"43343","inReplyTo":"7vac1v2uom.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] remove \"[PATCH]\" prefix from shortlog output","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-12-10T23:41:34Z","receivedAt":"2006-12-10T23:41:34Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 10 Dec 2006, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > It tries not only to strip \"[PATCH]\", but also \"[PATCH 0/n]\" and basically \n> > every prefix beginning with \"[PATCH\" and ending in \"]\". I do not remember \n> > if I really tested that code, but it should work.\n> \n> The problem is that you forgot that the lines are indented when\n> acting as a filter.\n\nOf course!\n\nAnd your patch looks correct to me.\nCiao,\n"},{"id":"298501","messageId":"Pine.LNX.4.64.0612102147460.2630@xanadu.home","threadId":"43343","inReplyTo":"Pine.LNX.4.63.0612110040260.1471@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] remove \"[PATCH]\" prefix from shortlog output","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2006-12-11T03:17:57Z","receivedAt":"2006-12-11T03:17:57Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Mon, 11 Dec 2006, Johannes Schindelin wrote:\n\n> Hi,\n> \n> On Sun, 10 Dec 2006, Junio C Hamano wrote:\n> \n> > Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> > \n> > > It tries not only to strip \"[PATCH]\", but also \"[PATCH 0/n]\" and basically \n> > > every prefix beginning with \"[PATCH\" and ending in \"]\". I do not remember \n> > > if I really tested that code, but it should work.\n\nHmmm well, right.  And of course I failed to notice that code was there.\n\nI think I was corrupted by the dark side and failed to properly \"use the \nsource\" twice on that tool this week.\n\n> > The problem is that you forgot that the lines are indented when\n> > acting as a filter.\n\nWhich was indeed my use case.\n\n> Of course!\n> \n> And your patch looks correct to me.\n\nConfirmed.\n\n\n"}]}