{"thread":{"id":"33389","subject":"[PATCH] diff: allow unstuck arguments with --diff-algorithm","startedAt":"2013-04-05T11:15:27Z","lastAt":"2013-04-05T12:19:14Z","messageCount":3,"participants":["John Keeping","Thomas Rast"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"213257","messageId":"8fc6f21da7c876d50f2f35c73252e95d525dffb5.1365160527.git.john@keeping.me.uk","threadId":"33389","inReplyTo":null,"subject":"[PATCH] diff: allow unstuck arguments with --diff-algorithm","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-04-05T11:15:27Z","receivedAt":"2013-04-05T11:15:27Z","isPatch":true,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"The argument to --diff-algorithm is mandatory, so there is no reason to\nrequire the argument to be stuck to the option with '='.  Change this\nfor consistency with other Git commands.\n\nNote that this doesi not change the handling of diff-algorithm in\nmerge-recursive.c since the primary interface to that is via the -X\noption to 'git merge' where the unstuck form does not make sense.\n\nSigned-off-by: John Keeping <john@keeping.me.uk>\n---\n diff.c | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex db952a5..e0152f8 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3596,8 +3596,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t\toptions->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);\n \telse if (!strcmp(arg, \"--histogram\"))\n \t\toptions->xdl_opts = DIFF_WITH_ALG(options, HISTOGRAM_DIFF);\n-\telse if (!prefixcmp(arg, \"--diff-algorithm=\")) {\n-\t\tlong value = parse_algorithm_value(arg+17);\n+\telse if ((argcount = parse_long_opt(\"diff-algorithm\", av, &optarg))) {\n+\t\tlong value = parse_algorithm_value(optarg);\n \t\tif (value < 0)\n \t\t\treturn error(\"option diff-algorithm accepts \\\"myers\\\", \"\n \t\t\t\t     \"\\\"minimal\\\", \\\"patience\\\" and \\\"histogram\\\"\");\n@@ -3605,6 +3605,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t\tDIFF_XDL_CLR(options, NEED_MINIMAL);\n \t\toptions->xdl_opts &= ~XDF_DIFF_ALGORITHM_MASK;\n \t\toptions->xdl_opts |= value;\n+\t\treturn argcount;\n \t}\n \n \t/* flags options */\n-- \n1.8.2.540.gf023cfe\n"},{"id":"213259","messageId":"876201td7v.fsf@linux-k42r.v.cablecom.net","threadId":"33389","inReplyTo":"8fc6f21da7c876d50f2f35c73252e95d525dffb5.1365160527.git.john@keeping.me.uk","subject":"Re: [PATCH] diff: allow unstuck arguments with --diff-algorithm","fromName":"Thomas Rast","fromEmail":"trast@inf.ethz.ch","sentAt":"2013-04-05T11:43:16Z","receivedAt":"2013-04-05T11:43:16Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"John Keeping <john@keeping.me.uk> writes:\n\n> The argument to --diff-algorithm is mandatory, so there is no reason to\n> require the argument to be stuck to the option with '='.  Change this\n> for consistency with other Git commands.\n>\n> Note that this doesi not change the handling of diff-algorithm in\n                     ^\nstrayi ;-)\n\n> merge-recursive.c since the primary interface to that is via the -X\n> option to 'git merge' where the unstuck form does not make sense.\n>\n> Signed-off-by: John Keeping <john@keeping.me.uk>\n> ---\n>  diff.c | 5 +++--\n>  1 file changed, 3 insertions(+), 2 deletions(-)\n>\n> diff --git a/diff.c b/diff.c\n> index db952a5..e0152f8 100644\n> --- a/diff.c\n> +++ b/diff.c\n> @@ -3596,8 +3596,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n>  \t\toptions->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);\n>  \telse if (!strcmp(arg, \"--histogram\"))\n>  \t\toptions->xdl_opts = DIFF_WITH_ALG(options, HISTOGRAM_DIFF);\n> -\telse if (!prefixcmp(arg, \"--diff-algorithm=\")) {\n> -\t\tlong value = parse_algorithm_value(arg+17);\n> +\telse if ((argcount = parse_long_opt(\"diff-algorithm\", av, &optarg))) {\n> +\t\tlong value = parse_algorithm_value(optarg);\n>  \t\tif (value < 0)\n>  \t\t\treturn error(\"option diff-algorithm accepts \\\"myers\\\", \"\n>  \t\t\t\t     \"\\\"minimal\\\", \\\"patience\\\" and \\\"histogram\\\"\");\n> @@ -3605,6 +3605,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n>  \t\tDIFF_XDL_CLR(options, NEED_MINIMAL);\n>  \t\toptions->xdl_opts &= ~XDF_DIFF_ALGORITHM_MASK;\n>  \t\toptions->xdl_opts |= value;\n> +\t\treturn argcount;\n>  \t}\n>  \n>  \t/* flags options */\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"213300","messageId":"20130405121914.GP2222@serenity.lan","threadId":"33389","inReplyTo":"876201td7v.fsf@linux-k42r.v.cablecom.net","subject":"[PATCH v2] diff: allow unstuck arguments with --diff-algorithm","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-04-05T12:19:14Z","receivedAt":"2013-04-05T12:19:14Z","isPatch":true,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"The argument to --diff-algorithm is mandatory, so there is no reason to\nrequire the argument to be stuck to the option with '='.  Change this\nfor consistency with other Git commands.\n\nNote that this does not change the handling of diff-algorithm in\nmerge-recursive.c since the primary interface to that is via the -X\noption to 'git merge' where the unstuck form does not make sense.\n\nSigned-off-by: John Keeping <john@keeping.me.uk>\n---\nOn Fri, Apr 05, 2013 at 01:43:16PM +0200, Thomas Rast wrote:\n> John Keeping <john@keeping.me.uk> writes:\n> \n> > The argument to --diff-algorithm is mandatory, so there is no reason to\n> > require the argument to be stuck to the option with '='.  Change this\n> > for consistency with other Git commands.\n> >\n> > Note that this doesi not change the handling of diff-algorithm in\n>                      ^\n> strayi ;-)\n\nThanks.\n\n diff.c | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex db952a5..e0152f8 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3596,8 +3596,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t\toptions->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);\n \telse if (!strcmp(arg, \"--histogram\"))\n \t\toptions->xdl_opts = DIFF_WITH_ALG(options, HISTOGRAM_DIFF);\n-\telse if (!prefixcmp(arg, \"--diff-algorithm=\")) {\n-\t\tlong value = parse_algorithm_value(arg+17);\n+\telse if ((argcount = parse_long_opt(\"diff-algorithm\", av, &optarg))) {\n+\t\tlong value = parse_algorithm_value(optarg);\n \t\tif (value < 0)\n \t\t\treturn error(\"option diff-algorithm accepts \\\"myers\\\", \"\n \t\t\t\t     \"\\\"minimal\\\", \\\"patience\\\" and \\\"histogram\\\"\");\n@@ -3605,6 +3605,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t\tDIFF_XDL_CLR(options, NEED_MINIMAL);\n \t\toptions->xdl_opts &= ~XDF_DIFF_ALGORITHM_MASK;\n \t\toptions->xdl_opts |= value;\n+\t\treturn argcount;\n \t}\n \n \t/* flags options */\n-- \n1.8.2.540.gf023cfe\n"}]}