{"thread":{"id":"33384","subject":"[PATCH 2/2] diffcore-pickaxe: fill_one() doesn't modify textconv","startedAt":"2013-04-04T16:05:58Z","lastAt":"2013-04-04T17:49:42Z","messageCount":3,"participants":["Simon Ruderich","Matthieu Moy","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"213124","messageId":"20130404160557.GB25232@ruderich.org","threadId":"33384","inReplyTo":"472ae7e08eedfef5886d0ace935654876091447d.1365090893.git.simon@ruderich.org","subject":"[PATCH 2/2] diffcore-pickaxe: fill_one() doesn't modify textconv","fromName":"Simon Ruderich","fromEmail":"simon@ruderich.org","sentAt":"2013-04-04T16:05:58Z","receivedAt":"2013-04-04T16:05:58Z","isPatch":true,"sender":{"key":"simon@ruderich.org","avatar":"https://avatars.githubusercontent.com/u/390994?v=4"},"body":"Signed-off-by: Simon Ruderich <simon@ruderich.org>\n---\n diffcore-pickaxe.c | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c\nindex f814a52..c378ea0 100644\n--- a/diffcore-pickaxe.c\n+++ b/diffcore-pickaxe.c\n@@ -75,10 +75,10 @@ static void diffgrep_consume(void *priv, char *line, unsigned long len)\n }\n \n static void fill_one(struct diff_filespec *one,\n-\t\t     mmfile_t *mf, struct userdiff_driver **textconv)\n+\t\t     mmfile_t *mf, struct userdiff_driver *textconv)\n {\n \tif (DIFF_FILE_VALID(one)) {\n-\t\tmf->size = fill_textconv(*textconv, one, &mf->ptr);\n+\t\tmf->size = fill_textconv(textconv, one, &mf->ptr);\n \t} else {\n \t\tmemset(mf, 0, sizeof(*mf));\n \t}\n@@ -101,8 +101,8 @@ static int diff_grep(struct diff_filepair *p, struct diff_options *o,\n \t\ttextconv_two = get_textconv(p->two);\n \t}\n \n-\tfill_one(p->one, &mf1, &textconv_one);\n-\tfill_one(p->two, &mf2, &textconv_two);\n+\tfill_one(p->one, &mf1, textconv_one);\n+\tfill_one(p->two, &mf2, textconv_two);\n \n \tif (!mf1.ptr) {\n \t\tif (!mf2.ptr)\n@@ -228,8 +228,8 @@ static int has_changes(struct diff_filepair *p, struct diff_options *o,\n \tif (textconv_one == textconv_two && diff_unmodified_pair(p))\n \t\treturn 0;\n \n-\tfill_one(p->one, &mf1, &textconv_one);\n-\tfill_one(p->two, &mf2, &textconv_two);\n+\tfill_one(p->one, &mf1, textconv_one);\n+\tfill_one(p->two, &mf2, textconv_two);\n \n \tif (!mf1.ptr) {\n \t\tif (!mf2.ptr)\n-- \n1.8.2\n\n-- \n+ privacy is necessary\n+ using gnupg http://gnupg.org\n+ public key id: 0x92FEFDB7E44C32F9\n"},{"id":"213134","messageId":"vpqd2uaql8u.fsf@grenoble-inp.fr","threadId":"33384","inReplyTo":"20130404160557.GB25232@ruderich.org","subject":"Re: [PATCH 2/2] diffcore-pickaxe: fill_one() doesn't modify textconv","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-04-04T17:05:53Z","receivedAt":"2013-04-04T17:05:53Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Simon Ruderich <simon@ruderich.org> writes:\n\n> --- a/diffcore-pickaxe.c\n> +++ b/diffcore-pickaxe.c\n> @@ -75,10 +75,10 @@ static void diffgrep_consume(void *priv, char *line, unsigned long len)\n>  }\n>  \n>  static void fill_one(struct diff_filespec *one,\n> -\t\t     mmfile_t *mf, struct userdiff_driver **textconv)\n> +\t\t     mmfile_t *mf, struct userdiff_driver *textconv)\n\nNice, but perhaps you should elaborate a bit more in the commit message\nto say this is a cleanup without real change.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"213138","messageId":"20130404174942.GB13005@sigill.intra.peff.net","threadId":"33384","inReplyTo":"20130404160557.GB25232@ruderich.org","subject":"Re: [PATCH 2/2] diffcore-pickaxe: fill_one() doesn't modify textconv","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-04-04T17:49:42Z","receivedAt":"2013-04-04T17:49:42Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Apr 04, 2013 at 06:05:58PM +0200, Simon Ruderich wrote:\n\n> Signed-off-by: Simon Ruderich <simon@ruderich.org>\n> ---\n>  diffcore-pickaxe.c | 12 ++++++------\n>  1 file changed, 6 insertions(+), 6 deletions(-)\n> \n> diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c\n> index f814a52..c378ea0 100644\n> --- a/diffcore-pickaxe.c\n> +++ b/diffcore-pickaxe.c\n> @@ -75,10 +75,10 @@ static void diffgrep_consume(void *priv, char *line, unsigned long len)\n>  }\n>  \n>  static void fill_one(struct diff_filespec *one,\n> -\t\t     mmfile_t *mf, struct userdiff_driver **textconv)\n> +\t\t     mmfile_t *mf, struct userdiff_driver *textconv)\n>  {\n>  \tif (DIFF_FILE_VALID(one)) {\n> -\t\tmf->size = fill_textconv(*textconv, one, &mf->ptr);\n> +\t\tmf->size = fill_textconv(textconv, one, &mf->ptr);\n>  \t} else {\n>  \t\tmemset(mf, 0, sizeof(*mf));\n>  \t}\n> @@ -101,8 +101,8 @@ static int diff_grep(struct diff_filepair *p, struct diff_options *o,\n>  \t\ttextconv_two = get_textconv(p->two);\n>  \t}\n>  \n> -\tfill_one(p->one, &mf1, &textconv_one);\n> -\tfill_one(p->two, &mf2, &textconv_two);\n> +\tfill_one(p->one, &mf1, textconv_one);\n> +\tfill_one(p->two, &mf2, textconv_two);\n\nThis is a sensible cleanup, though as I mentioned elsewhere, I think it\nwould make sense to come first before the other patch.\n\nAfter this, fill_one is _almost_ identical to just calling\nfill_textconv; the exception is that for the !DIFF_FILE_VALID case,\nfill_textconv gives us an empty buffer rather than a NULL one.\n\nWhat do you think of something like this on top (this is on top of your\npatches, but again, I would suggest re-ordering your two, so it would\ncome as patch 2/3):\n\n diffcore-pickaxe.c | 30 ++++++++++--------------------\n 1 file changed, 10 insertions(+), 20 deletions(-)\n\ndiff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c\nindex c378ea0..26ddf00 100644\n--- a/diffcore-pickaxe.c\n+++ b/diffcore-pickaxe.c\n@@ -74,16 +74,6 @@ static void diffgrep_consume(void *priv, char *line, unsigned long len)\n \tline[len] = hold;\n }\n \n-static void fill_one(struct diff_filespec *one,\n-\t\t     mmfile_t *mf, struct userdiff_driver *textconv)\n-{\n-\tif (DIFF_FILE_VALID(one)) {\n-\t\tmf->size = fill_textconv(textconv, one, &mf->ptr);\n-\t} else {\n-\t\tmemset(mf, 0, sizeof(*mf));\n-\t}\n-}\n-\n static int diff_grep(struct diff_filepair *p, struct diff_options *o,\n \t\t     regex_t *regexp, kwset_t kws)\n {\n@@ -101,15 +91,15 @@ static int diff_grep(struct diff_filepair *p, struct diff_options *o,\n \t\ttextconv_two = get_textconv(p->two);\n \t}\n \n-\tfill_one(p->one, &mf1, textconv_one);\n-\tfill_one(p->two, &mf2, textconv_two);\n+\tmf1.size = fill_textconv(textconv_one, p->one, &mf1.ptr);\n+\tmf2.size = fill_textconv(textconv_two, p->two, &mf2.ptr);\n \n-\tif (!mf1.ptr) {\n-\t\tif (!mf2.ptr)\n+\tif (!DIFF_FILE_VALID(p->one)) {\n+\t\tif (!DIFF_FILE_VALID(p->two))\n \t\t\treturn 0; /* ignore unmerged */\n \t\t/* created \"two\" -- does it have what we are looking for? */\n \t\thit = !regexec(regexp, mf2.ptr, 1, &regmatch, 0);\n-\t} else if (!mf2.ptr) {\n+\t} else if (!DIFF_FILE_VALID(p->two)) {\n \t\t/* removed \"one\" -- did it have what we are looking for? */\n \t\thit = !regexec(regexp, mf1.ptr, 1, &regmatch, 0);\n \t} else {\n@@ -228,16 +218,16 @@ static int has_changes(struct diff_filepair *p, struct diff_options *o,\n \tif (textconv_one == textconv_two && diff_unmodified_pair(p))\n \t\treturn 0;\n \n-\tfill_one(p->one, &mf1, textconv_one);\n-\tfill_one(p->two, &mf2, textconv_two);\n+\tmf1.size = fill_textconv(textconv_one, p->one, &mf1.ptr);\n+\tmf2.size = fill_textconv(textconv_two, p->two, &mf2.ptr);\n \n-\tif (!mf1.ptr) {\n-\t\tif (!mf2.ptr)\n+\tif (!DIFF_FILE_VALID(p->one)) {\n+\t\tif (!DIFF_FILE_VALID(p->two))\n \t\t\tret = 0; /* ignore unmerged */\n \t\t/* created */\n \t\tret = contains(&mf2, o, regexp, kws) != 0;\n \t}\n-\telse if (!mf2.ptr) /* removed */\n+\telse if (!DIFF_FILE_VALID(p->two)) /* removed */\n \t\tret = contains(&mf1, o, regexp, kws) != 0;\n \telse\n \t\tret = contains(&mf1, o, regexp, kws) !=\n"}]}