{"thread":{"id":"50657","subject":"[PATCH 00/20] nd/diff-parseopt part 3","startedAt":"2019-03-05T12:30:43Z","lastAt":"2019-03-06T09:25:56Z","messageCount":23,"participants":["Nguyễn Thái Ngọc Duy","Eric Sunshine","Duy Nguyen"],"isPatch":true,"patchVersion":1,"patchTotal":20},"messages":[{"id":"370682","messageId":"20190305123026.7266-1-pclouds@gmail.com","threadId":"50657","inReplyTo":null,"subject":"[PATCH 00/20] nd/diff-parseopt part 3","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-05T12:30:06Z","receivedAt":"2019-03-05T12:30:43Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The next part of nd/diff-parseopt to continue converting more diff\noptions to parseopt. Based on nd/diff-parseopt-2.\n\nPart 4 will hopefully finish the diff.c part and we'll move on to 4-5\nmore parts on revision.c.\n\nNguyễn Thái Ngọc Duy (20):\n  diff-parseopt: convert --[no-]indent-heuristic\n  diff-parseopt: convert --patience\n  diff-parseopt: convert --histogram\n  diff-parseopt: convert --diff-algorithm\n  diff-parseopt: convert --anchored\n  diff-parseopt: convert --binary\n  diff-parseopt: convert --full-index\n  diff-parseopt: convert -a|--text\n  diff-parseopt: convert -R\n  diff-parseopt: convert --[no-]follow\n  diff-parseopt: convert --[no-]color\n  diff-parseopt: convert --word-diff\n  diff-parseopt: convert --word-diff-regex\n  diff-parseopt: convert --color-words\n  diff-parseopt: convert --exit-code\n  diff-parseopt: convert --quiet\n  diff-parseopt: convert --ext-diff\n  diff-parseopt: convert --textconv\n  diff-parseopt: convert --ignore-submodules\n  diff-parseopt: convert --submodule\n\n Documentation/diff-options.txt |   2 +-\n diff.c                         | 342 ++++++++++++++++++++++-----------\n 2 files changed, 229 insertions(+), 115 deletions(-)\n\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"370683","messageId":"20190305123026.7266-2-pclouds@gmail.com","threadId":"50657","inReplyTo":"20190305123026.7266-1-pclouds@gmail.com","subject":"[PATCH 01/20] diff-parseopt: convert --[no-]indent-heuristic","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-05T12:30:07Z","receivedAt":"2019-03-05T12:30:50Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff.c | 9 ++++-----\n 1 file changed, 4 insertions(+), 5 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex a63ee4a44d..c4cd84f1b3 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5124,6 +5124,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT_F(0, \"ignore-blank-lines\", &options->xdl_opts,\n \t\t\t  N_(\"ignore changes whose lines are all blank\"),\n \t\t\t  XDF_IGNORE_BLANK_LINES, PARSE_OPT_NONEG),\n+\t\tOPT_BIT(0, \"indent-heuristic\", &options->xdl_opts,\n+\t\t\tN_(\"heuristic to shift diff hunk boundaries for easy reading\"),\n+\t\t\tXDF_INDENT_HEURISTIC),\n \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\tOPT_CALLBACK_F(0, \"relative\", options, N_(\"<prefix>\"),\n@@ -5162,11 +5165,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* xdiff options */\n-\tif (!strcmp(arg, \"--indent-heuristic\"))\n-\t\tDIFF_XDL_SET(options, INDENT_HEURISTIC);\n-\telse if (!strcmp(arg, \"--no-indent-heuristic\"))\n-\t\tDIFF_XDL_CLR(options, INDENT_HEURISTIC);\n-\telse if (!strcmp(arg, \"--patience\")) {\n+\tif (!strcmp(arg, \"--patience\")) {\n \t\tint i;\n \t\toptions->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);\n \t\t/*\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"370684","messageId":"20190305123026.7266-3-pclouds@gmail.com","threadId":"50657","inReplyTo":"20190305123026.7266-1-pclouds@gmail.com","subject":"[PATCH 02/20] diff-parseopt: convert --patience","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-05T12:30:08Z","receivedAt":"2019-03-05T12:30:55Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff.c | 37 +++++++++++++++++++++++++------------\n 1 file changed, 25 insertions(+), 12 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex c4cd84f1b3..7899c7cc06 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4960,6 +4960,26 @@ static enum parse_opt_result diff_opt_output(struct parse_opt_ctx_t *ctx,\n \treturn 0;\n }\n \n+static int diff_opt_patience(const struct option *opt,\n+\t\t\t     const char *arg, int unset)\n+{\n+\tstruct diff_options *options = opt->value;\n+\tint i;\n+\n+\tBUG_ON_OPT_NEG(unset);\n+\tBUG_ON_OPT_ARG(arg);\n+\toptions->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);\n+\t/*\n+\t * Both --patience and --anchored use PATIENCE_DIFF\n+\t * internally, so remove any anchors previously\n+\t * specified.\n+\t */\n+\tfor (i = 0; i < options->anchors_nr; i++)\n+\t\tfree(options->anchors[i]);\n+\toptions->anchors_nr = 0;\n+\treturn 0;\n+}\n+\n static int diff_opt_relative(const struct option *opt,\n \t\t\t     const char *arg, int unset)\n {\n@@ -5127,6 +5147,10 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT(0, \"indent-heuristic\", &options->xdl_opts,\n \t\t\tN_(\"heuristic to shift diff hunk boundaries for easy reading\"),\n \t\t\tXDF_INDENT_HEURISTIC),\n+\t\tOPT_CALLBACK_F(0, \"patience\", options, NULL,\n+\t\t\t       N_(\"generate diff using the \\\"patience diff\\\" algorithm\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_NOARG,\n+\t\t\t       diff_opt_patience),\n \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\tOPT_CALLBACK_F(0, \"relative\", options, N_(\"<prefix>\"),\n@@ -5165,18 +5189,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* xdiff options */\n-\tif (!strcmp(arg, \"--patience\")) {\n-\t\tint i;\n-\t\toptions->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);\n-\t\t/*\n-\t\t * Both --patience and --anchored use PATIENCE_DIFF\n-\t\t * internally, so remove any anchors previously\n-\t\t * specified.\n-\t\t */\n-\t\tfor (i = 0; i < options->anchors_nr; i++)\n-\t\t\tfree(options->anchors[i]);\n-\t\toptions->anchors_nr = 0;\n-\t} else if (!strcmp(arg, \"--histogram\"))\n+\tif (!strcmp(arg, \"--histogram\"))\n \t\toptions->xdl_opts = DIFF_WITH_ALG(options, HISTOGRAM_DIFF);\n \telse if ((argcount = parse_long_opt(\"diff-algorithm\", av, &optarg))) {\n \t\tlong value = parse_algorithm_value(optarg);\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"370685","messageId":"20190305123026.7266-4-pclouds@gmail.com","threadId":"50657","inReplyTo":"20190305123026.7266-1-pclouds@gmail.com","subject":"[PATCH 03/20] diff-parseopt: convert --histogram","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-05T12:30:09Z","receivedAt":"2019-03-05T12:31:00Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff.c | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 7899c7cc06..7432702fd8 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5151,6 +5151,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       N_(\"generate diff using the \\\"patience diff\\\" algorithm\"),\n \t\t\t       PARSE_OPT_NONEG | PARSE_OPT_NOARG,\n \t\t\t       diff_opt_patience),\n+\t\tOPT_BITOP(0, \"histogram\", &options->xdl_opts,\n+\t\t\t  N_(\"generate diff using the \\\"histogram diff\\\" algorithm\"),\n+\t\t\t  XDF_HISTOGRAM_DIFF, XDF_DIFF_ALGORITHM_MASK),\n \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\tOPT_CALLBACK_F(0, \"relative\", options, N_(\"<prefix>\"),\n@@ -5189,9 +5192,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* xdiff options */\n-\tif (!strcmp(arg, \"--histogram\"))\n-\t\toptions->xdl_opts = DIFF_WITH_ALG(options, HISTOGRAM_DIFF);\n-\telse if ((argcount = parse_long_opt(\"diff-algorithm\", av, &optarg))) {\n+\tif ((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-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"370686","messageId":"20190305123026.7266-5-pclouds@gmail.com","threadId":"50657","inReplyTo":"20190305123026.7266-1-pclouds@gmail.com","subject":"[PATCH 04/20] diff-parseopt: convert --diff-algorithm","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-05T12:30:10Z","receivedAt":"2019-03-05T12:31:04Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff.c | 33 ++++++++++++++++++++++-----------\n 1 file changed, 22 insertions(+), 11 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 7432702fd8..8d08795f9c 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4891,6 +4891,24 @@ static int diff_opt_compact_summary(const struct option *opt,\n \treturn 0;\n }\n \n+static int diff_opt_diff_algorithm(const struct option *opt,\n+\t\t\t\t   const char *arg, int unset)\n+{\n+\tstruct diff_options *options = opt->value;\n+\tlong value = parse_algorithm_value(arg);\n+\n+\tBUG_ON_OPT_NEG(unset);\n+\tif (value < 0)\n+\t\treturn error(_(\"option diff-algorithm accepts \\\"myers\\\", \"\n+\t\t\t       \"\\\"minimal\\\", \\\"patience\\\" and \\\"histogram\\\"\"));\n+\n+\t/* clear out previous settings */\n+\tDIFF_XDL_CLR(options, NEED_MINIMAL);\n+\toptions->xdl_opts &= ~XDF_DIFF_ALGORITHM_MASK;\n+\toptions->xdl_opts |= value;\n+\treturn 0;\n+}\n+\n static int diff_opt_dirstat(const struct option *opt,\n \t\t\t    const char *arg, int unset)\n {\n@@ -5154,6 +5172,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BITOP(0, \"histogram\", &options->xdl_opts,\n \t\t\t  N_(\"generate diff using the \\\"histogram diff\\\" algorithm\"),\n \t\t\t  XDF_HISTOGRAM_DIFF, XDF_DIFF_ALGORITHM_MASK),\n+\t\tOPT_CALLBACK_F(0, \"diff-algorithm\", options, N_(\"<algorithm>\"),\n+\t\t\t       N_(\"choose a diff algorithm\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_diff_algorithm),\n \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\tOPT_CALLBACK_F(0, \"relative\", options, N_(\"<prefix>\"),\n@@ -5192,17 +5213,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* xdiff options */\n-\tif ((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-\t\t/* clear out previous settings */\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} else if (skip_prefix(arg, \"--anchored=\", &arg)) {\n+\tif (skip_prefix(arg, \"--anchored=\", &arg)) {\n \t\toptions->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);\n \t\tALLOC_GROW(options->anchors, options->anchors_nr + 1,\n \t\t\t   options->anchors_alloc);\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"370687","messageId":"20190305123026.7266-6-pclouds@gmail.com","threadId":"50657","inReplyTo":"20190305123026.7266-1-pclouds@gmail.com","subject":"[PATCH 05/20] diff-parseopt: convert --anchored","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-05T12:30:11Z","receivedAt":"2019-03-05T12:31:09Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff.c | 26 +++++++++++++++++---------\n 1 file changed, 17 insertions(+), 9 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 8d08795f9c..5195526db9 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4839,6 +4839,19 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)\n \treturn 1;\n }\n \n+static int diff_opt_anchored(const struct option *opt,\n+\t\t\t     const char *arg, int unset)\n+{\n+\tstruct diff_options *options = opt->value;\n+\n+\tBUG_ON_OPT_NEG(unset);\n+\toptions->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);\n+\tALLOC_GROW(options->anchors, options->anchors_nr + 1,\n+\t\t   options->anchors_alloc);\n+\toptions->anchors[options->anchors_nr++] = xstrdup(arg);\n+\treturn 0;\n+}\n+\n static int diff_opt_break_rewrites(const struct option *opt,\n \t\t\t\t   const char *arg, int unset)\n {\n@@ -5175,6 +5188,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_CALLBACK_F(0, \"diff-algorithm\", options, N_(\"<algorithm>\"),\n \t\t\t       N_(\"choose a diff algorithm\"),\n \t\t\t       PARSE_OPT_NONEG, diff_opt_diff_algorithm),\n+\t\tOPT_CALLBACK_F(0, \"anchored\", options, N_(\"<text>\"),\n+\t\t\t       N_(\"generate diff using the \\\"anchored diff\\\" algorithm\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_anchored),\n \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\tOPT_CALLBACK_F(0, \"relative\", options, N_(\"<prefix>\"),\n@@ -5212,16 +5228,8 @@ int diff_opt_parse(struct diff_options *options,\n \tif (ac)\n \t\treturn ac;\n \n-\t/* xdiff options */\n-\tif (skip_prefix(arg, \"--anchored=\", &arg)) {\n-\t\toptions->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);\n-\t\tALLOC_GROW(options->anchors, options->anchors_nr + 1,\n-\t\t\t   options->anchors_alloc);\n-\t\toptions->anchors[options->anchors_nr++] = xstrdup(arg);\n-\t}\n-\n \t/* flags options */\n-\telse if (!strcmp(arg, \"--binary\")) {\n+\tif (!strcmp(arg, \"--binary\")) {\n \t\tenable_patch_output(&options->output_format);\n \t\toptions->flags.binary = 1;\n \t}\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"370688","messageId":"20190305123026.7266-7-pclouds@gmail.com","threadId":"50657","inReplyTo":"20190305123026.7266-1-pclouds@gmail.com","subject":"[PATCH 06/20] diff-parseopt: convert --binary","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-05T12:30:12Z","receivedAt":"2019-03-05T12:31:13Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Documentation/diff-options.txt |  2 +-\n diff.c                         | 21 ++++++++++++++++-----\n 2 files changed, 17 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt\nindex 915f2fec8b..6810c94fea 100644\n--- a/Documentation/diff-options.txt\n+++ b/Documentation/diff-options.txt\n@@ -425,7 +425,7 @@ endif::git-format-patch[]\n \n --binary::\n \tIn addition to `--full-index`, output a binary diff that\n-\tcan be applied with `git-apply`.\n+\tcan be applied with `git-apply`. Implies `--patch`.\n \n --abbrev[=<n>]::\n \tInstead of showing the full 40-byte hexadecimal object\ndiff --git a/diff.c b/diff.c\nindex 5195526db9..214728c892 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4852,6 +4852,18 @@ static int diff_opt_anchored(const struct option *opt,\n \treturn 0;\n }\n \n+static int diff_opt_binary(const struct option *opt,\n+\t\t\t   const char *arg, int unset)\n+{\n+\tstruct diff_options *options = opt->value;\n+\n+\tBUG_ON_OPT_NEG(unset);\n+\tBUG_ON_OPT_ARG(arg);\n+\tenable_patch_output(&options->output_format);\n+\toptions->flags.binary = 1;\n+\treturn 0;\n+}\n+\n static int diff_opt_break_rewrites(const struct option *opt,\n \t\t\t\t   const char *arg, int unset)\n {\n@@ -5116,6 +5128,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_CALLBACK_F(0, \"compact-summary\", options, NULL,\n \t\t\t       N_(\"generate compact summary in diffstat\"),\n \t\t\t       PARSE_OPT_NOARG, diff_opt_compact_summary),\n+\t\tOPT_CALLBACK_F(0, \"binary\", options, NULL,\n+\t\t\t       N_(\"output a binary diff that can be applied\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_NOARG, diff_opt_binary),\n \t\tOPT_CALLBACK_F(0, \"output-indicator-new\",\n \t\t\t       &options->output_indicators[OUTPUT_INDICATOR_NEW],\n \t\t\t       N_(\"<char>\"),\n@@ -5229,11 +5244,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* flags options */\n-\tif (!strcmp(arg, \"--binary\")) {\n-\t\tenable_patch_output(&options->output_format);\n-\t\toptions->flags.binary = 1;\n-\t}\n-\telse if (!strcmp(arg, \"--full-index\"))\n+\tif (!strcmp(arg, \"--full-index\"))\n \t\toptions->flags.full_index = 1;\n \telse if (!strcmp(arg, \"-a\") || !strcmp(arg, \"--text\"))\n \t\toptions->flags.text = 1;\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"370689","messageId":"20190305123026.7266-8-pclouds@gmail.com","threadId":"50657","inReplyTo":"20190305123026.7266-1-pclouds@gmail.com","subject":"[PATCH 07/20] diff-parseopt: convert --full-index","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-05T12:30:13Z","receivedAt":"2019-03-05T12:31:18Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 214728c892..3a13ba37fd 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5131,6 +5131,8 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_CALLBACK_F(0, \"binary\", options, NULL,\n \t\t\t       N_(\"output a binary diff that can be applied\"),\n \t\t\t       PARSE_OPT_NONEG | PARSE_OPT_NOARG, diff_opt_binary),\n+\t\tOPT_BOOL(0, \"full-index\", &options->flags.full_index,\n+\t\t\t N_(\"show full pre- and post-image object names on the \\\"index\\\" lines\")),\n \t\tOPT_CALLBACK_F(0, \"output-indicator-new\",\n \t\t\t       &options->output_indicators[OUTPUT_INDICATOR_NEW],\n \t\t\t       N_(\"<char>\"),\n@@ -5244,9 +5246,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* flags options */\n-\tif (!strcmp(arg, \"--full-index\"))\n-\t\toptions->flags.full_index = 1;\n-\telse if (!strcmp(arg, \"-a\") || !strcmp(arg, \"--text\"))\n+\tif (!strcmp(arg, \"-a\") || !strcmp(arg, \"--text\"))\n \t\toptions->flags.text = 1;\n \telse if (!strcmp(arg, \"-R\"))\n \t\toptions->flags.reverse_diff = 1;\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"370690","messageId":"20190305123026.7266-9-pclouds@gmail.com","threadId":"50657","inReplyTo":"20190305123026.7266-1-pclouds@gmail.com","subject":"[PATCH 08/20] diff-parseopt: convert -a|--text","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-05T12:30:14Z","receivedAt":"2019-03-05T12:31:23Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 3a13ba37fd..51d22f63fa 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5214,6 +5214,8 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       N_(\"when run from subdir, exclude changes outside and show relative paths\"),\n \t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n \t\t\t       diff_opt_relative),\n+\t\tOPT_BOOL('a', \"text\", &options->flags.text,\n+\t\t\t N_(\"treat all files as text\")),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n \t\t  N_(\"Output to a specific file\"),\n \t\t  PARSE_OPT_NONEG, NULL, 0, diff_opt_output },\n@@ -5246,9 +5248,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* flags options */\n-\tif (!strcmp(arg, \"-a\") || !strcmp(arg, \"--text\"))\n-\t\toptions->flags.text = 1;\n-\telse if (!strcmp(arg, \"-R\"))\n+\tif (!strcmp(arg, \"-R\"))\n \t\toptions->flags.reverse_diff = 1;\n \telse if (!strcmp(arg, \"--follow\"))\n \t\toptions->flags.follow_renames = 1;\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"370691","messageId":"20190305123026.7266-10-pclouds@gmail.com","threadId":"50657","inReplyTo":"20190305123026.7266-1-pclouds@gmail.com","subject":"[PATCH 09/20] diff-parseopt: convert -R","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-05T12:30:15Z","receivedAt":"2019-03-05T12:31:28Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 51d22f63fa..689dc11684 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5216,6 +5216,8 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       diff_opt_relative),\n \t\tOPT_BOOL('a', \"text\", &options->flags.text,\n \t\t\t N_(\"treat all files as text\")),\n+\t\tOPT_BOOL('R', NULL, &options->flags.reverse_diff,\n+\t\t\t N_(\"swap two inputs, reverse the diff\")),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n \t\t  N_(\"Output to a specific file\"),\n \t\t  PARSE_OPT_NONEG, NULL, 0, diff_opt_output },\n@@ -5248,9 +5250,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* flags options */\n-\tif (!strcmp(arg, \"-R\"))\n-\t\toptions->flags.reverse_diff = 1;\n-\telse if (!strcmp(arg, \"--follow\"))\n+\tif (!strcmp(arg, \"--follow\"))\n \t\toptions->flags.follow_renames = 1;\n \telse if (!strcmp(arg, \"--no-follow\")) {\n \t\toptions->flags.follow_renames = 0;\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"370692","messageId":"20190305123026.7266-11-pclouds@gmail.com","threadId":"50657","inReplyTo":"20190305123026.7266-1-pclouds@gmail.com","subject":"[PATCH 10/20] diff-parseopt: convert --[no-]follow","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-05T12:30:16Z","receivedAt":"2019-03-05T12:31:33Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff.c | 25 +++++++++++++++++++------\n 1 file changed, 19 insertions(+), 6 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 689dc11684..ad813ea418 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4986,6 +4986,21 @@ static int diff_opt_find_renames(const struct option *opt,\n \treturn 0;\n }\n \n+static int diff_opt_follow(const struct option *opt,\n+\t\t\t   const char *arg, int unset)\n+{\n+\tstruct diff_options *options = opt->value;\n+\n+\tBUG_ON_OPT_ARG(arg);\n+\tif (unset) {\n+\t\toptions->flags.follow_renames = 0;\n+\t\toptions->flags.default_follow_renames = 0;\n+\t} else {\n+\t\toptions->flags.follow_renames = 1;\n+\t}\n+\treturn 0;\n+}\n+\n static enum parse_opt_result diff_opt_output(struct parse_opt_ctx_t *ctx,\n \t\t\t\t\t     const struct option *opt,\n \t\t\t\t\t     const char *arg, int unset)\n@@ -5172,6 +5187,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t      0, PARSE_OPT_NONEG),\n \t\tOPT_BOOL(0, \"rename-empty\", &options->flags.rename_empty,\n \t\t\t N_(\"use empty blobs as rename source\")),\n+\t\tOPT_CALLBACK_F(0, \"follow\", options, NULL,\n+\t\t\t       N_(\"continue listing the history of a file beyond renames\"),\n+\t\t\t       PARSE_OPT_NOARG, diff_opt_follow),\n \n \t\tOPT_GROUP(N_(\"Diff algorithm options\")),\n \t\tOPT_BIT(0, \"minimal\", &options->xdl_opts,\n@@ -5250,12 +5268,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* flags options */\n-\tif (!strcmp(arg, \"--follow\"))\n-\t\toptions->flags.follow_renames = 1;\n-\telse if (!strcmp(arg, \"--no-follow\")) {\n-\t\toptions->flags.follow_renames = 0;\n-\t\toptions->flags.default_follow_renames = 0;\n-\t} else if (skip_to_optional_arg_default(arg, \"--color\", &arg, \"always\")) {\n+\tif (skip_to_optional_arg_default(arg, \"--color\", &arg, \"always\")) {\n \t\tint value = git_config_colorbool(NULL, arg);\n \t\tif (value < 0)\n \t\t\treturn error(\"option `color' expects \\\"always\\\", \\\"auto\\\", or \\\"never\\\"\");\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"370693","messageId":"20190305123026.7266-12-pclouds@gmail.com","threadId":"50657","inReplyTo":"20190305123026.7266-1-pclouds@gmail.com","subject":"[PATCH 11/20] diff-parseopt: convert --[no-]color","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-05T12:30:17Z","receivedAt":"2019-03-05T12:31:37Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff.c | 12 +++---------\n 1 file changed, 3 insertions(+), 9 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex ad813ea418..bb36d507ec 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5148,6 +5148,8 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       PARSE_OPT_NONEG | PARSE_OPT_NOARG, diff_opt_binary),\n \t\tOPT_BOOL(0, \"full-index\", &options->flags.full_index,\n \t\t\t N_(\"show full pre- and post-image object names on the \\\"index\\\" lines\")),\n+\t\tOPT_COLOR_FLAG(0, \"color\", &options->use_color,\n+\t\t\t       N_(\"show colored diff\")),\n \t\tOPT_CALLBACK_F(0, \"output-indicator-new\",\n \t\t\t       &options->output_indicators[OUTPUT_INDICATOR_NEW],\n \t\t\t       N_(\"<char>\"),\n@@ -5268,15 +5270,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* flags options */\n-\tif (skip_to_optional_arg_default(arg, \"--color\", &arg, \"always\")) {\n-\t\tint value = git_config_colorbool(NULL, arg);\n-\t\tif (value < 0)\n-\t\t\treturn error(\"option `color' expects \\\"always\\\", \\\"auto\\\", or \\\"never\\\"\");\n-\t\toptions->use_color = value;\n-\t}\n-\telse if (!strcmp(arg, \"--no-color\"))\n-\t\toptions->use_color = 0;\n-\telse if (!strcmp(arg, \"--color-moved\")) {\n+\tif (!strcmp(arg, \"--color-moved\")) {\n \t\tif (diff_color_moved_default)\n \t\t\toptions->color_moved = diff_color_moved_default;\n \t\tif (options->color_moved == COLOR_MOVED_NO)\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"370694","messageId":"20190305123026.7266-13-pclouds@gmail.com","threadId":"50657","inReplyTo":"20190305123026.7266-1-pclouds@gmail.com","subject":"[PATCH 12/20] diff-parseopt: convert --word-diff","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-05T12:30:18Z","receivedAt":"2019-03-05T12:31:42Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff.c | 47 +++++++++++++++++++++++++++++------------------\n 1 file changed, 29 insertions(+), 18 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex bb36d507ec..14c057f3df 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5066,6 +5066,32 @@ static int diff_opt_unified(const struct option *opt,\n \treturn 0;\n }\n \n+static int diff_opt_word_diff(const struct option *opt,\n+\t\t\t      const char *arg, int unset)\n+{\n+\tstruct diff_options *options = opt->value;\n+\n+\tBUG_ON_OPT_NEG(unset);\n+\tif (arg) {\n+\t\tif (!strcmp(arg, \"plain\"))\n+\t\t\toptions->word_diff = DIFF_WORDS_PLAIN;\n+\t\telse if (!strcmp(arg, \"color\")) {\n+\t\t\toptions->use_color = 1;\n+\t\t\toptions->word_diff = DIFF_WORDS_COLOR;\n+\t\t}\n+\t\telse if (!strcmp(arg, \"porcelain\"))\n+\t\t\toptions->word_diff = DIFF_WORDS_PORCELAIN;\n+\t\telse if (!strcmp(arg, \"none\"))\n+\t\t\toptions->word_diff = DIFF_WORDS_NONE;\n+\t\telse\n+\t\t\treturn error(_(\"bad --word-diff argument: %s\"), arg);\n+\t} else {\n+\t\tif (options->word_diff == DIFF_WORDS_NONE)\n+\t\t\toptions->word_diff = DIFF_WORDS_PLAIN;\n+\t}\n+\treturn 0;\n+}\n+\n static void prep_parse_options(struct diff_options *options)\n {\n \tstruct option parseopts[] = {\n@@ -5228,6 +5254,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_CALLBACK_F(0, \"anchored\", options, N_(\"<text>\"),\n \t\t\t       N_(\"generate diff using the \\\"anchored diff\\\" algorithm\"),\n \t\t\t       PARSE_OPT_NONEG, diff_opt_anchored),\n+\t\tOPT_CALLBACK_F(0, \"word-diff\", options, N_(\"<mode>\"),\n+\t\t\t       N_(\"show word diff, using <mode> to delimit changed words\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_word_diff),\n \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\tOPT_CALLBACK_F(0, \"relative\", options, N_(\"<prefix>\"),\n@@ -5291,24 +5320,6 @@ int diff_opt_parse(struct diff_options *options,\n \t\toptions->use_color = 1;\n \t\toptions->word_diff = DIFF_WORDS_COLOR;\n \t}\n-\telse if (!strcmp(arg, \"--word-diff\")) {\n-\t\tif (options->word_diff == DIFF_WORDS_NONE)\n-\t\t\toptions->word_diff = DIFF_WORDS_PLAIN;\n-\t}\n-\telse if (skip_prefix(arg, \"--word-diff=\", &arg)) {\n-\t\tif (!strcmp(arg, \"plain\"))\n-\t\t\toptions->word_diff = DIFF_WORDS_PLAIN;\n-\t\telse if (!strcmp(arg, \"color\")) {\n-\t\t\toptions->use_color = 1;\n-\t\t\toptions->word_diff = DIFF_WORDS_COLOR;\n-\t\t}\n-\t\telse if (!strcmp(arg, \"porcelain\"))\n-\t\t\toptions->word_diff = DIFF_WORDS_PORCELAIN;\n-\t\telse if (!strcmp(arg, \"none\"))\n-\t\t\toptions->word_diff = DIFF_WORDS_NONE;\n-\t\telse\n-\t\t\tdie(\"bad --word-diff argument: %s\", arg);\n-\t}\n \telse if ((argcount = parse_long_opt(\"word-diff-regex\", av, &optarg))) {\n \t\tif (options->word_diff == DIFF_WORDS_NONE)\n \t\t\toptions->word_diff = DIFF_WORDS_PLAIN;\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"370695","messageId":"20190305123026.7266-14-pclouds@gmail.com","threadId":"50657","inReplyTo":"20190305123026.7266-1-pclouds@gmail.com","subject":"[PATCH 13/20] diff-parseopt: convert --word-diff-regex","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-05T12:30:19Z","receivedAt":"2019-03-05T12:31:46Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff.c | 21 +++++++++++++++------\n 1 file changed, 15 insertions(+), 6 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 14c057f3df..634981723b 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5092,6 +5092,18 @@ static int diff_opt_word_diff(const struct option *opt,\n \treturn 0;\n }\n \n+static int diff_opt_word_diff_regex(const struct option *opt,\n+\t\t\t\t    const char *arg, int unset)\n+{\n+\tstruct diff_options *options = opt->value;\n+\n+\tBUG_ON_OPT_NEG(unset);\n+\tif (options->word_diff == DIFF_WORDS_NONE)\n+\t\toptions->word_diff = DIFF_WORDS_PLAIN;\n+\toptions->word_regex = arg;\n+\treturn 0;\n+}\n+\n static void prep_parse_options(struct diff_options *options)\n {\n \tstruct option parseopts[] = {\n@@ -5257,6 +5269,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_CALLBACK_F(0, \"word-diff\", options, N_(\"<mode>\"),\n \t\t\t       N_(\"show word diff, using <mode> to delimit changed words\"),\n \t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_word_diff),\n+\t\tOPT_CALLBACK_F(0, \"word-diff-regex\", options, N_(\"<regex>\"),\n+\t\t\t       N_(\"use <regex> to decide what a word is\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_word_diff_regex),\n \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\tOPT_CALLBACK_F(0, \"relative\", options, N_(\"<prefix>\"),\n@@ -5320,12 +5335,6 @@ int diff_opt_parse(struct diff_options *options,\n \t\toptions->use_color = 1;\n \t\toptions->word_diff = DIFF_WORDS_COLOR;\n \t}\n-\telse if ((argcount = parse_long_opt(\"word-diff-regex\", av, &optarg))) {\n-\t\tif (options->word_diff == DIFF_WORDS_NONE)\n-\t\t\toptions->word_diff = DIFF_WORDS_PLAIN;\n-\t\toptions->word_regex = optarg;\n-\t\treturn argcount;\n-\t}\n \telse if (!strcmp(arg, \"--exit-code\"))\n \t\toptions->flags.exit_with_status = 1;\n \telse if (!strcmp(arg, \"--quiet\"))\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"370696","messageId":"20190305123026.7266-15-pclouds@gmail.com","threadId":"50657","inReplyTo":"20190305123026.7266-1-pclouds@gmail.com","subject":"[PATCH 14/20] diff-parseopt: convert --color-words","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-05T12:30:20Z","receivedAt":"2019-03-05T12:31:51Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff.c | 21 ++++++++++++++++-----\n 1 file changed, 16 insertions(+), 5 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 634981723b..5180c2f5a9 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4901,6 +4901,18 @@ static int diff_opt_char(const struct option *opt,\n \treturn 0;\n }\n \n+static int diff_opt_color_words(const struct option *opt,\n+\t\t\t\tconst char *arg, int unset)\n+{\n+\tstruct diff_options *options = opt->value;\n+\n+\tBUG_ON_OPT_NEG(unset);\n+\toptions->use_color = 1;\n+\toptions->word_diff = DIFF_WORDS_COLOR;\n+\toptions->word_regex = arg;\n+\treturn 0;\n+}\n+\n static int diff_opt_compact_summary(const struct option *opt,\n \t\t\t\t    const char *arg, int unset)\n {\n@@ -5272,6 +5284,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_CALLBACK_F(0, \"word-diff-regex\", options, N_(\"<regex>\"),\n \t\t\t       N_(\"use <regex> to decide what a word is\"),\n \t\t\t       PARSE_OPT_NONEG, diff_opt_word_diff_regex),\n+\t\tOPT_CALLBACK_F(0, \"color-words\", options, N_(\"<regex>\"),\n+\t\t\t       N_(\"equivalent to --word-diff=color --word-diff-regex=<regex>\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_color_words),\n \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\tOPT_CALLBACK_F(0, \"relative\", options, N_(\"<prefix>\"),\n@@ -5331,11 +5346,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\tif (cm & COLOR_MOVED_WS_ERROR)\n \t\t\treturn -1;\n \t\toptions->color_moved_ws_handling = cm;\n-\t} else if (skip_to_optional_arg_default(arg, \"--color-words\", &options->word_regex, NULL)) {\n-\t\toptions->use_color = 1;\n-\t\toptions->word_diff = DIFF_WORDS_COLOR;\n-\t}\n-\telse if (!strcmp(arg, \"--exit-code\"))\n+\t} else if (!strcmp(arg, \"--exit-code\"))\n \t\toptions->flags.exit_with_status = 1;\n \telse if (!strcmp(arg, \"--quiet\"))\n \t\toptions->flags.quick = 1;\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"370697","messageId":"20190305123026.7266-16-pclouds@gmail.com","threadId":"50657","inReplyTo":"20190305123026.7266-1-pclouds@gmail.com","subject":"[PATCH 15/20] diff-parseopt: convert --exit-code","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-05T12:30:21Z","receivedAt":"2019-03-05T12:31:56Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 5180c2f5a9..3f80e06de5 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5297,6 +5297,8 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t N_(\"treat all files as text\")),\n \t\tOPT_BOOL('R', NULL, &options->flags.reverse_diff,\n \t\t\t N_(\"swap two inputs, reverse the diff\")),\n+\t\tOPT_BOOL(0, \"exit-code\", &options->flags.exit_with_status,\n+\t\t\t N_(\"exit with 1 if there were differences, 0 otherwise\")),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n \t\t  N_(\"Output to a specific file\"),\n \t\t  PARSE_OPT_NONEG, NULL, 0, diff_opt_output },\n@@ -5346,9 +5348,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\tif (cm & COLOR_MOVED_WS_ERROR)\n \t\t\treturn -1;\n \t\toptions->color_moved_ws_handling = cm;\n-\t} else if (!strcmp(arg, \"--exit-code\"))\n-\t\toptions->flags.exit_with_status = 1;\n-\telse if (!strcmp(arg, \"--quiet\"))\n+\t} else if (!strcmp(arg, \"--quiet\"))\n \t\toptions->flags.quick = 1;\n \telse if (!strcmp(arg, \"--ext-diff\"))\n \t\toptions->flags.allow_external = 1;\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"370698","messageId":"20190305123026.7266-17-pclouds@gmail.com","threadId":"50657","inReplyTo":"20190305123026.7266-1-pclouds@gmail.com","subject":"[PATCH 16/20] diff-parseopt: convert --quiet","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-05T12:30:22Z","receivedAt":"2019-03-05T12:32:00Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 3f80e06de5..bd15269346 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5299,6 +5299,8 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t N_(\"swap two inputs, reverse the diff\")),\n \t\tOPT_BOOL(0, \"exit-code\", &options->flags.exit_with_status,\n \t\t\t N_(\"exit with 1 if there were differences, 0 otherwise\")),\n+\t\tOPT_BOOL(0, \"quiet\", &options->flags.quick,\n+\t\t\t N_(\"disable all output of the program\")),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n \t\t  N_(\"Output to a specific file\"),\n \t\t  PARSE_OPT_NONEG, NULL, 0, diff_opt_output },\n@@ -5348,9 +5350,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\tif (cm & COLOR_MOVED_WS_ERROR)\n \t\t\treturn -1;\n \t\toptions->color_moved_ws_handling = cm;\n-\t} else if (!strcmp(arg, \"--quiet\"))\n-\t\toptions->flags.quick = 1;\n-\telse if (!strcmp(arg, \"--ext-diff\"))\n+\t} else if (!strcmp(arg, \"--ext-diff\"))\n \t\toptions->flags.allow_external = 1;\n \telse if (!strcmp(arg, \"--no-ext-diff\"))\n \t\toptions->flags.allow_external = 0;\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"370699","messageId":"20190305123026.7266-18-pclouds@gmail.com","threadId":"50657","inReplyTo":"20190305123026.7266-1-pclouds@gmail.com","subject":"[PATCH 17/20] diff-parseopt: convert --ext-diff","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-05T12:30:23Z","receivedAt":"2019-03-05T12:32:05Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff.c | 8 +++-----\n 1 file changed, 3 insertions(+), 5 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex bd15269346..b460fa010b 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5301,6 +5301,8 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t N_(\"exit with 1 if there were differences, 0 otherwise\")),\n \t\tOPT_BOOL(0, \"quiet\", &options->flags.quick,\n \t\t\t N_(\"disable all output of the program\")),\n+\t\tOPT_BOOL(0, \"ext-diff\", &options->flags.allow_external,\n+\t\t\t N_(\"allow an external diff helper to be executed\")),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n \t\t  N_(\"Output to a specific file\"),\n \t\t  PARSE_OPT_NONEG, NULL, 0, diff_opt_output },\n@@ -5350,11 +5352,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\tif (cm & COLOR_MOVED_WS_ERROR)\n \t\t\treturn -1;\n \t\toptions->color_moved_ws_handling = cm;\n-\t} else if (!strcmp(arg, \"--ext-diff\"))\n-\t\toptions->flags.allow_external = 1;\n-\telse if (!strcmp(arg, \"--no-ext-diff\"))\n-\t\toptions->flags.allow_external = 0;\n-\telse if (!strcmp(arg, \"--textconv\")) {\n+\t} else if (!strcmp(arg, \"--textconv\")) {\n \t\toptions->flags.allow_textconv = 1;\n \t\toptions->flags.textconv_set_via_cmdline = 1;\n \t} else if (!strcmp(arg, \"--no-textconv\"))\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"370700","messageId":"20190305123026.7266-19-pclouds@gmail.com","threadId":"50657","inReplyTo":"20190305123026.7266-1-pclouds@gmail.com","subject":"[PATCH 18/20] diff-parseopt: convert --textconv","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-05T12:30:24Z","receivedAt":"2019-03-05T12:32:09Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff.c | 25 +++++++++++++++++++------\n 1 file changed, 19 insertions(+), 6 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex b460fa010b..a27bca527d 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5062,6 +5062,21 @@ static int diff_opt_relative(const struct option *opt,\n \treturn 0;\n }\n \n+static int diff_opt_textconv(const struct option *opt,\n+\t\t\t     const char *arg, int unset)\n+{\n+\tstruct diff_options *options = opt->value;\n+\n+\tBUG_ON_OPT_ARG(arg);\n+\tif (unset) {\n+\t\toptions->flags.allow_textconv = 0;\n+\t} else {\n+\t\toptions->flags.allow_textconv = 1;\n+\t\toptions->flags.textconv_set_via_cmdline = 1;\n+\t}\n+\treturn 0;\n+}\n+\n static int diff_opt_unified(const struct option *opt,\n \t\t\t    const char *arg, int unset)\n {\n@@ -5303,6 +5318,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t N_(\"disable all output of the program\")),\n \t\tOPT_BOOL(0, \"ext-diff\", &options->flags.allow_external,\n \t\t\t N_(\"allow an external diff helper to be executed\")),\n+\t\tOPT_CALLBACK_F(0, \"textconv\", options, NULL,\n+\t\t\t       N_(\"run external text conversion filters when comparing binary files\"),\n+\t\t\t       PARSE_OPT_NOARG, diff_opt_textconv),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n \t\t  N_(\"Output to a specific file\"),\n \t\t  PARSE_OPT_NONEG, NULL, 0, diff_opt_output },\n@@ -5352,12 +5370,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\tif (cm & COLOR_MOVED_WS_ERROR)\n \t\t\treturn -1;\n \t\toptions->color_moved_ws_handling = cm;\n-\t} else if (!strcmp(arg, \"--textconv\")) {\n-\t\toptions->flags.allow_textconv = 1;\n-\t\toptions->flags.textconv_set_via_cmdline = 1;\n-\t} else if (!strcmp(arg, \"--no-textconv\"))\n-\t\toptions->flags.allow_textconv = 0;\n-\telse if (skip_to_optional_arg_default(arg, \"--ignore-submodules\", &arg, \"all\")) {\n+\t} else if (skip_to_optional_arg_default(arg, \"--ignore-submodules\", &arg, \"all\")) {\n \t\toptions->flags.override_submodule_config = 1;\n \t\thandle_ignore_submodules_arg(options, arg);\n \t} else if (skip_to_optional_arg_default(arg, \"--submodule\", &arg, \"log\"))\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"370701","messageId":"20190305123026.7266-20-pclouds@gmail.com","threadId":"50657","inReplyTo":"20190305123026.7266-1-pclouds@gmail.com","subject":"[PATCH 19/20] diff-parseopt: convert --ignore-submodules","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-05T12:30:25Z","receivedAt":"2019-03-05T12:32:15Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff.c | 20 +++++++++++++++++---\n 1 file changed, 17 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex a27bca527d..6fd6106963 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5013,6 +5013,19 @@ static int diff_opt_follow(const struct option *opt,\n \treturn 0;\n }\n \n+static int diff_opt_ignore_submodules(const struct option *opt,\n+\t\t\t\t      const char *arg, int unset)\n+{\n+\tstruct diff_options *options = opt->value;\n+\n+\tBUG_ON_OPT_NEG(unset);\n+\tif (!arg)\n+\t\targ = \"all\";\n+\toptions->flags.override_submodule_config = 1;\n+\thandle_ignore_submodules_arg(options, arg);\n+\treturn 0;\n+}\n+\n static enum parse_opt_result diff_opt_output(struct parse_opt_ctx_t *ctx,\n \t\t\t\t\t     const struct option *opt,\n \t\t\t\t\t     const char *arg, int unset)\n@@ -5321,6 +5334,10 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_CALLBACK_F(0, \"textconv\", options, NULL,\n \t\t\t       N_(\"run external text conversion filters when comparing binary files\"),\n \t\t\t       PARSE_OPT_NOARG, diff_opt_textconv),\n+\t\tOPT_CALLBACK_F(0, \"ignore-submodules\", options, N_(\"<when>\"),\n+\t\t\t       N_(\"ignore changes to submodules in the diff generation\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n+\t\t\t       diff_opt_ignore_submodules),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n \t\t  N_(\"Output to a specific file\"),\n \t\t  PARSE_OPT_NONEG, NULL, 0, diff_opt_output },\n@@ -5370,9 +5387,6 @@ int diff_opt_parse(struct diff_options *options,\n \t\tif (cm & COLOR_MOVED_WS_ERROR)\n \t\t\treturn -1;\n \t\toptions->color_moved_ws_handling = cm;\n-\t} else if (skip_to_optional_arg_default(arg, \"--ignore-submodules\", &arg, \"all\")) {\n-\t\toptions->flags.override_submodule_config = 1;\n-\t\thandle_ignore_submodules_arg(options, arg);\n \t} else if (skip_to_optional_arg_default(arg, \"--submodule\", &arg, \"log\"))\n \t\treturn parse_submodule_opt(options, arg);\n \telse if (skip_prefix(arg, \"--ws-error-highlight=\", &arg))\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"370702","messageId":"20190305123026.7266-21-pclouds@gmail.com","threadId":"50657","inReplyTo":"20190305123026.7266-1-pclouds@gmail.com","subject":"[PATCH 20/20] diff-parseopt: convert --submodule","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-05T12:30:26Z","receivedAt":"2019-03-05T12:32:18Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff.c | 30 +++++++++++++++++++-----------\n 1 file changed, 19 insertions(+), 11 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 6fd6106963..ce118bb326 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4721,14 +4721,6 @@ static int parse_dirstat_opt(struct diff_options *options, const char *params)\n \treturn 1;\n }\n \n-static int parse_submodule_opt(struct diff_options *options, const char *value)\n-{\n-\tif (parse_submodule_params(options, value))\n-\t\tdie(_(\"Failed to parse --submodule option parameter: '%s'\"),\n-\t\t\tvalue);\n-\treturn 1;\n-}\n-\n static const char diff_status_letters[] = {\n \tDIFF_STATUS_ADDED,\n \tDIFF_STATUS_COPIED,\n@@ -5075,6 +5067,20 @@ static int diff_opt_relative(const struct option *opt,\n \treturn 0;\n }\n \n+static int diff_opt_submodule(const struct option *opt,\n+\t\t\t      const char *arg, int unset)\n+{\n+\tstruct diff_options *options = opt->value;\n+\n+\tBUG_ON_OPT_NEG(unset);\n+\tif (!arg)\n+\t\targ = \"log\";\n+\tif (parse_submodule_params(options, arg))\n+\t\treturn error(_(\"failed to parse --submodule option parameter: '%s'\"),\n+\t\t\t     arg);\n+\treturn 0;\n+}\n+\n static int diff_opt_textconv(const struct option *opt,\n \t\t\t     const char *arg, int unset)\n {\n@@ -5338,6 +5344,10 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       N_(\"ignore changes to submodules in the diff generation\"),\n \t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n \t\t\t       diff_opt_ignore_submodules),\n+\t\tOPT_CALLBACK_F(0, \"submodule\", options, N_(\"<format>\"),\n+\t\t\t       N_(\"specify how differences in submodules are shown\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n+\t\t\t       diff_opt_submodule),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n \t\t  N_(\"Output to a specific file\"),\n \t\t  PARSE_OPT_NONEG, NULL, 0, diff_opt_output },\n@@ -5387,9 +5397,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\tif (cm & COLOR_MOVED_WS_ERROR)\n \t\t\treturn -1;\n \t\toptions->color_moved_ws_handling = cm;\n-\t} else if (skip_to_optional_arg_default(arg, \"--submodule\", &arg, \"log\"))\n-\t\treturn parse_submodule_opt(options, arg);\n-\telse if (skip_prefix(arg, \"--ws-error-highlight=\", &arg))\n+\t} else if (skip_prefix(arg, \"--ws-error-highlight=\", &arg))\n \t\treturn parse_ws_error_highlight_opt(options, arg);\n \telse if (!strcmp(arg, \"--ita-invisible-in-index\"))\n \t\toptions->ita_invisible_in_index = 1;\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"370722","messageId":"CAPig+cR-efk5esa9=5j+Fu0eWxAkFnohkSL4eabrP44K_AkdCg@mail.gmail.com","threadId":"50657","inReplyTo":"20190305123026.7266-17-pclouds@gmail.com","subject":"Re: [PATCH 16/20] diff-parseopt: convert --quiet","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2019-03-05T15:42:46Z","receivedAt":"2019-03-05T15:42:59Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Mar 5, 2019 at 7:32 AM Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n> diff --git a/diff.c b/diff.c\n> @@ -5299,6 +5299,8 @@ static void prep_parse_options(struct diff_options *options)\n> +               OPT_BOOL(0, \"quiet\", &options->flags.quick,\n> +                        N_(\"disable all output of the program\")),\n\nAs a reviewer, I was wondering why you didn't use OPT__QUIET() here, but...\n\n> @@ -5348,9 +5350,7 @@ int diff_opt_parse(struct diff_options *options,\n> -       } else if (!strcmp(arg, \"--quiet\"))\n> -               options->flags.quick = 1;\n> -       else if (!strcmp(arg, \"--ext-diff\"))\n\nI guess the reason is that flags.quick isn't necessarily about\nverbosity/quietness.\n"},{"id":"370795","messageId":"CACsJy8CtewTfFUwJwRK4BzF+kBq1OvmDwgsWEzf8Y8o=_0_nZw@mail.gmail.com","threadId":"50657","inReplyTo":"CAPig+cR-efk5esa9=5j+Fu0eWxAkFnohkSL4eabrP44K_AkdCg@mail.gmail.com","subject":"Re: [PATCH 16/20] diff-parseopt: convert --quiet","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-06T09:25:28Z","receivedAt":"2019-03-06T09:25:56Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Mar 5, 2019 at 10:42 PM Eric Sunshine <sunshine@sunshineco.com> wrote:\n>\n> On Tue, Mar 5, 2019 at 7:32 AM Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n> > diff --git a/diff.c b/diff.c\n> > @@ -5299,6 +5299,8 @@ static void prep_parse_options(struct diff_options *options)\n> > +               OPT_BOOL(0, \"quiet\", &options->flags.quick,\n> > +                        N_(\"disable all output of the program\")),\n>\n> As a reviewer, I was wondering why you didn't use OPT__QUIET() here, but...\n\nIt probably just didn't occur to me. After doing a couple conversions,\nyou kinda get in a routine and forget to question if your choice is\nthe right one.\n\n> > @@ -5348,9 +5350,7 @@ int diff_opt_parse(struct diff_options *options,\n> > -       } else if (!strcmp(arg, \"--quiet\"))\n> > -               options->flags.quick = 1;\n> > -       else if (!strcmp(arg, \"--ext-diff\"))\n>\n> I guess the reason is that flags.quick isn't necessarily about\n> verbosity/quietness.\n\nAlso OPT__QUIET() adds the short option -q. Adding that, even if\nhelpful, should be done separately.\n-- \nDuy\n"}]}