{"thread":{"id":"25456","subject":"[PATCH] Trim ending whitespaces in exclude file if needed.","startedAt":"2010-10-15T22:41:45Z","lastAt":"2010-10-18T21:54:01Z","messageCount":4,"participants":["Vasyl'","Jonathan Nieder","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"153606","messageId":"AANLkTinUHQzuLJhZnVMKngEO75W=+5sES0WZFAFw5bDw@mail.gmail.com","threadId":"25456","inReplyTo":null,"subject":"[PATCH] Trim ending whitespaces in exclude file if needed.","fromName":"Vasyl'","fromEmail":"vvavrychuk@gmail.com","sentAt":"2010-10-15T22:41:45Z","receivedAt":"2010-10-15T22:41:45Z","isPatch":true,"sender":{"key":"vvavrychuk@gmail.com","avatar":"https://avatars.githubusercontent.com/u/152563?v=4"},"body":"Signed-off-by: Vasyl' Vavrychuk <vvavrychuk@gmail.com>\n---\n\nHope this can save someone's time debugging git.\n\n dir.c |    8 ++++++++\n 1 files changed, 8 insertions(+), 0 deletions(-)\n\ndiff --git a/dir.c b/dir.c\nindex d1e5e5e..704914b 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -171,7 +171,15 @@ void add_exclude(const char *string, const char *base,\n \t\tto_exclude = 0;\n \t\tstring++;\n \t}\n+\n \tlen = strlen(string);\n+\tif (len && isspace((unsigned char)string[len - 1])) {\n+\t\tstruct strbuf trim_buf = STRBUF_INIT;\n+\t\tstrbuf_add(&trim_buf, string, len);\n+\t\tstrbuf_rtrim(&trim_buf);\n+\t\tstring = strbuf_detach(&trim_buf, &len);\n+\t}\n+\n \tif (len && string[len - 1] == '/') {\n \t\tchar *s;\n \t\tx = xmalloc(sizeof(*x) + len);\n-- \n1.7.3.1.msysgit.0\n"},{"id":"153651","messageId":"20101017024133.GF26656@burratino","threadId":"25456","inReplyTo":"AANLkTinUHQzuLJhZnVMKngEO75W=+5sES0WZFAFw5bDw@mail.gmail.com","subject":"Re: [PATCH] Trim ending whitespaces in exclude file if needed.","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-10-17T02:41:33Z","receivedAt":"2010-10-17T02:41:33Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"(+cc: msysgit)\n\nVasyl' wrote:\n\n> Hope this can save someone's time debugging git.\n\nIt sounds like there's a story behind this one.  Could you tell it?\nThat would help future readers of this code to easily determine\nwhy they shouldn't break it.\n\n> --- a/dir.c\n> +++ b/dir.c\n> @@ -171,7 +171,15 @@ void add_exclude(const char *string, const char *base,\n>  \t\tto_exclude = 0;\n>  \t\tstring++;\n>  \t}\n> +\n\nWhy?\n\n>  \tlen = strlen(string);\n> +\tif (len && isspace((unsigned char)string[len - 1])) {\n\nThis cast is not needed (see git-compat-util.h).\n\n> +\t\tstruct strbuf trim_buf = STRBUF_INIT;\n> +\t\tstrbuf_add(&trim_buf, string, len);\n> +\t\tstrbuf_rtrim(&trim_buf);\n\nMissing free(string)?\n\n> +\t\tstring = strbuf_detach(&trim_buf, &len);\n> +\t}\n> +\n>  \tif (len && string[len - 1] == '/') {\n\nThanks for a clear and pleasant read.\nJonathan\n"},{"id":"153662","messageId":"AANLkTimrgGYXDtN_ukWuCpjGTibrMNLQvfpq8fe=VxS_@mail.gmail.com","threadId":"25456","inReplyTo":"20101017024133.GF26656@burratino","subject":"Re: [PATCH] Trim ending whitespaces in exclude file if needed.","fromName":"Vasyl'","fromEmail":"vvavrychuk@gmail.com","sentAt":"2010-10-17T09:29:06Z","receivedAt":"2010-10-17T09:29:06Z","isPatch":true,"sender":{"key":"vvavrychuk@gmail.com","avatar":"https://avatars.githubusercontent.com/u/152563?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> wrote:\n\n> (+cc: msysgit)\n>\n> Vasyl' wrote:\n>\n> > Hope this can save someone's time debugging git.\n>\n> It sounds like there's a story behind this one.  Could you tell it?\n> That would help future readers of this code to easily determine\n> why they shouldn't break it.\n>\nI modify either .git/info/exclude or .gitignore by copy-pasting `git\nstatus`. But unfortunetly this adds spacing to ends of lines and ignoring\ndoes not work...\n\n>\n> > --- a/dir.c\n> > +++ b/dir.c\n> > @@ -171,7 +171,15 @@ void add_exclude(const char *string, const char\n> *base,\n> >               to_exclude = 0;\n> >               string++;\n> >       }\n> > +\n>\n> Why?\n>\n> >       len = strlen(string);\n> > +     if (len && isspace((unsigned char)string[len - 1])) {\n>\n> This cast is not needed (see git-compat-util.h).\n>\n> > +             struct strbuf trim_buf = STRBUF_INIT;\n> > +             strbuf_add(&trim_buf, string, len);\n> > +             strbuf_rtrim(&trim_buf);\n>\n> Missing free(string)?\n>\nI have misunderstood in the first iteration memory managment in the\nadd_exclude's function code\n struct exclude *x;\nchar *s;\nx = xmalloc(sizeof(*x) + len);\ns = (char *)(x+1);\nmemcpy(s, string, len - 1);\ns[len - 1] = '\\0';\nstring = s;\nAnd fix of my patch needs more change and testing. I will do this later.\n\n>\n> > +             string = strbuf_detach(&trim_buf, &len);\n> > +     }\n> > +\n> >       if (len && string[len - 1] == '/') {\n>\n> Thanks for a clear and pleasant read.\n>\nThanks for review.\n\n> Jonathan\n>\n"},{"id":"153751","messageId":"7v39s3416u.fsf@alter.siamese.dyndns.org","threadId":"25456","inReplyTo":"AANLkTimrgGYXDtN_ukWuCpjGTibrMNLQvfpq8fe=VxS_@mail.gmail.com","subject":"Re: [PATCH] Trim ending whitespaces in exclude file if needed.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-10-18T21:54:01Z","receivedAt":"2010-10-18T21:54:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Vasyl'\" <vvavrychuk@gmail.com> writes:\n\n>> It sounds like there's a story behind this one.  Could you tell it?\n>> That would help future readers of this code to easily determine\n>> why they shouldn't break it.\n>>\n> I modify either .git/info/exclude or .gitignore by copy-pasting `git\n> status`. But unfortunetly this adds spacing to ends of lines and ignoring\n> does not work...\n\nThat makes it sound as if you would need a patch to fix your editor or\nwhatever you are using for copy/paste, rather than git, no?\n\nI do not personally have need to ignore paths whose names end with\nwhitespaces, and I do not think anybody with such a need is sane, so in\nthat sense your patch would be less harmful than the purist in me finds\nissues in it ;-)\n\nBut it changes the documented behaviour that requires documentation\nupdates, yes?\n"}]}