{"thread":{"id":"50424","subject":"[PATCH 00/21] nd/diff-parseopt part 2","startedAt":"2019-02-07T10:33:46Z","lastAt":"2019-02-21T11:18:20Z","messageCount":80,"participants":["Nguyễn Thái Ngọc Duy","SZEDER Gábor","Junio C Hamano","Andrei Rybak"],"isPatch":true,"patchVersion":1,"patchTotal":21},"messages":[{"id":"368677","messageId":"20190207103326.10693-1-pclouds@gmail.com","threadId":"50424","inReplyTo":null,"subject":"[PATCH 00/21] nd/diff-parseopt part 2","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-07T10:33:05Z","receivedAt":"2019-02-07T10:33:46Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\"What's cooking\" mails seem to indicate that the series will be cooked\nin full there then landed on master later. So here's the second part.\nThis continues to convert more diff options to parseopt.\n\nNguyễn Thái Ngọc Duy (21):\n  diff.c: convert --patch-with-raw\n  diff.c: convert --numstat and --shortstat\n  diff.c: convert --dirstat and friends\n  diff.c: convert --check\n  diff.c: convert --summary\n  diff.c: convert --patch-with-stat\n  diff.c: convert --name-only\n  diff.c: convert --name-status\n  diff.c: convert -s|--no-patch\n  diff.c: convert --stat*\n  diff.c: convert --[no-]compact-summary\n  diff.c: convert --output-*\n  diff.c: convert -B|--break-rewrites\n  diff.c: convert -M|--find-renames\n  diff.c: convert -D|--irreversible-delete\n  diff.c: convert -C|--find-copies\n  diff.c: convert --find-copies-harder\n  diff.c: convert --no-renames|--[no--rename-empty\n  diff.c: convert --relative\n  diff.c: convert --[no-]minimal\n  diff.c: convert --ignore-some-changes\n\n Documentation/diff-options.txt |  20 ++\n diff.c                         | 510 +++++++++++++++++++--------------\n 2 files changed, 319 insertions(+), 211 deletions(-)\n\n-- \n2.20.1.682.gd5861c6d90\n\n"},{"id":"368678","messageId":"20190207103326.10693-2-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"[PATCH 01/21] diff.c: convert --patch-with-raw","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-07T10:33:06Z","receivedAt":"2019-02-07T10:33: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 | 9 +++++----\n 1 file changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 4bc9df7362..12e333c67f 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4901,6 +4901,10 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT_F(0, \"raw\", &options->output_format,\n \t\t\t  N_(\"generate the diff in raw format\"),\n \t\t\t  DIFF_FORMAT_RAW, PARSE_OPT_NONEG),\n+\t\tOPT_BITOP(0, \"patch-with-raw\", &options->output_format,\n+\t\t\t  N_(\"synonym for '-p --raw'\"),\n+\t\t\t  DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW,\n+\t\t\t  DIFF_FORMAT_NO_OUTPUT),\n \t\tOPT_END()\n \t};\n \n@@ -4929,10 +4933,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--patch-with-raw\")) {\n-\t\tenable_patch_output(&options->output_format);\n-\t\toptions->output_format |= DIFF_FORMAT_RAW;\n-\t} else if (!strcmp(arg, \"--numstat\"))\n+\tif (!strcmp(arg, \"--numstat\"))\n \t\toptions->output_format |= DIFF_FORMAT_NUMSTAT;\n \telse if (!strcmp(arg, \"--shortstat\"))\n \t\toptions->output_format |= DIFF_FORMAT_SHORTSTAT;\n-- \n2.20.1.682.gd5861c6d90\n\n"},{"id":"368679","messageId":"20190207103326.10693-3-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"[PATCH 02/21] diff.c: convert --numstat and --shortstat","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-07T10:33:07Z","receivedAt":"2019-02-07T10:33: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 | 12 +++++++-----\n 1 file changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 12e333c67f..419b6ac4ae 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4905,6 +4905,12 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t  N_(\"synonym for '-p --raw'\"),\n \t\t\t  DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW,\n \t\t\t  DIFF_FORMAT_NO_OUTPUT),\n+\t\tOPT_BIT_F(0, \"numstat\", &options->output_format,\n+\t\t\t  N_(\"machine friendly --stat\"),\n+\t\t\t  DIFF_FORMAT_NUMSTAT, PARSE_OPT_NONEG),\n+\t\tOPT_BIT_F(0, \"shortstat\", &options->output_format,\n+\t\t\t  N_(\"output only the last line of --stat\"),\n+\t\t\t  DIFF_FORMAT_SHORTSTAT, PARSE_OPT_NONEG),\n \t\tOPT_END()\n \t};\n \n@@ -4933,11 +4939,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--numstat\"))\n-\t\toptions->output_format |= DIFF_FORMAT_NUMSTAT;\n-\telse if (!strcmp(arg, \"--shortstat\"))\n-\t\toptions->output_format |= DIFF_FORMAT_SHORTSTAT;\n-\telse if (skip_prefix(arg, \"-X\", &arg) ||\n+\tif (skip_prefix(arg, \"-X\", &arg) ||\n \t\t skip_to_optional_arg(arg, \"--dirstat\", &arg))\n \t\treturn parse_dirstat_opt(options, arg);\n \telse if (!strcmp(arg, \"--cumulative\"))\n-- \n2.20.1.682.gd5861c6d90\n\n"},{"id":"368680","messageId":"20190207103326.10693-4-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"[PATCH 03/21] diff.c: convert --dirstat and friends","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-07T10:33:08Z","receivedAt":"2019-02-07T10:34:02Z","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 |  7 ++++++\n diff.c                         | 39 +++++++++++++++++++++++++---------\n 2 files changed, 36 insertions(+), 10 deletions(-)\n\ndiff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt\nindex 0711734b12..058d93ec4f 100644\n--- a/Documentation/diff-options.txt\n+++ b/Documentation/diff-options.txt\n@@ -148,6 +148,7 @@ These parameters can also be set individually with `--stat-width=<width>`,\n \tnumber of modified files, as well as number of added and deleted\n \tlines.\n \n+-X<param1,param2,...>::\n --dirstat[=<param1,param2,...>]::\n \tOutput the distribution of relative amount of changes for each\n \tsub-directory. The behavior of `--dirstat` can be customized by\n@@ -192,6 +193,12 @@ directories with less than 10% of the total amount of changed files,\n and accumulating child directory counts in the parent directories:\n `--dirstat=files,10,cumulative`.\n \n+--cumulative::\n+\tSynonym for --dirstat=cumulative\n+\n+--dirstat-by-file[=<param1,param2>...]::\n+\tSynonym for --dirstat=files,param1,param2...\n+\n --summary::\n \tOutput a condensed summary of extended header information\n \tsuch as creations, renames and mode changes.\ndiff --git a/diff.c b/diff.c\nindex 419b6ac4ae..1cdbe8e688 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4867,6 +4867,22 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)\n \treturn 1;\n }\n \n+static int diff_opt_dirstat(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 (!strcmp(opt->long_name, \"cumulative\")) {\n+\t\tif (arg)\n+\t\t\tBUG(\"how come --cumulative take a value?\");\n+\t\targ = \"cumulative\";\n+\t} else if (!strcmp(opt->long_name, \"dirstat-by-file\"))\n+\t\tparse_dirstat_opt(options, \"files\");\n+\tparse_dirstat_opt(options, arg ? arg : \"\");\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@@ -4911,6 +4927,18 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT_F(0, \"shortstat\", &options->output_format,\n \t\t\t  N_(\"output only the last line of --stat\"),\n \t\t\t  DIFF_FORMAT_SHORTSTAT, PARSE_OPT_NONEG),\n+\t\tOPT_CALLBACK_F('X', \"dirstat\", options, N_(\"<param1,param2>...\"),\n+\t\t\t       N_(\"output the distribution of relative amount of changes for each sub-directory\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n+\t\t\t       diff_opt_dirstat),\n+\t\tOPT_CALLBACK_F(0, \"cumulative\", options, NULL,\n+\t\t\t       N_(\"synonym for --dirstat=cumulative\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_NOARG,\n+\t\t\t       diff_opt_dirstat),\n+\t\tOPT_CALLBACK_F(0, \"dirstat-by-file\", options, N_(\"<param1,param2>...\"),\n+\t\t\t       N_(\"synonym for --dirstat=files,param1,param2...\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n+\t\t\t       diff_opt_dirstat),\n \t\tOPT_END()\n \t};\n \n@@ -4939,16 +4967,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (skip_prefix(arg, \"-X\", &arg) ||\n-\t\t skip_to_optional_arg(arg, \"--dirstat\", &arg))\n-\t\treturn parse_dirstat_opt(options, arg);\n-\telse if (!strcmp(arg, \"--cumulative\"))\n-\t\treturn parse_dirstat_opt(options, \"cumulative\");\n-\telse if (skip_to_optional_arg(arg, \"--dirstat-by-file\", &arg)) {\n-\t\tparse_dirstat_opt(options, \"files\");\n-\t\treturn parse_dirstat_opt(options, arg);\n-\t}\n-\telse if (!strcmp(arg, \"--check\"))\n+\tif (!strcmp(arg, \"--check\"))\n \t\toptions->output_format |= DIFF_FORMAT_CHECKDIFF;\n \telse if (!strcmp(arg, \"--summary\"))\n \t\toptions->output_format |= DIFF_FORMAT_SUMMARY;\n-- \n2.20.1.682.gd5861c6d90\n\n"},{"id":"368681","messageId":"20190207103326.10693-5-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"[PATCH 04/21] diff.c: convert --check","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-07T10:33:09Z","receivedAt":"2019-02-07T10:34:06Z","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 1cdbe8e688..5e16082091 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4939,6 +4939,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       N_(\"synonym for --dirstat=files,param1,param2...\"),\n \t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n \t\t\t       diff_opt_dirstat),\n+\t\tOPT_BIT_F(0, \"check\", &options->output_format,\n+\t\t\t  N_(\"warn if changes introduce conflict markers or whitespace errors\"),\n+\t\t\t  DIFF_FORMAT_CHECKDIFF, PARSE_OPT_NONEG),\n \t\tOPT_END()\n \t};\n \n@@ -4967,9 +4970,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--check\"))\n-\t\toptions->output_format |= DIFF_FORMAT_CHECKDIFF;\n-\telse if (!strcmp(arg, \"--summary\"))\n+\tif (!strcmp(arg, \"--summary\"))\n \t\toptions->output_format |= DIFF_FORMAT_SUMMARY;\n \telse if (!strcmp(arg, \"--patch-with-stat\")) {\n \t\tenable_patch_output(&options->output_format);\n-- \n2.20.1.682.gd5861c6d90\n\n"},{"id":"368682","messageId":"20190207103326.10693-6-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"[PATCH 05/21] diff.c: convert --summary","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-07T10:33:10Z","receivedAt":"2019-02-07T10:34:11Z","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 5e16082091..0276f25200 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4942,6 +4942,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT_F(0, \"check\", &options->output_format,\n \t\t\t  N_(\"warn if changes introduce conflict markers or whitespace errors\"),\n \t\t\t  DIFF_FORMAT_CHECKDIFF, PARSE_OPT_NONEG),\n+\t\tOPT_BIT_F(0, \"summary\", &options->output_format,\n+\t\t\t  N_(\"condensed summary such as creations, renames and mode changes\"),\n+\t\t\t  DIFF_FORMAT_SUMMARY, PARSE_OPT_NONEG),\n \t\tOPT_END()\n \t};\n \n@@ -4970,9 +4973,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--summary\"))\n-\t\toptions->output_format |= DIFF_FORMAT_SUMMARY;\n-\telse if (!strcmp(arg, \"--patch-with-stat\")) {\n+\tif (!strcmp(arg, \"--patch-with-stat\")) {\n \t\tenable_patch_output(&options->output_format);\n \t\toptions->output_format |= DIFF_FORMAT_DIFFSTAT;\n \t} else if (!strcmp(arg, \"--name-only\"))\n-- \n2.20.1.682.gd5861c6d90\n\n"},{"id":"368683","messageId":"20190207103326.10693-7-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"[PATCH 06/21] diff.c: convert --patch-with-stat","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-07T10:33:11Z","receivedAt":"2019-02-07T10:34:16Z","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, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 0276f25200..b9811aefef 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4921,6 +4921,10 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t  N_(\"synonym for '-p --raw'\"),\n \t\t\t  DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW,\n \t\t\t  DIFF_FORMAT_NO_OUTPUT),\n+\t\tOPT_BITOP(0, \"patch-with-stat\", &options->output_format,\n+\t\t\t  N_(\"synonym for '-p --stat'\"),\n+\t\t\t  DIFF_FORMAT_PATCH | DIFF_FORMAT_DIFFSTAT,\n+\t\t\t  DIFF_FORMAT_NO_OUTPUT),\n \t\tOPT_BIT_F(0, \"numstat\", &options->output_format,\n \t\t\t  N_(\"machine friendly --stat\"),\n \t\t\t  DIFF_FORMAT_NUMSTAT, PARSE_OPT_NONEG),\n@@ -4973,10 +4977,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--patch-with-stat\")) {\n-\t\tenable_patch_output(&options->output_format);\n-\t\toptions->output_format |= DIFF_FORMAT_DIFFSTAT;\n-\t} else if (!strcmp(arg, \"--name-only\"))\n+\tif (!strcmp(arg, \"--name-only\"))\n \t\toptions->output_format |= DIFF_FORMAT_NAME;\n \telse if (!strcmp(arg, \"--name-status\"))\n \t\toptions->output_format |= DIFF_FORMAT_NAME_STATUS;\n-- \n2.20.1.682.gd5861c6d90\n\n"},{"id":"368684","messageId":"20190207103326.10693-8-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"[PATCH 07/21] diff.c: convert --name-only","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-07T10:33:12Z","receivedAt":"2019-02-07T10:34:21Z","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 b9811aefef..7ea308814f 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4949,6 +4949,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT_F(0, \"summary\", &options->output_format,\n \t\t\t  N_(\"condensed summary such as creations, renames and mode changes\"),\n \t\t\t  DIFF_FORMAT_SUMMARY, PARSE_OPT_NONEG),\n+\t\tOPT_BIT_F(0, \"name-only\", &options->output_format,\n+\t\t\t  N_(\"show only names of changed files\"),\n+\t\t\t  DIFF_FORMAT_NAME, PARSE_OPT_NONEG),\n \t\tOPT_END()\n \t};\n \n@@ -4977,9 +4980,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--name-only\"))\n-\t\toptions->output_format |= DIFF_FORMAT_NAME;\n-\telse if (!strcmp(arg, \"--name-status\"))\n+\tif (!strcmp(arg, \"--name-status\"))\n \t\toptions->output_format |= DIFF_FORMAT_NAME_STATUS;\n \telse if (!strcmp(arg, \"-s\") || !strcmp(arg, \"--no-patch\"))\n \t\toptions->output_format |= DIFF_FORMAT_NO_OUTPUT;\n-- \n2.20.1.682.gd5861c6d90\n\n"},{"id":"368685","messageId":"20190207103326.10693-9-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"[PATCH 08/21] diff.c: convert --name-status","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-07T10:33:13Z","receivedAt":"2019-02-07T10:34:26Z","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 7ea308814f..99047fb5fe 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4952,6 +4952,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT_F(0, \"name-only\", &options->output_format,\n \t\t\t  N_(\"show only names of changed files\"),\n \t\t\t  DIFF_FORMAT_NAME, PARSE_OPT_NONEG),\n+\t\tOPT_BIT_F(0, \"name-status\", &options->output_format,\n+\t\t\t  N_(\"show only names and status of changed files\"),\n+\t\t\t  DIFF_FORMAT_NAME_STATUS, PARSE_OPT_NONEG),\n \t\tOPT_END()\n \t};\n \n@@ -4980,9 +4983,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--name-status\"))\n-\t\toptions->output_format |= DIFF_FORMAT_NAME_STATUS;\n-\telse if (!strcmp(arg, \"-s\") || !strcmp(arg, \"--no-patch\"))\n+\tif (!strcmp(arg, \"-s\") || !strcmp(arg, \"--no-patch\"))\n \t\toptions->output_format |= DIFF_FORMAT_NO_OUTPUT;\n \telse if (starts_with(arg, \"--stat\"))\n \t\t/* --stat, --stat-width, --stat-name-width, or --stat-count */\n-- \n2.20.1.682.gd5861c6d90\n\n"},{"id":"368686","messageId":"20190207103326.10693-10-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"[PATCH 09/21] diff.c: convert -s|--no-patch","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-07T10:33:14Z","receivedAt":"2019-02-07T10:34:31Z","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 99047fb5fe..9c8f5336bc 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4906,6 +4906,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BITOP('p', \"patch\", &options->output_format,\n \t\t\t  N_(\"generate patch\"),\n \t\t\t  DIFF_FORMAT_PATCH, DIFF_FORMAT_NO_OUTPUT),\n+\t\tOPT_BIT_F('s', \"no-patch\", &options->output_format,\n+\t\t\t  N_(\"suppress diff output\"),\n+\t\t\t  DIFF_FORMAT_NO_OUTPUT, PARSE_OPT_NONEG),\n \t\tOPT_BITOP('u', NULL, &options->output_format,\n \t\t\t  N_(\"generate patch\"),\n \t\t\t  DIFF_FORMAT_PATCH, DIFF_FORMAT_NO_OUTPUT),\n@@ -4983,9 +4986,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"-s\") || !strcmp(arg, \"--no-patch\"))\n-\t\toptions->output_format |= DIFF_FORMAT_NO_OUTPUT;\n-\telse if (starts_with(arg, \"--stat\"))\n+\tif (starts_with(arg, \"--stat\"))\n \t\t/* --stat, --stat-width, --stat-name-width, or --stat-count */\n \t\treturn stat_opt(options, av);\n \telse if (!strcmp(arg, \"--compact-summary\")) {\n-- \n2.20.1.682.gd5861c6d90\n\n"},{"id":"368687","messageId":"20190207103326.10693-11-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"[PATCH 10/21] diff.c: convert --stat*","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-07T10:33:15Z","receivedAt":"2019-02-07T10:34:36Z","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 | 118 +++++++++++++++++++++++++--------------------------------\n 1 file changed, 52 insertions(+), 66 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 9c8f5336bc..1feb13deb3 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -104,11 +104,6 @@ static const char *color_diff_slots[] = {\n \t[DIFF_FILE_NEW_BOLD]\t      = \"newBold\",\n };\n \n-static NORETURN void die_want_option(const char *option_name)\n-{\n-\tdie(_(\"option '%s' requires a value\"), option_name);\n-}\n-\n define_list_config_array_extra(color_diff_slots, {\"plain\"});\n \n static int parse_diff_color_slot(const char *var)\n@@ -4661,77 +4656,56 @@ int parse_long_opt(const char *opt, const char **argv,\n \treturn 2;\n }\n \n-static int stat_opt(struct diff_options *options, const char **av)\n+static int diff_opt_stat(const struct option *opt, const char *value, int unset)\n {\n-\tconst char *arg = av[0];\n-\tchar *end;\n+\tstruct diff_options *options = opt->value;\n \tint width = options->stat_width;\n \tint name_width = options->stat_name_width;\n \tint graph_width = options->stat_graph_width;\n \tint count = options->stat_count;\n-\tint argcount = 1;\n+\tchar *end;\n \n-\tif (!skip_prefix(arg, \"--stat\", &arg))\n-\t\tBUG(\"stat option does not begin with --stat: %s\", arg);\n-\tend = (char *)arg;\n+\tBUG_ON_OPT_NEG(unset);\n \n-\tswitch (*arg) {\n-\tcase '-':\n-\t\tif (skip_prefix(arg, \"-width\", &arg)) {\n-\t\t\tif (*arg == '=')\n-\t\t\t\twidth = strtoul(arg + 1, &end, 10);\n-\t\t\telse if (!*arg && !av[1])\n-\t\t\t\tdie_want_option(\"--stat-width\");\n-\t\t\telse if (!*arg) {\n-\t\t\t\twidth = strtoul(av[1], &end, 10);\n-\t\t\t\targcount = 2;\n-\t\t\t}\n-\t\t} else if (skip_prefix(arg, \"-name-width\", &arg)) {\n-\t\t\tif (*arg == '=')\n-\t\t\t\tname_width = strtoul(arg + 1, &end, 10);\n-\t\t\telse if (!*arg && !av[1])\n-\t\t\t\tdie_want_option(\"--stat-name-width\");\n-\t\t\telse if (!*arg) {\n-\t\t\t\tname_width = strtoul(av[1], &end, 10);\n-\t\t\t\targcount = 2;\n-\t\t\t}\n-\t\t} else if (skip_prefix(arg, \"-graph-width\", &arg)) {\n-\t\t\tif (*arg == '=')\n-\t\t\t\tgraph_width = strtoul(arg + 1, &end, 10);\n-\t\t\telse if (!*arg && !av[1])\n-\t\t\t\tdie_want_option(\"--stat-graph-width\");\n-\t\t\telse if (!*arg) {\n-\t\t\t\tgraph_width = strtoul(av[1], &end, 10);\n-\t\t\t\targcount = 2;\n-\t\t\t}\n-\t\t} else if (skip_prefix(arg, \"-count\", &arg)) {\n-\t\t\tif (*arg == '=')\n-\t\t\t\tcount = strtoul(arg + 1, &end, 10);\n-\t\t\telse if (!*arg && !av[1])\n-\t\t\t\tdie_want_option(\"--stat-count\");\n-\t\t\telse if (!*arg) {\n-\t\t\t\tcount = strtoul(av[1], &end, 10);\n-\t\t\t\targcount = 2;\n-\t\t\t}\n+\tif (!strcmp(opt->long_name, \"stat\")) {\n+\t\tif (value) {\n+\t\t\twidth = strtoul(value, &end, 10);\n+\t\t\tif (*end == ',')\n+\t\t\t\tname_width = strtoul(end+1, &end, 10);\n+\t\t\tif (*end == ',')\n+\t\t\t\tcount = strtoul(end+1, &end, 10);\n+\t\t\tif (*end)\n+\t\t\t\treturn error(_(\"invalid --stat value: %s\"), value);\n \t\t}\n-\t\tbreak;\n-\tcase '=':\n-\t\twidth = strtoul(arg+1, &end, 10);\n-\t\tif (*end == ',')\n-\t\t\tname_width = strtoul(end+1, &end, 10);\n-\t\tif (*end == ',')\n-\t\t\tcount = strtoul(end+1, &end, 10);\n-\t}\n+\t} else if (!strcmp(opt->long_name, \"stat-width\")) {\n+\t\twidth = strtoul(value, &end, 10);\n+\t\tif (*end)\n+\t\t\treturn error(_(\"%s expects a numerical value\"),\n+\t\t\t\t     opt->long_name);\n+\t} else if (!strcmp(opt->long_name, \"stat-name-width\")) {\n+\t\tname_width = strtoul(value, &end, 10);\n+\t\tif (*end)\n+\t\t\treturn error(_(\"%s expects a numerical value\"),\n+\t\t\t\t     opt->long_name);\n+\t} else if (!strcmp(opt->long_name, \"stat-graph-width\")) {\n+\t\tgraph_width = strtoul(value, &end, 10);\n+\t\tif (*end)\n+\t\t\treturn error(_(\"%s expects a numerical value\"),\n+\t\t\t\t     opt->long_name);\n+\t} else if (!strcmp(opt->long_name, \"stat-count\")) {\n+\t\tcount = strtoul(value, &end, 10);\n+\t\tif (*end)\n+\t\t\treturn error(_(\"%s expects a numerical value\"),\n+\t\t\t\t     opt->long_name);\n+\t} else\n+\t\tBUG(\"%s should not get here\", opt->long_name);\n \n-\t/* Important! This checks all the error cases! */\n-\tif (*end)\n-\t\treturn 0;\n \toptions->output_format |= DIFF_FORMAT_DIFFSTAT;\n \toptions->stat_name_width = name_width;\n \toptions->stat_graph_width = graph_width;\n \toptions->stat_width = width;\n \toptions->stat_count = count;\n-\treturn argcount;\n+\treturn 0;\n }\n \n static int parse_dirstat_opt(struct diff_options *options, const char *params)\n@@ -4958,6 +4932,21 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT_F(0, \"name-status\", &options->output_format,\n \t\t\t  N_(\"show only names and status of changed files\"),\n \t\t\t  DIFF_FORMAT_NAME_STATUS, PARSE_OPT_NONEG),\n+\t\tOPT_CALLBACK_F(0, \"stat\", options, N_(\"<width>[,<name-width>[,<count>]]\"),\n+\t\t\t       N_(\"generate diffstat\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_stat),\n+\t\tOPT_CALLBACK_F(0, \"stat-width\", options, N_(\"<width>\"),\n+\t\t\t       N_(\"generate diffstat with a given width\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_stat),\n+\t\tOPT_CALLBACK_F(0, \"stat-name-width\", options, N_(\"<width>\"),\n+\t\t\t       N_(\"generate diffstat with a given name width\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_stat),\n+\t\tOPT_CALLBACK_F(0, \"stat-graph-width\", options, N_(\"<width>\"),\n+\t\t\t       N_(\"generate diffstat with a given graph width\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_stat),\n+\t\tOPT_CALLBACK_F(0, \"stat-count\", options, N_(\"<count>\"),\n+\t\t\t       N_(\"generate diffstat with limited lines\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_stat),\n \t\tOPT_END()\n \t};\n \n@@ -4986,10 +4975,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (starts_with(arg, \"--stat\"))\n-\t\t/* --stat, --stat-width, --stat-name-width, or --stat-count */\n-\t\treturn stat_opt(options, av);\n-\telse if (!strcmp(arg, \"--compact-summary\")) {\n+\tif (!strcmp(arg, \"--compact-summary\")) {\n \t\t options->flags.stat_with_summary = 1;\n \t\t options->output_format |= DIFF_FORMAT_DIFFSTAT;\n \t} else if (!strcmp(arg, \"--no-compact-summary\"))\n-- \n2.20.1.682.gd5861c6d90\n\n"},{"id":"368688","messageId":"20190207103326.10693-12-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"[PATCH 11/21] diff.c: convert --[no-]compact-summary","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-07T10:33:16Z","receivedAt":"2019-02-07T10:34:41Z","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 1feb13deb3..b24f6825a1 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4841,6 +4841,21 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)\n \treturn 1;\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+\tstruct diff_options *options = opt->value;\n+\n+\tBUG_ON_OPT_ARG(arg);\n+\tif (unset) {\n+\t\toptions->flags.stat_with_summary = 0;\n+\t} else {\n+\t\toptions->flags.stat_with_summary = 1;\n+\t\toptions->output_format |= DIFF_FORMAT_DIFFSTAT;\n+\t}\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@@ -4947,6 +4962,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_CALLBACK_F(0, \"stat-count\", options, N_(\"<count>\"),\n \t\t\t       N_(\"generate diffstat with limited lines\"),\n \t\t\t       PARSE_OPT_NONEG, diff_opt_stat),\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_END()\n \t};\n \n@@ -4975,12 +4993,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--compact-summary\")) {\n-\t\t options->flags.stat_with_summary = 1;\n-\t\t options->output_format |= DIFF_FORMAT_DIFFSTAT;\n-\t} else if (!strcmp(arg, \"--no-compact-summary\"))\n-\t\t options->flags.stat_with_summary = 0;\n-\telse if (skip_prefix(arg, \"--output-indicator-new=\", &arg))\n+\tif (skip_prefix(arg, \"--output-indicator-new=\", &arg))\n \t\toptions->output_indicators[OUTPUT_INDICATOR_NEW] = arg[0];\n \telse if (skip_prefix(arg, \"--output-indicator-old=\", &arg))\n \t\toptions->output_indicators[OUTPUT_INDICATOR_OLD] = arg[0];\n-- \n2.20.1.682.gd5861c6d90\n\n"},{"id":"368689","messageId":"20190207103326.10693-13-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"[PATCH 12/21] diff.c: convert --output-*","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-07T10:33:17Z","receivedAt":"2019-02-07T10:34:46Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This also validates that the user specifies a single character in\n--output-indicator-*, not a string.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Documentation/diff-options.txt | 10 +++++\n diff.c                         | 71 +++++++++++++++++++++++++---------\n 2 files changed, 63 insertions(+), 18 deletions(-)\n\ndiff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt\nindex 058d93ec4f..d3e8d634b2 100644\n--- a/Documentation/diff-options.txt\n+++ b/Documentation/diff-options.txt\n@@ -41,6 +41,16 @@ ifndef::git-format-patch[]\n \tImplies `-p`.\n endif::git-format-patch[]\n \n+--output=<file>::\n+\tOutput to a specific file instead of stdout.\n+\n+--output-indicator-new=<char>::\n+--output-indicator-old=<char>::\n+--output-indicator-context=<char>::\n+\tSpecify the character used to indicate new, old or context\n+\tlines in the generated patch. Normally they are '+', '-' and\n+\t' ' respectively.\n+\n ifndef::git-format-patch[]\n --raw::\n ifndef::git-log[]\ndiff --git a/diff.c b/diff.c\nindex b24f6825a1..8df396cb9a 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4841,6 +4841,19 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)\n \treturn 1;\n }\n \n+static int diff_opt_char(const struct option *opt,\n+\t\t\t const char *arg, int unset)\n+{\n+\tchar *value = opt->value;\n+\n+\tBUG_ON_OPT_NEG(unset);\n+\tif (arg[1])\n+\t\treturn error(_(\"%s expects a character, got '%s'\"),\n+\t\t\t     opt->long_name, arg);\n+\t*value = arg[0];\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@@ -4872,6 +4885,23 @@ static int diff_opt_dirstat(const struct option *opt,\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+{\n+\tstruct diff_options *options = opt->value;\n+\tchar *path;\n+\n+\tBUG_ON_OPT_NEG(unset);\n+\tpath = prefix_filename(ctx->prefix, arg);\n+\toptions->file = xfopen(path, \"w\");\n+\toptions->close_file = 1;\n+\tif (options->use_color != GIT_COLOR_ALWAYS)\n+\t\toptions->use_color = GIT_COLOR_NEVER;\n+\tfree(path);\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@@ -4965,6 +4995,27 @@ 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, \"output-indicator-new\",\n+\t\t\t       &options->output_indicators[OUTPUT_INDICATOR_NEW],\n+\t\t\t       N_(\"<char>\"),\n+\t\t\t       N_(\"specify the character to indicate a new line instead of '+'\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_char),\n+\t\tOPT_CALLBACK_F(0, \"output-indicator-old\",\n+\t\t\t       &options->output_indicators[OUTPUT_INDICATOR_OLD],\n+\t\t\t       N_(\"<char>\"),\n+\t\t\t       N_(\"specify the character to indicate an old line instead of '-'\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_char),\n+\t\tOPT_CALLBACK_F(0, \"output-indicator-context\",\n+\t\t\t       &options->output_indicators[OUTPUT_INDICATOR_CONTEXT],\n+\t\t\t       N_(\"<char>\"),\n+\t\t\t       N_(\"specify the character to indicate a context instead of ' '\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_char),\n+\n+\t\tOPT_GROUP(N_(\"Diff other options\")),\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+\n \t\tOPT_END()\n \t};\n \n@@ -4992,16 +5043,8 @@ int diff_opt_parse(struct diff_options *options,\n \tif (ac)\n \t\treturn ac;\n \n-\t/* Output format options */\n-\tif (skip_prefix(arg, \"--output-indicator-new=\", &arg))\n-\t\toptions->output_indicators[OUTPUT_INDICATOR_NEW] = arg[0];\n-\telse if (skip_prefix(arg, \"--output-indicator-old=\", &arg))\n-\t\toptions->output_indicators[OUTPUT_INDICATOR_OLD] = arg[0];\n-\telse if (skip_prefix(arg, \"--output-indicator-context=\", &arg))\n-\t\toptions->output_indicators[OUTPUT_INDICATOR_CONTEXT] = arg[0];\n-\n \t/* renames options */\n-\telse if (starts_with(arg, \"-B\") ||\n+\tif (starts_with(arg, \"-B\") ||\n \t\t skip_to_optional_arg(arg, \"--break-rewrites\", NULL)) {\n \t\tif ((options->break_opt = diff_scoreopt_parse(arg)) == -1)\n \t\t\treturn error(\"invalid argument to -B: %s\", arg+2);\n@@ -5242,15 +5285,7 @@ int diff_opt_parse(struct diff_options *options,\n \telse if (opt_arg(arg, '\\0', \"inter-hunk-context\",\n \t\t\t &options->interhunkcontext))\n \t\t;\n-\telse if ((argcount = parse_long_opt(\"output\", av, &optarg))) {\n-\t\tchar *path = prefix_filename(prefix, optarg);\n-\t\toptions->file = xfopen(path, \"w\");\n-\t\toptions->close_file = 1;\n-\t\tif (options->use_color != GIT_COLOR_ALWAYS)\n-\t\t\toptions->use_color = GIT_COLOR_NEVER;\n-\t\tfree(path);\n-\t\treturn argcount;\n-\t} else\n+\telse\n \t\treturn 0;\n \treturn 1;\n }\n-- \n2.20.1.682.gd5861c6d90\n\n"},{"id":"368690","messageId":"20190207103326.10693-14-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"[PATCH 13/21] diff.c: convert -B|--break-rewrites","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-07T10:33:18Z","receivedAt":"2019-02-07T10:34: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 | 62 ++++++++++++++++++++++++++++++++++------------------------\n 1 file changed, 36 insertions(+), 26 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 8df396cb9a..d2139082b7 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4841,6 +4841,30 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)\n \treturn 1;\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+\tint *break_opt = opt->value;\n+\tint opt1, opt2;\n+\n+\tBUG_ON_OPT_NEG(unset);\n+\tif (!arg)\n+\t\targ = \"\";\n+\topt1 = parse_rename_score(&arg);\n+\tif (*arg == 0)\n+\t\topt2 = 0;\n+\telse if (*arg != '/')\n+\t\treturn error(_(\"%s expects <n>/<m> form\"), opt->long_name);\n+\telse {\n+\t\targ++;\n+\t\topt2 = parse_rename_score(&arg);\n+\t}\n+\tif (*arg != 0)\n+\t\treturn error(_(\"%s expects <n>/<m> form\"), opt->long_name);\n+\t*break_opt = opt1 | (opt2 << 16);\n+\treturn 0;\n+}\n+\n static int diff_opt_char(const struct option *opt,\n \t\t\t const char *arg, int unset)\n {\n@@ -5011,6 +5035,12 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       N_(\"specify the character to indicate a context instead of ' '\"),\n \t\t\t       PARSE_OPT_NONEG, diff_opt_char),\n \n+\t\tOPT_GROUP(N_(\"Diff rename options\")),\n+\t\tOPT_CALLBACK_F('B', \"break-rewrites\", &options->break_opt, N_(\"<n>[/<m>]\"),\n+\t\t\t       N_(\"break complete rewrite changes into pairs of delete and create\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n+\t\t\t       diff_opt_break_rewrites),\n+\n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n \t\t  N_(\"Output to a specific file\"),\n@@ -5044,12 +5074,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* renames options */\n-\tif (starts_with(arg, \"-B\") ||\n-\t\t skip_to_optional_arg(arg, \"--break-rewrites\", NULL)) {\n-\t\tif ((options->break_opt = diff_scoreopt_parse(arg)) == -1)\n-\t\t\treturn error(\"invalid argument to -B: %s\", arg+2);\n-\t}\n-\telse if (starts_with(arg, \"-M\") ||\n+\tif (starts_with(arg, \"-M\") ||\n \t\t skip_to_optional_arg(arg, \"--find-renames\", NULL)) {\n \t\tif ((options->rename_score = diff_scoreopt_parse(arg)) == -1)\n \t\t\treturn error(\"invalid argument to -M: %s\", arg+2);\n@@ -5328,17 +5353,14 @@ int parse_rename_score(const char **cp_p)\n \n static int diff_scoreopt_parse(const char *opt)\n {\n-\tint opt1, opt2, cmd;\n+\tint opt1, cmd;\n \n \tif (*opt++ != '-')\n \t\treturn -1;\n \tcmd = *opt++;\n \tif (cmd == '-') {\n \t\t/* convert the long-form arguments into short-form versions */\n-\t\tif (skip_prefix(opt, \"break-rewrites\", &opt)) {\n-\t\t\tif (*opt == 0 || *opt++ == '=')\n-\t\t\t\tcmd = 'B';\n-\t\t} else if (skip_prefix(opt, \"find-copies\", &opt)) {\n+\t\tif (skip_prefix(opt, \"find-copies\", &opt)) {\n \t\t\tif (*opt == 0 || *opt++ == '=')\n \t\t\t\tcmd = 'C';\n \t\t} else if (skip_prefix(opt, \"find-renames\", &opt)) {\n@@ -5346,25 +5368,13 @@ static int diff_scoreopt_parse(const char *opt)\n \t\t\t\tcmd = 'M';\n \t\t}\n \t}\n-\tif (cmd != 'M' && cmd != 'C' && cmd != 'B')\n-\t\treturn -1; /* that is not a -M, -C, or -B option */\n+\tif (cmd != 'M' && cmd != 'C')\n+\t\treturn -1; /* that is not a -M, or -C option */\n \n \topt1 = parse_rename_score(&opt);\n-\tif (cmd != 'B')\n-\t\topt2 = 0;\n-\telse {\n-\t\tif (*opt == 0)\n-\t\t\topt2 = 0;\n-\t\telse if (*opt != '/')\n-\t\t\treturn -1; /* we expect -B80/99 or -B80 */\n-\t\telse {\n-\t\t\topt++;\n-\t\t\topt2 = parse_rename_score(&opt);\n-\t\t}\n-\t}\n \tif (*opt != 0)\n \t\treturn -1;\n-\treturn opt1 | (opt2 << 16);\n+\treturn opt1;\n }\n \n struct diff_queue_struct diff_queued_diff;\n-- \n2.20.1.682.gd5861c6d90\n\n"},{"id":"368691","messageId":"20190207103326.10693-15-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"[PATCH 14/21] diff.c: convert -M|--find-renames","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-07T10:33:19Z","receivedAt":"2019-02-07T10:34: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 | 35 +++++++++++++++++++++++------------\n 1 file changed, 23 insertions(+), 12 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex d2139082b7..2c904e0526 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4909,6 +4909,22 @@ static int diff_opt_dirstat(const struct option *opt,\n \treturn 0;\n }\n \n+static int diff_opt_find_renames(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 = \"\";\n+\toptions->rename_score = parse_rename_score(&arg);\n+\tif (*arg != 0)\n+\t\treturn error(_(\"invalid argument to %s\"), opt->long_name);\n+\n+\toptions->detect_rename = DIFF_DETECT_RENAME;\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@@ -5040,6 +5056,10 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       N_(\"break complete rewrite changes into pairs of delete and create\"),\n \t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n \t\t\t       diff_opt_break_rewrites),\n+\t\tOPT_CALLBACK_F('M', \"find-renames\", options, N_(\"<n>\"),\n+\t\t\t       N_(\"detect renames\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n+\t\t\t       diff_opt_find_renames),\n \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n@@ -5074,13 +5094,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* renames options */\n-\tif (starts_with(arg, \"-M\") ||\n-\t\t skip_to_optional_arg(arg, \"--find-renames\", NULL)) {\n-\t\tif ((options->rename_score = diff_scoreopt_parse(arg)) == -1)\n-\t\t\treturn error(\"invalid argument to -M: %s\", arg+2);\n-\t\toptions->detect_rename = DIFF_DETECT_RENAME;\n-\t}\n-\telse if (!strcmp(arg, \"-D\") || !strcmp(arg, \"--irreversible-delete\")) {\n+\tif (!strcmp(arg, \"-D\") || !strcmp(arg, \"--irreversible-delete\")) {\n \t\toptions->irreversible_delete = 1;\n \t}\n \telse if (starts_with(arg, \"-C\") ||\n@@ -5363,13 +5377,10 @@ static int diff_scoreopt_parse(const char *opt)\n \t\tif (skip_prefix(opt, \"find-copies\", &opt)) {\n \t\t\tif (*opt == 0 || *opt++ == '=')\n \t\t\t\tcmd = 'C';\n-\t\t} else if (skip_prefix(opt, \"find-renames\", &opt)) {\n-\t\t\tif (*opt == 0 || *opt++ == '=')\n-\t\t\t\tcmd = 'M';\n \t\t}\n \t}\n-\tif (cmd != 'M' && cmd != 'C')\n-\t\treturn -1; /* that is not a -M, or -C option */\n+\tif (cmd != 'C')\n+\t\treturn -1; /* that is not a -M option */\n \n \topt1 = parse_rename_score(&opt);\n \tif (*opt != 0)\n-- \n2.20.1.682.gd5861c6d90\n\n"},{"id":"368692","messageId":"20190207103326.10693-16-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"[PATCH 15/21] diff.c: convert -D|--irreversible-delete","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-07T10:33:20Z","receivedAt":"2019-02-07T10:35: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 | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 2c904e0526..e51f6b3005 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5060,6 +5060,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       N_(\"detect renames\"),\n \t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n \t\t\t       diff_opt_find_renames),\n+\t\tOPT_SET_INT_F('D', \"irreversible-delete\", &options->irreversible_delete,\n+\t\t\t      N_(\"omit the preimage for deletes\"),\n+\t\t\t      1, PARSE_OPT_NONEG),\n \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n@@ -5094,10 +5097,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* renames options */\n-\tif (!strcmp(arg, \"-D\") || !strcmp(arg, \"--irreversible-delete\")) {\n-\t\toptions->irreversible_delete = 1;\n-\t}\n-\telse if (starts_with(arg, \"-C\") ||\n+\tif (starts_with(arg, \"-C\") ||\n \t\t skip_to_optional_arg(arg, \"--find-copies\", NULL)) {\n \t\tif (options->detect_rename == DIFF_DETECT_COPY)\n \t\t\toptions->flags.find_copies_harder = 1;\n-- \n2.20.1.682.gd5861c6d90\n\n"},{"id":"368693","messageId":"20190207103326.10693-17-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"[PATCH 16/21] diff.c: convert -C|--find-copies","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-07T10:33:21Z","receivedAt":"2019-02-07T10:35:06Z","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 | 59 +++++++++++++++++++++++++---------------------------------\n 1 file changed, 25 insertions(+), 34 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex e51f6b3005..35bac115cc 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4617,8 +4617,6 @@ static int opt_arg(const char *arg, int arg_short, const char *arg_long, int *va\n \treturn 1;\n }\n \n-static int diff_scoreopt_parse(const char *opt);\n-\n static inline int short_opt(char opt, const char **argv,\n \t\t\t    const char **optarg)\n {\n@@ -4909,6 +4907,26 @@ static int diff_opt_dirstat(const struct option *opt,\n \treturn 0;\n }\n \n+static int diff_opt_find_copies(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+\tif (!arg)\n+\t\targ = \"\";\n+\toptions->rename_score = parse_rename_score(&arg);\n+\tif (*arg != 0)\n+\t\treturn error(_(\"invalid argument to %s\"), opt->long_name);\n+\n+\tif (options->detect_rename == DIFF_DETECT_COPY)\n+\t\toptions->flags.find_copies_harder = 1;\n+\telse\n+\t\toptions->detect_rename = DIFF_DETECT_COPY;\n+\n+\treturn 0;\n+}\n+\n static int diff_opt_find_renames(const struct option *opt,\n \t\t\t\t const char *arg, int unset)\n {\n@@ -5063,6 +5081,10 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_SET_INT_F('D', \"irreversible-delete\", &options->irreversible_delete,\n \t\t\t      N_(\"omit the preimage for deletes\"),\n \t\t\t      1, PARSE_OPT_NONEG),\n+\t\tOPT_CALLBACK_F('C', \"find-copies\", options, N_(\"<n>\"),\n+\t\t\t       N_(\"detect copies\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n+\t\t\t       diff_opt_find_copies),\n \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n@@ -5097,15 +5119,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* renames options */\n-\tif (starts_with(arg, \"-C\") ||\n-\t\t skip_to_optional_arg(arg, \"--find-copies\", NULL)) {\n-\t\tif (options->detect_rename == DIFF_DETECT_COPY)\n-\t\t\toptions->flags.find_copies_harder = 1;\n-\t\tif ((options->rename_score = diff_scoreopt_parse(arg)) == -1)\n-\t\t\treturn error(\"invalid argument to -C: %s\", arg+2);\n-\t\toptions->detect_rename = DIFF_DETECT_COPY;\n-\t}\n-\telse if (!strcmp(arg, \"--no-renames\"))\n+\tif (!strcmp(arg, \"--no-renames\"))\n \t\toptions->detect_rename = 0;\n \telse if (!strcmp(arg, \"--rename-empty\"))\n \t\toptions->flags.rename_empty = 1;\n@@ -5365,29 +5379,6 @@ int parse_rename_score(const char **cp_p)\n \treturn (int)((num >= scale) ? MAX_SCORE : (MAX_SCORE * num / scale));\n }\n \n-static int diff_scoreopt_parse(const char *opt)\n-{\n-\tint opt1, cmd;\n-\n-\tif (*opt++ != '-')\n-\t\treturn -1;\n-\tcmd = *opt++;\n-\tif (cmd == '-') {\n-\t\t/* convert the long-form arguments into short-form versions */\n-\t\tif (skip_prefix(opt, \"find-copies\", &opt)) {\n-\t\t\tif (*opt == 0 || *opt++ == '=')\n-\t\t\t\tcmd = 'C';\n-\t\t}\n-\t}\n-\tif (cmd != 'C')\n-\t\treturn -1; /* that is not a -M option */\n-\n-\topt1 = parse_rename_score(&opt);\n-\tif (*opt != 0)\n-\t\treturn -1;\n-\treturn opt1;\n-}\n-\n struct diff_queue_struct diff_queued_diff;\n \n void diff_q(struct diff_queue_struct *queue, struct diff_filepair *dp)\n-- \n2.20.1.682.gd5861c6d90\n\n"},{"id":"368694","messageId":"20190207103326.10693-18-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"[PATCH 17/21] diff.c: convert --find-copies-harder","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-07T10:33:22Z","receivedAt":"2019-02-07T10:35:11Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"--no-find-copies-harder is also added on purpose (because I don't see\nwhy we should not have the --no- version for this)\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 35bac115cc..abb1566f95 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5085,6 +5085,8 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       N_(\"detect copies\"),\n \t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n \t\t\t       diff_opt_find_copies),\n+\t\tOPT_BOOL(0, \"find-copies-harder\", &options->flags.find_copies_harder,\n+\t\t\t N_(\"use unmodified files as source to find copies\")),\n \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n@@ -5191,8 +5193,6 @@ int diff_opt_parse(struct diff_options *options,\n \t\toptions->flags.text = 1;\n \telse if (!strcmp(arg, \"-R\"))\n \t\toptions->flags.reverse_diff = 1;\n-\telse if (!strcmp(arg, \"--find-copies-harder\"))\n-\t\toptions->flags.find_copies_harder = 1;\n \telse if (!strcmp(arg, \"--follow\"))\n \t\toptions->flags.follow_renames = 1;\n \telse if (!strcmp(arg, \"--no-follow\")) {\n-- \n2.20.1.682.gd5861c6d90\n\n"},{"id":"368695","messageId":"20190207103326.10693-19-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"[PATCH 18/21] diff.c: convert --no-renames|--[no--rename-empty","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-07T10:33:23Z","receivedAt":"2019-02-07T10:35:16Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"For --rename-empty, see 90d43b0768 (teach diffcore-rename to\noptionally ignore empty content - 2012-03-22) for more information.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Documentation/diff-options.txt |  3 +++\n diff.c                         | 13 ++++++-------\n 2 files changed, 9 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt\nindex d3e8d634b2..4c0d40881b 100644\n--- a/Documentation/diff-options.txt\n+++ b/Documentation/diff-options.txt\n@@ -392,6 +392,9 @@ endif::git-format-patch[]\n \tTurn off rename detection, even when the configuration\n \tfile gives the default to do so.\n \n+--[no-]rename-empty::\n+\tWhether to use empty blobs as rename source.\n+\n ifndef::git-format-patch[]\n --check::\n \tWarn if changes introduce conflict markers or whitespace errors.\ndiff --git a/diff.c b/diff.c\nindex abb1566f95..d423a06b41 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5087,6 +5087,11 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       diff_opt_find_copies),\n \t\tOPT_BOOL(0, \"find-copies-harder\", &options->flags.find_copies_harder,\n \t\t\t N_(\"use unmodified files as source to find copies\")),\n+\t\tOPT_SET_INT_F(0, \"no-renames\", &options->detect_rename,\n+\t\t\t      N_(\"disable rename detection\"),\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 \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n@@ -5121,13 +5126,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* renames options */\n-\tif (!strcmp(arg, \"--no-renames\"))\n-\t\toptions->detect_rename = 0;\n-\telse if (!strcmp(arg, \"--rename-empty\"))\n-\t\toptions->flags.rename_empty = 1;\n-\telse if (!strcmp(arg, \"--no-rename-empty\"))\n-\t\toptions->flags.rename_empty = 0;\n-\telse if (skip_to_optional_arg_default(arg, \"--relative\", &arg, NULL)) {\n+\tif (skip_to_optional_arg_default(arg, \"--relative\", &arg, NULL)) {\n \t\toptions->flags.relative_name = 1;\n \t\tif (arg)\n \t\t\toptions->prefix = arg;\n-- \n2.20.1.682.gd5861c6d90\n\n"},{"id":"368696","messageId":"20190207103326.10693-20-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"[PATCH 19/21] diff.c: convert --relative","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-07T10:33:24Z","receivedAt":"2019-02-07T10:35:21Z","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, 17 insertions(+), 8 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex d423a06b41..b9c267a199 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4960,6 +4960,18 @@ static enum parse_opt_result diff_opt_output(struct parse_opt_ctx_t *ctx,\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+\tstruct diff_options *options = opt->value;\n+\n+\tBUG_ON_OPT_NEG(unset);\n+\toptions->flags.relative_name = 1;\n+\tif (arg)\n+\t\toptions->prefix = arg;\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@@ -5094,6 +5106,10 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t N_(\"use empty blobs as rename source\")),\n \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n+\t\tOPT_CALLBACK_F(0, \"relative\", options, N_(\"<prefix>\"),\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\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@@ -5125,15 +5141,8 @@ int diff_opt_parse(struct diff_options *options,\n \tif (ac)\n \t\treturn ac;\n \n-\t/* renames options */\n-\tif (skip_to_optional_arg_default(arg, \"--relative\", &arg, NULL)) {\n-\t\toptions->flags.relative_name = 1;\n-\t\tif (arg)\n-\t\t\toptions->prefix = arg;\n-\t}\n-\n \t/* xdiff options */\n-\telse if (!strcmp(arg, \"--minimal\"))\n+\tif (!strcmp(arg, \"--minimal\"))\n \t\tDIFF_XDL_SET(options, NEED_MINIMAL);\n \telse if (!strcmp(arg, \"--no-minimal\"))\n \t\tDIFF_XDL_CLR(options, NEED_MINIMAL);\n-- \n2.20.1.682.gd5861c6d90\n\n"},{"id":"368697","messageId":"20190207103326.10693-21-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"[PATCH 20/21] diff.c: convert --[no-]minimal","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-07T10:33:25Z","receivedAt":"2019-02-07T10:35:26Z","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 | 11 ++++++-----\n 1 file changed, 6 insertions(+), 5 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex b9c267a199..33492e754f 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5105,6 +5105,11 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BOOL(0, \"rename-empty\", &options->flags.rename_empty,\n \t\t\t N_(\"use empty blobs as rename source\")),\n \n+\t\tOPT_GROUP(N_(\"Diff algorithm options\")),\n+\t\tOPT_BIT(0, \"minimal\", &options->xdl_opts,\n+\t\t\tN_(\"produce the smallest possible diff\"),\n+\t\t\tXDF_NEED_MINIMAL),\n+\n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\tOPT_CALLBACK_F(0, \"relative\", options, N_(\"<prefix>\"),\n \t\t\t       N_(\"when run from subdir, exclude changes outside and show relative paths\"),\n@@ -5142,11 +5147,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* xdiff options */\n-\tif (!strcmp(arg, \"--minimal\"))\n-\t\tDIFF_XDL_SET(options, NEED_MINIMAL);\n-\telse if (!strcmp(arg, \"--no-minimal\"))\n-\t\tDIFF_XDL_CLR(options, NEED_MINIMAL);\n-\telse if (!strcmp(arg, \"-w\") || !strcmp(arg, \"--ignore-all-space\"))\n+\tif (!strcmp(arg, \"-w\") || !strcmp(arg, \"--ignore-all-space\"))\n \t\tDIFF_XDL_SET(options, IGNORE_WHITESPACE);\n \telse if (!strcmp(arg, \"-b\") || !strcmp(arg, \"--ignore-space-change\"))\n \t\tDIFF_XDL_SET(options, IGNORE_WHITESPACE_CHANGE);\n-- \n2.20.1.682.gd5861c6d90\n\n"},{"id":"368698","messageId":"20190207103326.10693-22-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"[PATCH 21/21] diff.c: convert --ignore-some-changes","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-07T10:33:26Z","receivedAt":"2019-02-07T10:35:31Z","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 | 27 ++++++++++++++++-----------\n 1 file changed, 16 insertions(+), 11 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 33492e754f..a63ee4a44d 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5109,6 +5109,21 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT(0, \"minimal\", &options->xdl_opts,\n \t\t\tN_(\"produce the smallest possible diff\"),\n \t\t\tXDF_NEED_MINIMAL),\n+\t\tOPT_BIT_F('w', \"ignore-all-space\", &options->xdl_opts,\n+\t\t\t  N_(\"ignore whitespace when comparing lines\"),\n+\t\t\t  XDF_IGNORE_WHITESPACE, PARSE_OPT_NONEG),\n+\t\tOPT_BIT_F('b', \"ignore-space-change\", &options->xdl_opts,\n+\t\t\t  N_(\"ignore changes in amount of whitespace\"),\n+\t\t\t  XDF_IGNORE_WHITESPACE_CHANGE, PARSE_OPT_NONEG),\n+\t\tOPT_BIT_F(0, \"ignore-space-at-eol\", &options->xdl_opts,\n+\t\t\t  N_(\"ignore changes in whitespace at EOL\"),\n+\t\t\t  XDF_IGNORE_WHITESPACE_AT_EOL, PARSE_OPT_NONEG),\n+\t\tOPT_BIT_F(0, \"ignore-cr-at-eol\", &options->xdl_opts,\n+\t\t\t  N_(\"ignore carrier-return at the end of line\"),\n+\t\t\t  XDF_IGNORE_CR_AT_EOL, PARSE_OPT_NONEG),\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 \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\tOPT_CALLBACK_F(0, \"relative\", options, N_(\"<prefix>\"),\n@@ -5147,17 +5162,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* xdiff options */\n-\tif (!strcmp(arg, \"-w\") || !strcmp(arg, \"--ignore-all-space\"))\n-\t\tDIFF_XDL_SET(options, IGNORE_WHITESPACE);\n-\telse if (!strcmp(arg, \"-b\") || !strcmp(arg, \"--ignore-space-change\"))\n-\t\tDIFF_XDL_SET(options, IGNORE_WHITESPACE_CHANGE);\n-\telse if (!strcmp(arg, \"--ignore-space-at-eol\"))\n-\t\tDIFF_XDL_SET(options, IGNORE_WHITESPACE_AT_EOL);\n-\telse if (!strcmp(arg, \"--ignore-cr-at-eol\"))\n-\t\tDIFF_XDL_SET(options, IGNORE_CR_AT_EOL);\n-\telse if (!strcmp(arg, \"--ignore-blank-lines\"))\n-\t\tDIFF_XDL_SET(options, IGNORE_BLANK_LINES);\n-\telse if (!strcmp(arg, \"--indent-heuristic\"))\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-- \n2.20.1.682.gd5861c6d90\n\n"},{"id":"368717","messageId":"20190207184300.GN10587@szeder.dev","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"Re: [PATCH 00/21] nd/diff-parseopt part 2","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2019-02-07T18:43:00Z","receivedAt":"2019-02-07T18:43:06Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Thu, Feb 07, 2019 at 05:33:05PM +0700, Nguyễn Thái Ngọc Duy wrote:\n> Nguyễn Thái Ngọc Duy (21):\n>   diff.c: convert --patch-with-raw\n>   diff.c: convert --numstat and --shortstat\n>   diff.c: convert --dirstat and friends\n>   diff.c: convert --check\n>   diff.c: convert --summary\n>   diff.c: convert --patch-with-stat\n>   diff.c: convert --name-only\n>   diff.c: convert --name-status\n>   diff.c: convert -s|--no-patch\n>   diff.c: convert --stat*\n>   diff.c: convert --[no-]compact-summary\n>   diff.c: convert --output-*\n>   diff.c: convert -B|--break-rewrites\n>   diff.c: convert -M|--find-renames\n>   diff.c: convert -D|--irreversible-delete\n>   diff.c: convert -C|--find-copies\n>   diff.c: convert --find-copies-harder\n>   diff.c: convert --no-renames|--[no--rename-empty\n>   diff.c: convert --relative\n>   diff.c: convert --[no-]minimal\n>   diff.c: convert --ignore-some-changes\n\nNit: convert to what?  Perhaps a 's/$/ to parse-options/' would\nimprove the shortlog/oneline output.\n\n"},{"id":"369016","messageId":"xmqqo97ii714.fsf@gitster-ct.c.googlers.com","threadId":"50424","inReplyTo":"20190207184300.GN10587@szeder.dev","subject":"Re: [PATCH 00/21] nd/diff-parseopt part 2","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-02-11T17:12:07Z","receivedAt":"2019-02-11T17:12:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"SZEDER Gábor <szeder.dev@gmail.com> writes:\n\n> On Thu, Feb 07, 2019 at 05:33:05PM +0700, Nguyễn Thái Ngọc Duy wrote:\n>> Nguyễn Thái Ngọc Duy (21):\n>>   diff.c: convert --patch-with-raw\n>>   diff.c: convert --numstat and --shortstat\n>>   diff.c: convert --dirstat and friends\n>>   diff.c: convert --check\n>>   ...\n>>   diff.c: convert --no-renames|--[no--rename-empty\n>>   diff.c: convert --relative\n>>   diff.c: convert --[no-]minimal\n>>   diff.c: convert --ignore-some-changes\n>\n> Nit: convert to what?  Perhaps a 's/$/ to parse-options/' would\n> improve the shortlog/oneline output.\n\nBut that would be hidden by getting pushed far to the right.\n\nI am wondering if we can do something clever with the <area>: prefix.\nFor a series like this one, the shortlog output may be better off if\na short token that clearly identifies the topic is used there, e.g.\n\n    diff-parseopt: convert --patch-with-raw\n    diff-parseopt: convert --numstat and --shortstat\n    ...\n\nor even\n\n    diff-parseopt: --patch-with-raw\n\nperhaps.\n"},{"id":"369020","messageId":"xmqqftsui35j.fsf@gitster-ct.c.googlers.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"Re: [PATCH 00/21] nd/diff-parseopt part 2","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-02-11T18:35:52Z","receivedAt":"2019-02-11T18:35:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> \"What's cooking\" mails seem to indicate that the series will be cooked\n> in full there then landed on master later. So here's the second part.\n\nAh, I should have responded to this part.\n\nI think that the part 1 was reviewed and found reasonable, and we\ncould merge them to 'master'.  But because they themselves won't do\nmuch good until completed, I'd rather refrain from including them in\na half-done form in the upcoming release.  In other words, do not be\nsurprised if you see these early part(s) land on 'master' before the\nremainder after the upcoming release.\n\nThanks.\n\n"},{"id":"369436","messageId":"20190216113346.25000-1-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"[PATCH v2 00/21] nd/diff-parseopt part 2","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:33:25Z","receivedAt":"2019-02-16T11:34:11Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"v2 changes the subject line to help clarify in \"git log --oneline\"\n\nNguyễn Thái Ngọc Duy (21):\n  diff-parseopt: convert --patch-with-raw\n  diff-parseopt: convert --numstat and --shortstat\n  diff-parseopt: convert --dirstat and friends\n  diff-parseopt: convert --check\n  diff-parseopt: convert --summary\n  diff-parseopt: convert --patch-with-stat\n  diff-parseopt: convert --name-only\n  diff-parseopt: convert --name-status\n  diff-parseopt: convert -s|--no-patch\n  diff-parseopt: convert --stat*\n  diff-parseopt: convert --[no-]compact-summary\n  diff-parseopt: convert --output-*\n  diff-parseopt: convert -B|--break-rewrites\n  diff-parseopt: convert -M|--find-renames\n  diff-parseopt: convert -D|--irreversible-delete\n  diff-parseopt: convert -C|--find-copies\n  diff-parseopt: convert --find-copies-harder\n  diff-parseopt: convert --no-renames|--[no--rename-empty\n  diff-parseopt: convert --relative\n  diff-parseopt: convert --[no-]minimal\n  diff-parseopt: convert --ignore-some-changes\n\n Documentation/diff-options.txt |  20 ++\n diff.c                         | 510 +++++++++++++++++++--------------\n 2 files changed, 319 insertions(+), 211 deletions(-)\n\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369437","messageId":"20190216113346.25000-2-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113346.25000-1-pclouds@gmail.com","subject":"[PATCH v2 01/21] diff-parseopt: convert --patch-with-raw","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:33:26Z","receivedAt":"2019-02-16T11:34:16Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 9 +++++----\n 1 file changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 4bc9df7362..12e333c67f 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4901,6 +4901,10 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT_F(0, \"raw\", &options->output_format,\n \t\t\t  N_(\"generate the diff in raw format\"),\n \t\t\t  DIFF_FORMAT_RAW, PARSE_OPT_NONEG),\n+\t\tOPT_BITOP(0, \"patch-with-raw\", &options->output_format,\n+\t\t\t  N_(\"synonym for '-p --raw'\"),\n+\t\t\t  DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW,\n+\t\t\t  DIFF_FORMAT_NO_OUTPUT),\n \t\tOPT_END()\n \t};\n \n@@ -4929,10 +4933,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--patch-with-raw\")) {\n-\t\tenable_patch_output(&options->output_format);\n-\t\toptions->output_format |= DIFF_FORMAT_RAW;\n-\t} else if (!strcmp(arg, \"--numstat\"))\n+\tif (!strcmp(arg, \"--numstat\"))\n \t\toptions->output_format |= DIFF_FORMAT_NUMSTAT;\n \telse if (!strcmp(arg, \"--shortstat\"))\n \t\toptions->output_format |= DIFF_FORMAT_SHORTSTAT;\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369438","messageId":"20190216113346.25000-3-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113346.25000-1-pclouds@gmail.com","subject":"[PATCH v2 02/21] diff-parseopt: convert --numstat and --shortstat","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:33:27Z","receivedAt":"2019-02-16T11:34:21Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 12 +++++++-----\n 1 file changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 12e333c67f..419b6ac4ae 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4905,6 +4905,12 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t  N_(\"synonym for '-p --raw'\"),\n \t\t\t  DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW,\n \t\t\t  DIFF_FORMAT_NO_OUTPUT),\n+\t\tOPT_BIT_F(0, \"numstat\", &options->output_format,\n+\t\t\t  N_(\"machine friendly --stat\"),\n+\t\t\t  DIFF_FORMAT_NUMSTAT, PARSE_OPT_NONEG),\n+\t\tOPT_BIT_F(0, \"shortstat\", &options->output_format,\n+\t\t\t  N_(\"output only the last line of --stat\"),\n+\t\t\t  DIFF_FORMAT_SHORTSTAT, PARSE_OPT_NONEG),\n \t\tOPT_END()\n \t};\n \n@@ -4933,11 +4939,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--numstat\"))\n-\t\toptions->output_format |= DIFF_FORMAT_NUMSTAT;\n-\telse if (!strcmp(arg, \"--shortstat\"))\n-\t\toptions->output_format |= DIFF_FORMAT_SHORTSTAT;\n-\telse if (skip_prefix(arg, \"-X\", &arg) ||\n+\tif (skip_prefix(arg, \"-X\", &arg) ||\n \t\t skip_to_optional_arg(arg, \"--dirstat\", &arg))\n \t\treturn parse_dirstat_opt(options, arg);\n \telse if (!strcmp(arg, \"--cumulative\"))\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369439","messageId":"20190216113346.25000-4-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113346.25000-1-pclouds@gmail.com","subject":"[PATCH v2 03/21] diff-parseopt: convert --dirstat and friends","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:33:28Z","receivedAt":"2019-02-16T11:34:26Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/diff-options.txt |  7 ++++++\n diff.c                         | 39 +++++++++++++++++++++++++---------\n 2 files changed, 36 insertions(+), 10 deletions(-)\n\ndiff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt\nindex 0711734b12..058d93ec4f 100644\n--- a/Documentation/diff-options.txt\n+++ b/Documentation/diff-options.txt\n@@ -148,6 +148,7 @@ These parameters can also be set individually with `--stat-width=<width>`,\n \tnumber of modified files, as well as number of added and deleted\n \tlines.\n \n+-X<param1,param2,...>::\n --dirstat[=<param1,param2,...>]::\n \tOutput the distribution of relative amount of changes for each\n \tsub-directory. The behavior of `--dirstat` can be customized by\n@@ -192,6 +193,12 @@ directories with less than 10% of the total amount of changed files,\n and accumulating child directory counts in the parent directories:\n `--dirstat=files,10,cumulative`.\n \n+--cumulative::\n+\tSynonym for --dirstat=cumulative\n+\n+--dirstat-by-file[=<param1,param2>...]::\n+\tSynonym for --dirstat=files,param1,param2...\n+\n --summary::\n \tOutput a condensed summary of extended header information\n \tsuch as creations, renames and mode changes.\ndiff --git a/diff.c b/diff.c\nindex 419b6ac4ae..1cdbe8e688 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4867,6 +4867,22 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)\n \treturn 1;\n }\n \n+static int diff_opt_dirstat(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 (!strcmp(opt->long_name, \"cumulative\")) {\n+\t\tif (arg)\n+\t\t\tBUG(\"how come --cumulative take a value?\");\n+\t\targ = \"cumulative\";\n+\t} else if (!strcmp(opt->long_name, \"dirstat-by-file\"))\n+\t\tparse_dirstat_opt(options, \"files\");\n+\tparse_dirstat_opt(options, arg ? arg : \"\");\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@@ -4911,6 +4927,18 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT_F(0, \"shortstat\", &options->output_format,\n \t\t\t  N_(\"output only the last line of --stat\"),\n \t\t\t  DIFF_FORMAT_SHORTSTAT, PARSE_OPT_NONEG),\n+\t\tOPT_CALLBACK_F('X', \"dirstat\", options, N_(\"<param1,param2>...\"),\n+\t\t\t       N_(\"output the distribution of relative amount of changes for each sub-directory\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n+\t\t\t       diff_opt_dirstat),\n+\t\tOPT_CALLBACK_F(0, \"cumulative\", options, NULL,\n+\t\t\t       N_(\"synonym for --dirstat=cumulative\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_NOARG,\n+\t\t\t       diff_opt_dirstat),\n+\t\tOPT_CALLBACK_F(0, \"dirstat-by-file\", options, N_(\"<param1,param2>...\"),\n+\t\t\t       N_(\"synonym for --dirstat=files,param1,param2...\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n+\t\t\t       diff_opt_dirstat),\n \t\tOPT_END()\n \t};\n \n@@ -4939,16 +4967,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (skip_prefix(arg, \"-X\", &arg) ||\n-\t\t skip_to_optional_arg(arg, \"--dirstat\", &arg))\n-\t\treturn parse_dirstat_opt(options, arg);\n-\telse if (!strcmp(arg, \"--cumulative\"))\n-\t\treturn parse_dirstat_opt(options, \"cumulative\");\n-\telse if (skip_to_optional_arg(arg, \"--dirstat-by-file\", &arg)) {\n-\t\tparse_dirstat_opt(options, \"files\");\n-\t\treturn parse_dirstat_opt(options, arg);\n-\t}\n-\telse if (!strcmp(arg, \"--check\"))\n+\tif (!strcmp(arg, \"--check\"))\n \t\toptions->output_format |= DIFF_FORMAT_CHECKDIFF;\n \telse if (!strcmp(arg, \"--summary\"))\n \t\toptions->output_format |= DIFF_FORMAT_SUMMARY;\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369440","messageId":"20190216113346.25000-5-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113346.25000-1-pclouds@gmail.com","subject":"[PATCH v2 04/21] diff-parseopt: convert --check","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:33:29Z","receivedAt":"2019-02-16T11:34:30Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 1cdbe8e688..5e16082091 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4939,6 +4939,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       N_(\"synonym for --dirstat=files,param1,param2...\"),\n \t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n \t\t\t       diff_opt_dirstat),\n+\t\tOPT_BIT_F(0, \"check\", &options->output_format,\n+\t\t\t  N_(\"warn if changes introduce conflict markers or whitespace errors\"),\n+\t\t\t  DIFF_FORMAT_CHECKDIFF, PARSE_OPT_NONEG),\n \t\tOPT_END()\n \t};\n \n@@ -4967,9 +4970,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--check\"))\n-\t\toptions->output_format |= DIFF_FORMAT_CHECKDIFF;\n-\telse if (!strcmp(arg, \"--summary\"))\n+\tif (!strcmp(arg, \"--summary\"))\n \t\toptions->output_format |= DIFF_FORMAT_SUMMARY;\n \telse if (!strcmp(arg, \"--patch-with-stat\")) {\n \t\tenable_patch_output(&options->output_format);\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369441","messageId":"20190216113346.25000-6-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113346.25000-1-pclouds@gmail.com","subject":"[PATCH v2 05/21] diff-parseopt: convert --summary","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:33:30Z","receivedAt":"2019-02-16T11:34:35Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 5e16082091..0276f25200 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4942,6 +4942,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT_F(0, \"check\", &options->output_format,\n \t\t\t  N_(\"warn if changes introduce conflict markers or whitespace errors\"),\n \t\t\t  DIFF_FORMAT_CHECKDIFF, PARSE_OPT_NONEG),\n+\t\tOPT_BIT_F(0, \"summary\", &options->output_format,\n+\t\t\t  N_(\"condensed summary such as creations, renames and mode changes\"),\n+\t\t\t  DIFF_FORMAT_SUMMARY, PARSE_OPT_NONEG),\n \t\tOPT_END()\n \t};\n \n@@ -4970,9 +4973,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--summary\"))\n-\t\toptions->output_format |= DIFF_FORMAT_SUMMARY;\n-\telse if (!strcmp(arg, \"--patch-with-stat\")) {\n+\tif (!strcmp(arg, \"--patch-with-stat\")) {\n \t\tenable_patch_output(&options->output_format);\n \t\toptions->output_format |= DIFF_FORMAT_DIFFSTAT;\n \t} else if (!strcmp(arg, \"--name-only\"))\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369442","messageId":"20190216113346.25000-7-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113346.25000-1-pclouds@gmail.com","subject":"[PATCH v2 06/21] diff-parseopt: convert --patch-with-stat","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:33:31Z","receivedAt":"2019-02-16T11:34:40Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 9 +++++----\n 1 file changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 0276f25200..b9811aefef 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4921,6 +4921,10 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t  N_(\"synonym for '-p --raw'\"),\n \t\t\t  DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW,\n \t\t\t  DIFF_FORMAT_NO_OUTPUT),\n+\t\tOPT_BITOP(0, \"patch-with-stat\", &options->output_format,\n+\t\t\t  N_(\"synonym for '-p --stat'\"),\n+\t\t\t  DIFF_FORMAT_PATCH | DIFF_FORMAT_DIFFSTAT,\n+\t\t\t  DIFF_FORMAT_NO_OUTPUT),\n \t\tOPT_BIT_F(0, \"numstat\", &options->output_format,\n \t\t\t  N_(\"machine friendly --stat\"),\n \t\t\t  DIFF_FORMAT_NUMSTAT, PARSE_OPT_NONEG),\n@@ -4973,10 +4977,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--patch-with-stat\")) {\n-\t\tenable_patch_output(&options->output_format);\n-\t\toptions->output_format |= DIFF_FORMAT_DIFFSTAT;\n-\t} else if (!strcmp(arg, \"--name-only\"))\n+\tif (!strcmp(arg, \"--name-only\"))\n \t\toptions->output_format |= DIFF_FORMAT_NAME;\n \telse if (!strcmp(arg, \"--name-status\"))\n \t\toptions->output_format |= DIFF_FORMAT_NAME_STATUS;\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369443","messageId":"20190216113655.25728-1-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190207103326.10693-1-pclouds@gmail.com","subject":"[PATCH v3 00/21] nd/diff-parseopt part 2","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:36:34Z","receivedAt":"2019-02-16T11:37:13Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"v3 is the same as v2 except I will not delete the patches while it's\nstill sending, grr...\n\nNguyễn Thái Ngọc Duy (21):\n  diff-parseopt: convert --patch-with-raw\n  diff-parseopt: convert --numstat and --shortstat\n  diff-parseopt: convert --dirstat and friends\n  diff-parseopt: convert --check\n  diff-parseopt: convert --summary\n  diff-parseopt: convert --patch-with-stat\n  diff-parseopt: convert --name-only\n  diff-parseopt: convert --name-status\n  diff-parseopt: convert -s|--no-patch\n  diff-parseopt: convert --stat*\n  diff-parseopt: convert --[no-]compact-summary\n  diff-parseopt: convert --output-*\n  diff-parseopt: convert -B|--break-rewrites\n  diff-parseopt: convert -M|--find-renames\n  diff-parseopt: convert -D|--irreversible-delete\n  diff-parseopt: convert -C|--find-copies\n  diff-parseopt: convert --find-copies-harder\n  diff-parseopt: convert --no-renames|--[no--rename-empty\n  diff-parseopt: convert --relative\n  diff-parseopt: convert --[no-]minimal\n  diff-parseopt: convert --ignore-some-changes\n\n Documentation/diff-options.txt |  20 ++\n diff.c                         | 510 +++++++++++++++++++--------------\n 2 files changed, 319 insertions(+), 211 deletions(-)\n\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369444","messageId":"20190216113655.25728-2-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113655.25728-1-pclouds@gmail.com","subject":"[PATCH v3 01/21] diff-parseopt: convert --patch-with-raw","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:36:35Z","receivedAt":"2019-02-16T11:37:17Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 9 +++++----\n 1 file changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 4bc9df7362..12e333c67f 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4901,6 +4901,10 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT_F(0, \"raw\", &options->output_format,\n \t\t\t  N_(\"generate the diff in raw format\"),\n \t\t\t  DIFF_FORMAT_RAW, PARSE_OPT_NONEG),\n+\t\tOPT_BITOP(0, \"patch-with-raw\", &options->output_format,\n+\t\t\t  N_(\"synonym for '-p --raw'\"),\n+\t\t\t  DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW,\n+\t\t\t  DIFF_FORMAT_NO_OUTPUT),\n \t\tOPT_END()\n \t};\n \n@@ -4929,10 +4933,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--patch-with-raw\")) {\n-\t\tenable_patch_output(&options->output_format);\n-\t\toptions->output_format |= DIFF_FORMAT_RAW;\n-\t} else if (!strcmp(arg, \"--numstat\"))\n+\tif (!strcmp(arg, \"--numstat\"))\n \t\toptions->output_format |= DIFF_FORMAT_NUMSTAT;\n \telse if (!strcmp(arg, \"--shortstat\"))\n \t\toptions->output_format |= DIFF_FORMAT_SHORTSTAT;\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369445","messageId":"20190216113655.25728-3-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113655.25728-1-pclouds@gmail.com","subject":"[PATCH v3 02/21] diff-parseopt: convert --numstat and --shortstat","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:36:36Z","receivedAt":"2019-02-16T11:37:22Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 12 +++++++-----\n 1 file changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 12e333c67f..419b6ac4ae 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4905,6 +4905,12 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t  N_(\"synonym for '-p --raw'\"),\n \t\t\t  DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW,\n \t\t\t  DIFF_FORMAT_NO_OUTPUT),\n+\t\tOPT_BIT_F(0, \"numstat\", &options->output_format,\n+\t\t\t  N_(\"machine friendly --stat\"),\n+\t\t\t  DIFF_FORMAT_NUMSTAT, PARSE_OPT_NONEG),\n+\t\tOPT_BIT_F(0, \"shortstat\", &options->output_format,\n+\t\t\t  N_(\"output only the last line of --stat\"),\n+\t\t\t  DIFF_FORMAT_SHORTSTAT, PARSE_OPT_NONEG),\n \t\tOPT_END()\n \t};\n \n@@ -4933,11 +4939,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--numstat\"))\n-\t\toptions->output_format |= DIFF_FORMAT_NUMSTAT;\n-\telse if (!strcmp(arg, \"--shortstat\"))\n-\t\toptions->output_format |= DIFF_FORMAT_SHORTSTAT;\n-\telse if (skip_prefix(arg, \"-X\", &arg) ||\n+\tif (skip_prefix(arg, \"-X\", &arg) ||\n \t\t skip_to_optional_arg(arg, \"--dirstat\", &arg))\n \t\treturn parse_dirstat_opt(options, arg);\n \telse if (!strcmp(arg, \"--cumulative\"))\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369446","messageId":"20190216113655.25728-4-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113655.25728-1-pclouds@gmail.com","subject":"[PATCH v3 03/21] diff-parseopt: convert --dirstat and friends","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:36:37Z","receivedAt":"2019-02-16T11:37:27Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/diff-options.txt |  7 ++++++\n diff.c                         | 39 +++++++++++++++++++++++++---------\n 2 files changed, 36 insertions(+), 10 deletions(-)\n\ndiff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt\nindex 0711734b12..058d93ec4f 100644\n--- a/Documentation/diff-options.txt\n+++ b/Documentation/diff-options.txt\n@@ -148,6 +148,7 @@ These parameters can also be set individually with `--stat-width=<width>`,\n \tnumber of modified files, as well as number of added and deleted\n \tlines.\n \n+-X<param1,param2,...>::\n --dirstat[=<param1,param2,...>]::\n \tOutput the distribution of relative amount of changes for each\n \tsub-directory. The behavior of `--dirstat` can be customized by\n@@ -192,6 +193,12 @@ directories with less than 10% of the total amount of changed files,\n and accumulating child directory counts in the parent directories:\n `--dirstat=files,10,cumulative`.\n \n+--cumulative::\n+\tSynonym for --dirstat=cumulative\n+\n+--dirstat-by-file[=<param1,param2>...]::\n+\tSynonym for --dirstat=files,param1,param2...\n+\n --summary::\n \tOutput a condensed summary of extended header information\n \tsuch as creations, renames and mode changes.\ndiff --git a/diff.c b/diff.c\nindex 419b6ac4ae..1cdbe8e688 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4867,6 +4867,22 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)\n \treturn 1;\n }\n \n+static int diff_opt_dirstat(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 (!strcmp(opt->long_name, \"cumulative\")) {\n+\t\tif (arg)\n+\t\t\tBUG(\"how come --cumulative take a value?\");\n+\t\targ = \"cumulative\";\n+\t} else if (!strcmp(opt->long_name, \"dirstat-by-file\"))\n+\t\tparse_dirstat_opt(options, \"files\");\n+\tparse_dirstat_opt(options, arg ? arg : \"\");\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@@ -4911,6 +4927,18 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT_F(0, \"shortstat\", &options->output_format,\n \t\t\t  N_(\"output only the last line of --stat\"),\n \t\t\t  DIFF_FORMAT_SHORTSTAT, PARSE_OPT_NONEG),\n+\t\tOPT_CALLBACK_F('X', \"dirstat\", options, N_(\"<param1,param2>...\"),\n+\t\t\t       N_(\"output the distribution of relative amount of changes for each sub-directory\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n+\t\t\t       diff_opt_dirstat),\n+\t\tOPT_CALLBACK_F(0, \"cumulative\", options, NULL,\n+\t\t\t       N_(\"synonym for --dirstat=cumulative\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_NOARG,\n+\t\t\t       diff_opt_dirstat),\n+\t\tOPT_CALLBACK_F(0, \"dirstat-by-file\", options, N_(\"<param1,param2>...\"),\n+\t\t\t       N_(\"synonym for --dirstat=files,param1,param2...\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n+\t\t\t       diff_opt_dirstat),\n \t\tOPT_END()\n \t};\n \n@@ -4939,16 +4967,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (skip_prefix(arg, \"-X\", &arg) ||\n-\t\t skip_to_optional_arg(arg, \"--dirstat\", &arg))\n-\t\treturn parse_dirstat_opt(options, arg);\n-\telse if (!strcmp(arg, \"--cumulative\"))\n-\t\treturn parse_dirstat_opt(options, \"cumulative\");\n-\telse if (skip_to_optional_arg(arg, \"--dirstat-by-file\", &arg)) {\n-\t\tparse_dirstat_opt(options, \"files\");\n-\t\treturn parse_dirstat_opt(options, arg);\n-\t}\n-\telse if (!strcmp(arg, \"--check\"))\n+\tif (!strcmp(arg, \"--check\"))\n \t\toptions->output_format |= DIFF_FORMAT_CHECKDIFF;\n \telse if (!strcmp(arg, \"--summary\"))\n \t\toptions->output_format |= DIFF_FORMAT_SUMMARY;\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369447","messageId":"20190216113655.25728-5-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113655.25728-1-pclouds@gmail.com","subject":"[PATCH v3 04/21] diff-parseopt: convert --check","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:36:38Z","receivedAt":"2019-02-16T11:37:32Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 1cdbe8e688..5e16082091 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4939,6 +4939,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       N_(\"synonym for --dirstat=files,param1,param2...\"),\n \t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n \t\t\t       diff_opt_dirstat),\n+\t\tOPT_BIT_F(0, \"check\", &options->output_format,\n+\t\t\t  N_(\"warn if changes introduce conflict markers or whitespace errors\"),\n+\t\t\t  DIFF_FORMAT_CHECKDIFF, PARSE_OPT_NONEG),\n \t\tOPT_END()\n \t};\n \n@@ -4967,9 +4970,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--check\"))\n-\t\toptions->output_format |= DIFF_FORMAT_CHECKDIFF;\n-\telse if (!strcmp(arg, \"--summary\"))\n+\tif (!strcmp(arg, \"--summary\"))\n \t\toptions->output_format |= DIFF_FORMAT_SUMMARY;\n \telse if (!strcmp(arg, \"--patch-with-stat\")) {\n \t\tenable_patch_output(&options->output_format);\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369448","messageId":"20190216113655.25728-6-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113655.25728-1-pclouds@gmail.com","subject":"[PATCH v3 05/21] diff-parseopt: convert --summary","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:36:39Z","receivedAt":"2019-02-16T11:37: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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 5e16082091..0276f25200 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4942,6 +4942,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT_F(0, \"check\", &options->output_format,\n \t\t\t  N_(\"warn if changes introduce conflict markers or whitespace errors\"),\n \t\t\t  DIFF_FORMAT_CHECKDIFF, PARSE_OPT_NONEG),\n+\t\tOPT_BIT_F(0, \"summary\", &options->output_format,\n+\t\t\t  N_(\"condensed summary such as creations, renames and mode changes\"),\n+\t\t\t  DIFF_FORMAT_SUMMARY, PARSE_OPT_NONEG),\n \t\tOPT_END()\n \t};\n \n@@ -4970,9 +4973,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--summary\"))\n-\t\toptions->output_format |= DIFF_FORMAT_SUMMARY;\n-\telse if (!strcmp(arg, \"--patch-with-stat\")) {\n+\tif (!strcmp(arg, \"--patch-with-stat\")) {\n \t\tenable_patch_output(&options->output_format);\n \t\toptions->output_format |= DIFF_FORMAT_DIFFSTAT;\n \t} else if (!strcmp(arg, \"--name-only\"))\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369449","messageId":"20190216113655.25728-7-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113655.25728-1-pclouds@gmail.com","subject":"[PATCH v3 06/21] diff-parseopt: convert --patch-with-stat","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:36:40Z","receivedAt":"2019-02-16T11:37: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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 9 +++++----\n 1 file changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 0276f25200..b9811aefef 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4921,6 +4921,10 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t  N_(\"synonym for '-p --raw'\"),\n \t\t\t  DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW,\n \t\t\t  DIFF_FORMAT_NO_OUTPUT),\n+\t\tOPT_BITOP(0, \"patch-with-stat\", &options->output_format,\n+\t\t\t  N_(\"synonym for '-p --stat'\"),\n+\t\t\t  DIFF_FORMAT_PATCH | DIFF_FORMAT_DIFFSTAT,\n+\t\t\t  DIFF_FORMAT_NO_OUTPUT),\n \t\tOPT_BIT_F(0, \"numstat\", &options->output_format,\n \t\t\t  N_(\"machine friendly --stat\"),\n \t\t\t  DIFF_FORMAT_NUMSTAT, PARSE_OPT_NONEG),\n@@ -4973,10 +4977,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--patch-with-stat\")) {\n-\t\tenable_patch_output(&options->output_format);\n-\t\toptions->output_format |= DIFF_FORMAT_DIFFSTAT;\n-\t} else if (!strcmp(arg, \"--name-only\"))\n+\tif (!strcmp(arg, \"--name-only\"))\n \t\toptions->output_format |= DIFF_FORMAT_NAME;\n \telse if (!strcmp(arg, \"--name-status\"))\n \t\toptions->output_format |= DIFF_FORMAT_NAME_STATUS;\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369450","messageId":"20190216113655.25728-8-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113655.25728-1-pclouds@gmail.com","subject":"[PATCH v3 07/21] diff-parseopt: convert --name-only","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:36:41Z","receivedAt":"2019-02-16T11:37: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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex b9811aefef..7ea308814f 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4949,6 +4949,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT_F(0, \"summary\", &options->output_format,\n \t\t\t  N_(\"condensed summary such as creations, renames and mode changes\"),\n \t\t\t  DIFF_FORMAT_SUMMARY, PARSE_OPT_NONEG),\n+\t\tOPT_BIT_F(0, \"name-only\", &options->output_format,\n+\t\t\t  N_(\"show only names of changed files\"),\n+\t\t\t  DIFF_FORMAT_NAME, PARSE_OPT_NONEG),\n \t\tOPT_END()\n \t};\n \n@@ -4977,9 +4980,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--name-only\"))\n-\t\toptions->output_format |= DIFF_FORMAT_NAME;\n-\telse if (!strcmp(arg, \"--name-status\"))\n+\tif (!strcmp(arg, \"--name-status\"))\n \t\toptions->output_format |= DIFF_FORMAT_NAME_STATUS;\n \telse if (!strcmp(arg, \"-s\") || !strcmp(arg, \"--no-patch\"))\n \t\toptions->output_format |= DIFF_FORMAT_NO_OUTPUT;\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369451","messageId":"20190216113655.25728-9-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113655.25728-1-pclouds@gmail.com","subject":"[PATCH v3 08/21] diff-parseopt: convert --name-status","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:36:42Z","receivedAt":"2019-02-16T11:37: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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 7ea308814f..99047fb5fe 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4952,6 +4952,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT_F(0, \"name-only\", &options->output_format,\n \t\t\t  N_(\"show only names of changed files\"),\n \t\t\t  DIFF_FORMAT_NAME, PARSE_OPT_NONEG),\n+\t\tOPT_BIT_F(0, \"name-status\", &options->output_format,\n+\t\t\t  N_(\"show only names and status of changed files\"),\n+\t\t\t  DIFF_FORMAT_NAME_STATUS, PARSE_OPT_NONEG),\n \t\tOPT_END()\n \t};\n \n@@ -4980,9 +4983,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--name-status\"))\n-\t\toptions->output_format |= DIFF_FORMAT_NAME_STATUS;\n-\telse if (!strcmp(arg, \"-s\") || !strcmp(arg, \"--no-patch\"))\n+\tif (!strcmp(arg, \"-s\") || !strcmp(arg, \"--no-patch\"))\n \t\toptions->output_format |= DIFF_FORMAT_NO_OUTPUT;\n \telse if (starts_with(arg, \"--stat\"))\n \t\t/* --stat, --stat-width, --stat-name-width, or --stat-count */\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369452","messageId":"20190216113655.25728-10-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113655.25728-1-pclouds@gmail.com","subject":"[PATCH v3 09/21] diff-parseopt: convert -s|--no-patch","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:36:43Z","receivedAt":"2019-02-16T11:37: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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 99047fb5fe..9c8f5336bc 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4906,6 +4906,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BITOP('p', \"patch\", &options->output_format,\n \t\t\t  N_(\"generate patch\"),\n \t\t\t  DIFF_FORMAT_PATCH, DIFF_FORMAT_NO_OUTPUT),\n+\t\tOPT_BIT_F('s', \"no-patch\", &options->output_format,\n+\t\t\t  N_(\"suppress diff output\"),\n+\t\t\t  DIFF_FORMAT_NO_OUTPUT, PARSE_OPT_NONEG),\n \t\tOPT_BITOP('u', NULL, &options->output_format,\n \t\t\t  N_(\"generate patch\"),\n \t\t\t  DIFF_FORMAT_PATCH, DIFF_FORMAT_NO_OUTPUT),\n@@ -4983,9 +4986,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"-s\") || !strcmp(arg, \"--no-patch\"))\n-\t\toptions->output_format |= DIFF_FORMAT_NO_OUTPUT;\n-\telse if (starts_with(arg, \"--stat\"))\n+\tif (starts_with(arg, \"--stat\"))\n \t\t/* --stat, --stat-width, --stat-name-width, or --stat-count */\n \t\treturn stat_opt(options, av);\n \telse if (!strcmp(arg, \"--compact-summary\")) {\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369453","messageId":"20190216113655.25728-11-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113655.25728-1-pclouds@gmail.com","subject":"[PATCH v3 10/21] diff-parseopt: convert --stat*","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:36:44Z","receivedAt":"2019-02-16T11:38: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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 118 +++++++++++++++++++++++++--------------------------------\n 1 file changed, 52 insertions(+), 66 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 9c8f5336bc..1feb13deb3 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -104,11 +104,6 @@ static const char *color_diff_slots[] = {\n \t[DIFF_FILE_NEW_BOLD]\t      = \"newBold\",\n };\n \n-static NORETURN void die_want_option(const char *option_name)\n-{\n-\tdie(_(\"option '%s' requires a value\"), option_name);\n-}\n-\n define_list_config_array_extra(color_diff_slots, {\"plain\"});\n \n static int parse_diff_color_slot(const char *var)\n@@ -4661,77 +4656,56 @@ int parse_long_opt(const char *opt, const char **argv,\n \treturn 2;\n }\n \n-static int stat_opt(struct diff_options *options, const char **av)\n+static int diff_opt_stat(const struct option *opt, const char *value, int unset)\n {\n-\tconst char *arg = av[0];\n-\tchar *end;\n+\tstruct diff_options *options = opt->value;\n \tint width = options->stat_width;\n \tint name_width = options->stat_name_width;\n \tint graph_width = options->stat_graph_width;\n \tint count = options->stat_count;\n-\tint argcount = 1;\n+\tchar *end;\n \n-\tif (!skip_prefix(arg, \"--stat\", &arg))\n-\t\tBUG(\"stat option does not begin with --stat: %s\", arg);\n-\tend = (char *)arg;\n+\tBUG_ON_OPT_NEG(unset);\n \n-\tswitch (*arg) {\n-\tcase '-':\n-\t\tif (skip_prefix(arg, \"-width\", &arg)) {\n-\t\t\tif (*arg == '=')\n-\t\t\t\twidth = strtoul(arg + 1, &end, 10);\n-\t\t\telse if (!*arg && !av[1])\n-\t\t\t\tdie_want_option(\"--stat-width\");\n-\t\t\telse if (!*arg) {\n-\t\t\t\twidth = strtoul(av[1], &end, 10);\n-\t\t\t\targcount = 2;\n-\t\t\t}\n-\t\t} else if (skip_prefix(arg, \"-name-width\", &arg)) {\n-\t\t\tif (*arg == '=')\n-\t\t\t\tname_width = strtoul(arg + 1, &end, 10);\n-\t\t\telse if (!*arg && !av[1])\n-\t\t\t\tdie_want_option(\"--stat-name-width\");\n-\t\t\telse if (!*arg) {\n-\t\t\t\tname_width = strtoul(av[1], &end, 10);\n-\t\t\t\targcount = 2;\n-\t\t\t}\n-\t\t} else if (skip_prefix(arg, \"-graph-width\", &arg)) {\n-\t\t\tif (*arg == '=')\n-\t\t\t\tgraph_width = strtoul(arg + 1, &end, 10);\n-\t\t\telse if (!*arg && !av[1])\n-\t\t\t\tdie_want_option(\"--stat-graph-width\");\n-\t\t\telse if (!*arg) {\n-\t\t\t\tgraph_width = strtoul(av[1], &end, 10);\n-\t\t\t\targcount = 2;\n-\t\t\t}\n-\t\t} else if (skip_prefix(arg, \"-count\", &arg)) {\n-\t\t\tif (*arg == '=')\n-\t\t\t\tcount = strtoul(arg + 1, &end, 10);\n-\t\t\telse if (!*arg && !av[1])\n-\t\t\t\tdie_want_option(\"--stat-count\");\n-\t\t\telse if (!*arg) {\n-\t\t\t\tcount = strtoul(av[1], &end, 10);\n-\t\t\t\targcount = 2;\n-\t\t\t}\n+\tif (!strcmp(opt->long_name, \"stat\")) {\n+\t\tif (value) {\n+\t\t\twidth = strtoul(value, &end, 10);\n+\t\t\tif (*end == ',')\n+\t\t\t\tname_width = strtoul(end+1, &end, 10);\n+\t\t\tif (*end == ',')\n+\t\t\t\tcount = strtoul(end+1, &end, 10);\n+\t\t\tif (*end)\n+\t\t\t\treturn error(_(\"invalid --stat value: %s\"), value);\n \t\t}\n-\t\tbreak;\n-\tcase '=':\n-\t\twidth = strtoul(arg+1, &end, 10);\n-\t\tif (*end == ',')\n-\t\t\tname_width = strtoul(end+1, &end, 10);\n-\t\tif (*end == ',')\n-\t\t\tcount = strtoul(end+1, &end, 10);\n-\t}\n+\t} else if (!strcmp(opt->long_name, \"stat-width\")) {\n+\t\twidth = strtoul(value, &end, 10);\n+\t\tif (*end)\n+\t\t\treturn error(_(\"%s expects a numerical value\"),\n+\t\t\t\t     opt->long_name);\n+\t} else if (!strcmp(opt->long_name, \"stat-name-width\")) {\n+\t\tname_width = strtoul(value, &end, 10);\n+\t\tif (*end)\n+\t\t\treturn error(_(\"%s expects a numerical value\"),\n+\t\t\t\t     opt->long_name);\n+\t} else if (!strcmp(opt->long_name, \"stat-graph-width\")) {\n+\t\tgraph_width = strtoul(value, &end, 10);\n+\t\tif (*end)\n+\t\t\treturn error(_(\"%s expects a numerical value\"),\n+\t\t\t\t     opt->long_name);\n+\t} else if (!strcmp(opt->long_name, \"stat-count\")) {\n+\t\tcount = strtoul(value, &end, 10);\n+\t\tif (*end)\n+\t\t\treturn error(_(\"%s expects a numerical value\"),\n+\t\t\t\t     opt->long_name);\n+\t} else\n+\t\tBUG(\"%s should not get here\", opt->long_name);\n \n-\t/* Important! This checks all the error cases! */\n-\tif (*end)\n-\t\treturn 0;\n \toptions->output_format |= DIFF_FORMAT_DIFFSTAT;\n \toptions->stat_name_width = name_width;\n \toptions->stat_graph_width = graph_width;\n \toptions->stat_width = width;\n \toptions->stat_count = count;\n-\treturn argcount;\n+\treturn 0;\n }\n \n static int parse_dirstat_opt(struct diff_options *options, const char *params)\n@@ -4958,6 +4932,21 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT_F(0, \"name-status\", &options->output_format,\n \t\t\t  N_(\"show only names and status of changed files\"),\n \t\t\t  DIFF_FORMAT_NAME_STATUS, PARSE_OPT_NONEG),\n+\t\tOPT_CALLBACK_F(0, \"stat\", options, N_(\"<width>[,<name-width>[,<count>]]\"),\n+\t\t\t       N_(\"generate diffstat\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_stat),\n+\t\tOPT_CALLBACK_F(0, \"stat-width\", options, N_(\"<width>\"),\n+\t\t\t       N_(\"generate diffstat with a given width\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_stat),\n+\t\tOPT_CALLBACK_F(0, \"stat-name-width\", options, N_(\"<width>\"),\n+\t\t\t       N_(\"generate diffstat with a given name width\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_stat),\n+\t\tOPT_CALLBACK_F(0, \"stat-graph-width\", options, N_(\"<width>\"),\n+\t\t\t       N_(\"generate diffstat with a given graph width\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_stat),\n+\t\tOPT_CALLBACK_F(0, \"stat-count\", options, N_(\"<count>\"),\n+\t\t\t       N_(\"generate diffstat with limited lines\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_stat),\n \t\tOPT_END()\n \t};\n \n@@ -4986,10 +4975,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (starts_with(arg, \"--stat\"))\n-\t\t/* --stat, --stat-width, --stat-name-width, or --stat-count */\n-\t\treturn stat_opt(options, av);\n-\telse if (!strcmp(arg, \"--compact-summary\")) {\n+\tif (!strcmp(arg, \"--compact-summary\")) {\n \t\t options->flags.stat_with_summary = 1;\n \t\t options->output_format |= DIFF_FORMAT_DIFFSTAT;\n \t} else if (!strcmp(arg, \"--no-compact-summary\"))\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369454","messageId":"20190216113655.25728-12-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113655.25728-1-pclouds@gmail.com","subject":"[PATCH v3 11/21] diff-parseopt: convert --[no-]compact-summary","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:36:45Z","receivedAt":"2019-02-16T11:38: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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 25 +++++++++++++++++++------\n 1 file changed, 19 insertions(+), 6 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 1feb13deb3..b24f6825a1 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4841,6 +4841,21 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)\n \treturn 1;\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+\tstruct diff_options *options = opt->value;\n+\n+\tBUG_ON_OPT_ARG(arg);\n+\tif (unset) {\n+\t\toptions->flags.stat_with_summary = 0;\n+\t} else {\n+\t\toptions->flags.stat_with_summary = 1;\n+\t\toptions->output_format |= DIFF_FORMAT_DIFFSTAT;\n+\t}\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@@ -4947,6 +4962,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_CALLBACK_F(0, \"stat-count\", options, N_(\"<count>\"),\n \t\t\t       N_(\"generate diffstat with limited lines\"),\n \t\t\t       PARSE_OPT_NONEG, diff_opt_stat),\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_END()\n \t};\n \n@@ -4975,12 +4993,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--compact-summary\")) {\n-\t\t options->flags.stat_with_summary = 1;\n-\t\t options->output_format |= DIFF_FORMAT_DIFFSTAT;\n-\t} else if (!strcmp(arg, \"--no-compact-summary\"))\n-\t\t options->flags.stat_with_summary = 0;\n-\telse if (skip_prefix(arg, \"--output-indicator-new=\", &arg))\n+\tif (skip_prefix(arg, \"--output-indicator-new=\", &arg))\n \t\toptions->output_indicators[OUTPUT_INDICATOR_NEW] = arg[0];\n \telse if (skip_prefix(arg, \"--output-indicator-old=\", &arg))\n \t\toptions->output_indicators[OUTPUT_INDICATOR_OLD] = arg[0];\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369455","messageId":"20190216113655.25728-13-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113655.25728-1-pclouds@gmail.com","subject":"[PATCH v3 12/21] diff-parseopt: convert --output-*","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:36:46Z","receivedAt":"2019-02-16T11:38:10Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This also validates that the user specifies a single character in\n--output-indicator-*, not a string.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/diff-options.txt | 10 +++++\n diff.c                         | 71 +++++++++++++++++++++++++---------\n 2 files changed, 63 insertions(+), 18 deletions(-)\n\ndiff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt\nindex 058d93ec4f..d3e8d634b2 100644\n--- a/Documentation/diff-options.txt\n+++ b/Documentation/diff-options.txt\n@@ -41,6 +41,16 @@ ifndef::git-format-patch[]\n \tImplies `-p`.\n endif::git-format-patch[]\n \n+--output=<file>::\n+\tOutput to a specific file instead of stdout.\n+\n+--output-indicator-new=<char>::\n+--output-indicator-old=<char>::\n+--output-indicator-context=<char>::\n+\tSpecify the character used to indicate new, old or context\n+\tlines in the generated patch. Normally they are '+', '-' and\n+\t' ' respectively.\n+\n ifndef::git-format-patch[]\n --raw::\n ifndef::git-log[]\ndiff --git a/diff.c b/diff.c\nindex b24f6825a1..8df396cb9a 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4841,6 +4841,19 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)\n \treturn 1;\n }\n \n+static int diff_opt_char(const struct option *opt,\n+\t\t\t const char *arg, int unset)\n+{\n+\tchar *value = opt->value;\n+\n+\tBUG_ON_OPT_NEG(unset);\n+\tif (arg[1])\n+\t\treturn error(_(\"%s expects a character, got '%s'\"),\n+\t\t\t     opt->long_name, arg);\n+\t*value = arg[0];\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@@ -4872,6 +4885,23 @@ static int diff_opt_dirstat(const struct option *opt,\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+{\n+\tstruct diff_options *options = opt->value;\n+\tchar *path;\n+\n+\tBUG_ON_OPT_NEG(unset);\n+\tpath = prefix_filename(ctx->prefix, arg);\n+\toptions->file = xfopen(path, \"w\");\n+\toptions->close_file = 1;\n+\tif (options->use_color != GIT_COLOR_ALWAYS)\n+\t\toptions->use_color = GIT_COLOR_NEVER;\n+\tfree(path);\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@@ -4965,6 +4995,27 @@ 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, \"output-indicator-new\",\n+\t\t\t       &options->output_indicators[OUTPUT_INDICATOR_NEW],\n+\t\t\t       N_(\"<char>\"),\n+\t\t\t       N_(\"specify the character to indicate a new line instead of '+'\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_char),\n+\t\tOPT_CALLBACK_F(0, \"output-indicator-old\",\n+\t\t\t       &options->output_indicators[OUTPUT_INDICATOR_OLD],\n+\t\t\t       N_(\"<char>\"),\n+\t\t\t       N_(\"specify the character to indicate an old line instead of '-'\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_char),\n+\t\tOPT_CALLBACK_F(0, \"output-indicator-context\",\n+\t\t\t       &options->output_indicators[OUTPUT_INDICATOR_CONTEXT],\n+\t\t\t       N_(\"<char>\"),\n+\t\t\t       N_(\"specify the character to indicate a context instead of ' '\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_char),\n+\n+\t\tOPT_GROUP(N_(\"Diff other options\")),\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+\n \t\tOPT_END()\n \t};\n \n@@ -4992,16 +5043,8 @@ int diff_opt_parse(struct diff_options *options,\n \tif (ac)\n \t\treturn ac;\n \n-\t/* Output format options */\n-\tif (skip_prefix(arg, \"--output-indicator-new=\", &arg))\n-\t\toptions->output_indicators[OUTPUT_INDICATOR_NEW] = arg[0];\n-\telse if (skip_prefix(arg, \"--output-indicator-old=\", &arg))\n-\t\toptions->output_indicators[OUTPUT_INDICATOR_OLD] = arg[0];\n-\telse if (skip_prefix(arg, \"--output-indicator-context=\", &arg))\n-\t\toptions->output_indicators[OUTPUT_INDICATOR_CONTEXT] = arg[0];\n-\n \t/* renames options */\n-\telse if (starts_with(arg, \"-B\") ||\n+\tif (starts_with(arg, \"-B\") ||\n \t\t skip_to_optional_arg(arg, \"--break-rewrites\", NULL)) {\n \t\tif ((options->break_opt = diff_scoreopt_parse(arg)) == -1)\n \t\t\treturn error(\"invalid argument to -B: %s\", arg+2);\n@@ -5242,15 +5285,7 @@ int diff_opt_parse(struct diff_options *options,\n \telse if (opt_arg(arg, '\\0', \"inter-hunk-context\",\n \t\t\t &options->interhunkcontext))\n \t\t;\n-\telse if ((argcount = parse_long_opt(\"output\", av, &optarg))) {\n-\t\tchar *path = prefix_filename(prefix, optarg);\n-\t\toptions->file = xfopen(path, \"w\");\n-\t\toptions->close_file = 1;\n-\t\tif (options->use_color != GIT_COLOR_ALWAYS)\n-\t\t\toptions->use_color = GIT_COLOR_NEVER;\n-\t\tfree(path);\n-\t\treturn argcount;\n-\t} else\n+\telse\n \t\treturn 0;\n \treturn 1;\n }\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369456","messageId":"20190216113655.25728-14-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113655.25728-1-pclouds@gmail.com","subject":"[PATCH v3 13/21] diff-parseopt: convert -B|--break-rewrites","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:36:47Z","receivedAt":"2019-02-16T11:38: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 | 62 ++++++++++++++++++++++++++++++++++------------------------\n 1 file changed, 36 insertions(+), 26 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 8df396cb9a..d2139082b7 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4841,6 +4841,30 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)\n \treturn 1;\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+\tint *break_opt = opt->value;\n+\tint opt1, opt2;\n+\n+\tBUG_ON_OPT_NEG(unset);\n+\tif (!arg)\n+\t\targ = \"\";\n+\topt1 = parse_rename_score(&arg);\n+\tif (*arg == 0)\n+\t\topt2 = 0;\n+\telse if (*arg != '/')\n+\t\treturn error(_(\"%s expects <n>/<m> form\"), opt->long_name);\n+\telse {\n+\t\targ++;\n+\t\topt2 = parse_rename_score(&arg);\n+\t}\n+\tif (*arg != 0)\n+\t\treturn error(_(\"%s expects <n>/<m> form\"), opt->long_name);\n+\t*break_opt = opt1 | (opt2 << 16);\n+\treturn 0;\n+}\n+\n static int diff_opt_char(const struct option *opt,\n \t\t\t const char *arg, int unset)\n {\n@@ -5011,6 +5035,12 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       N_(\"specify the character to indicate a context instead of ' '\"),\n \t\t\t       PARSE_OPT_NONEG, diff_opt_char),\n \n+\t\tOPT_GROUP(N_(\"Diff rename options\")),\n+\t\tOPT_CALLBACK_F('B', \"break-rewrites\", &options->break_opt, N_(\"<n>[/<m>]\"),\n+\t\t\t       N_(\"break complete rewrite changes into pairs of delete and create\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n+\t\t\t       diff_opt_break_rewrites),\n+\n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n \t\t  N_(\"Output to a specific file\"),\n@@ -5044,12 +5074,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* renames options */\n-\tif (starts_with(arg, \"-B\") ||\n-\t\t skip_to_optional_arg(arg, \"--break-rewrites\", NULL)) {\n-\t\tif ((options->break_opt = diff_scoreopt_parse(arg)) == -1)\n-\t\t\treturn error(\"invalid argument to -B: %s\", arg+2);\n-\t}\n-\telse if (starts_with(arg, \"-M\") ||\n+\tif (starts_with(arg, \"-M\") ||\n \t\t skip_to_optional_arg(arg, \"--find-renames\", NULL)) {\n \t\tif ((options->rename_score = diff_scoreopt_parse(arg)) == -1)\n \t\t\treturn error(\"invalid argument to -M: %s\", arg+2);\n@@ -5328,17 +5353,14 @@ int parse_rename_score(const char **cp_p)\n \n static int diff_scoreopt_parse(const char *opt)\n {\n-\tint opt1, opt2, cmd;\n+\tint opt1, cmd;\n \n \tif (*opt++ != '-')\n \t\treturn -1;\n \tcmd = *opt++;\n \tif (cmd == '-') {\n \t\t/* convert the long-form arguments into short-form versions */\n-\t\tif (skip_prefix(opt, \"break-rewrites\", &opt)) {\n-\t\t\tif (*opt == 0 || *opt++ == '=')\n-\t\t\t\tcmd = 'B';\n-\t\t} else if (skip_prefix(opt, \"find-copies\", &opt)) {\n+\t\tif (skip_prefix(opt, \"find-copies\", &opt)) {\n \t\t\tif (*opt == 0 || *opt++ == '=')\n \t\t\t\tcmd = 'C';\n \t\t} else if (skip_prefix(opt, \"find-renames\", &opt)) {\n@@ -5346,25 +5368,13 @@ static int diff_scoreopt_parse(const char *opt)\n \t\t\t\tcmd = 'M';\n \t\t}\n \t}\n-\tif (cmd != 'M' && cmd != 'C' && cmd != 'B')\n-\t\treturn -1; /* that is not a -M, -C, or -B option */\n+\tif (cmd != 'M' && cmd != 'C')\n+\t\treturn -1; /* that is not a -M, or -C option */\n \n \topt1 = parse_rename_score(&opt);\n-\tif (cmd != 'B')\n-\t\topt2 = 0;\n-\telse {\n-\t\tif (*opt == 0)\n-\t\t\topt2 = 0;\n-\t\telse if (*opt != '/')\n-\t\t\treturn -1; /* we expect -B80/99 or -B80 */\n-\t\telse {\n-\t\t\topt++;\n-\t\t\topt2 = parse_rename_score(&opt);\n-\t\t}\n-\t}\n \tif (*opt != 0)\n \t\treturn -1;\n-\treturn opt1 | (opt2 << 16);\n+\treturn opt1;\n }\n \n struct diff_queue_struct diff_queued_diff;\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369457","messageId":"20190216113655.25728-15-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113655.25728-1-pclouds@gmail.com","subject":"[PATCH v3 14/21] diff-parseopt: convert -M|--find-renames","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:36:48Z","receivedAt":"2019-02-16T11:38:20Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 35 +++++++++++++++++++++++------------\n 1 file changed, 23 insertions(+), 12 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex d2139082b7..2c904e0526 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4909,6 +4909,22 @@ static int diff_opt_dirstat(const struct option *opt,\n \treturn 0;\n }\n \n+static int diff_opt_find_renames(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 = \"\";\n+\toptions->rename_score = parse_rename_score(&arg);\n+\tif (*arg != 0)\n+\t\treturn error(_(\"invalid argument to %s\"), opt->long_name);\n+\n+\toptions->detect_rename = DIFF_DETECT_RENAME;\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@@ -5040,6 +5056,10 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       N_(\"break complete rewrite changes into pairs of delete and create\"),\n \t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n \t\t\t       diff_opt_break_rewrites),\n+\t\tOPT_CALLBACK_F('M', \"find-renames\", options, N_(\"<n>\"),\n+\t\t\t       N_(\"detect renames\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n+\t\t\t       diff_opt_find_renames),\n \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n@@ -5074,13 +5094,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* renames options */\n-\tif (starts_with(arg, \"-M\") ||\n-\t\t skip_to_optional_arg(arg, \"--find-renames\", NULL)) {\n-\t\tif ((options->rename_score = diff_scoreopt_parse(arg)) == -1)\n-\t\t\treturn error(\"invalid argument to -M: %s\", arg+2);\n-\t\toptions->detect_rename = DIFF_DETECT_RENAME;\n-\t}\n-\telse if (!strcmp(arg, \"-D\") || !strcmp(arg, \"--irreversible-delete\")) {\n+\tif (!strcmp(arg, \"-D\") || !strcmp(arg, \"--irreversible-delete\")) {\n \t\toptions->irreversible_delete = 1;\n \t}\n \telse if (starts_with(arg, \"-C\") ||\n@@ -5363,13 +5377,10 @@ static int diff_scoreopt_parse(const char *opt)\n \t\tif (skip_prefix(opt, \"find-copies\", &opt)) {\n \t\t\tif (*opt == 0 || *opt++ == '=')\n \t\t\t\tcmd = 'C';\n-\t\t} else if (skip_prefix(opt, \"find-renames\", &opt)) {\n-\t\t\tif (*opt == 0 || *opt++ == '=')\n-\t\t\t\tcmd = 'M';\n \t\t}\n \t}\n-\tif (cmd != 'M' && cmd != 'C')\n-\t\treturn -1; /* that is not a -M, or -C option */\n+\tif (cmd != 'C')\n+\t\treturn -1; /* that is not a -M option */\n \n \topt1 = parse_rename_score(&opt);\n \tif (*opt != 0)\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369458","messageId":"20190216113655.25728-16-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113655.25728-1-pclouds@gmail.com","subject":"[PATCH v3 15/21] diff-parseopt: convert -D|--irreversible-delete","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:36:49Z","receivedAt":"2019-02-16T11:38:25Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 2c904e0526..e51f6b3005 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5060,6 +5060,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       N_(\"detect renames\"),\n \t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n \t\t\t       diff_opt_find_renames),\n+\t\tOPT_SET_INT_F('D', \"irreversible-delete\", &options->irreversible_delete,\n+\t\t\t      N_(\"omit the preimage for deletes\"),\n+\t\t\t      1, PARSE_OPT_NONEG),\n \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n@@ -5094,10 +5097,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* renames options */\n-\tif (!strcmp(arg, \"-D\") || !strcmp(arg, \"--irreversible-delete\")) {\n-\t\toptions->irreversible_delete = 1;\n-\t}\n-\telse if (starts_with(arg, \"-C\") ||\n+\tif (starts_with(arg, \"-C\") ||\n \t\t skip_to_optional_arg(arg, \"--find-copies\", NULL)) {\n \t\tif (options->detect_rename == DIFF_DETECT_COPY)\n \t\t\toptions->flags.find_copies_harder = 1;\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369459","messageId":"20190216113655.25728-17-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113655.25728-1-pclouds@gmail.com","subject":"[PATCH v3 16/21] diff-parseopt: convert -C|--find-copies","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:36:50Z","receivedAt":"2019-02-16T11:38:30Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 59 +++++++++++++++++++++++++---------------------------------\n 1 file changed, 25 insertions(+), 34 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex e51f6b3005..35bac115cc 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4617,8 +4617,6 @@ static int opt_arg(const char *arg, int arg_short, const char *arg_long, int *va\n \treturn 1;\n }\n \n-static int diff_scoreopt_parse(const char *opt);\n-\n static inline int short_opt(char opt, const char **argv,\n \t\t\t    const char **optarg)\n {\n@@ -4909,6 +4907,26 @@ static int diff_opt_dirstat(const struct option *opt,\n \treturn 0;\n }\n \n+static int diff_opt_find_copies(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+\tif (!arg)\n+\t\targ = \"\";\n+\toptions->rename_score = parse_rename_score(&arg);\n+\tif (*arg != 0)\n+\t\treturn error(_(\"invalid argument to %s\"), opt->long_name);\n+\n+\tif (options->detect_rename == DIFF_DETECT_COPY)\n+\t\toptions->flags.find_copies_harder = 1;\n+\telse\n+\t\toptions->detect_rename = DIFF_DETECT_COPY;\n+\n+\treturn 0;\n+}\n+\n static int diff_opt_find_renames(const struct option *opt,\n \t\t\t\t const char *arg, int unset)\n {\n@@ -5063,6 +5081,10 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_SET_INT_F('D', \"irreversible-delete\", &options->irreversible_delete,\n \t\t\t      N_(\"omit the preimage for deletes\"),\n \t\t\t      1, PARSE_OPT_NONEG),\n+\t\tOPT_CALLBACK_F('C', \"find-copies\", options, N_(\"<n>\"),\n+\t\t\t       N_(\"detect copies\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n+\t\t\t       diff_opt_find_copies),\n \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n@@ -5097,15 +5119,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* renames options */\n-\tif (starts_with(arg, \"-C\") ||\n-\t\t skip_to_optional_arg(arg, \"--find-copies\", NULL)) {\n-\t\tif (options->detect_rename == DIFF_DETECT_COPY)\n-\t\t\toptions->flags.find_copies_harder = 1;\n-\t\tif ((options->rename_score = diff_scoreopt_parse(arg)) == -1)\n-\t\t\treturn error(\"invalid argument to -C: %s\", arg+2);\n-\t\toptions->detect_rename = DIFF_DETECT_COPY;\n-\t}\n-\telse if (!strcmp(arg, \"--no-renames\"))\n+\tif (!strcmp(arg, \"--no-renames\"))\n \t\toptions->detect_rename = 0;\n \telse if (!strcmp(arg, \"--rename-empty\"))\n \t\toptions->flags.rename_empty = 1;\n@@ -5365,29 +5379,6 @@ int parse_rename_score(const char **cp_p)\n \treturn (int)((num >= scale) ? MAX_SCORE : (MAX_SCORE * num / scale));\n }\n \n-static int diff_scoreopt_parse(const char *opt)\n-{\n-\tint opt1, cmd;\n-\n-\tif (*opt++ != '-')\n-\t\treturn -1;\n-\tcmd = *opt++;\n-\tif (cmd == '-') {\n-\t\t/* convert the long-form arguments into short-form versions */\n-\t\tif (skip_prefix(opt, \"find-copies\", &opt)) {\n-\t\t\tif (*opt == 0 || *opt++ == '=')\n-\t\t\t\tcmd = 'C';\n-\t\t}\n-\t}\n-\tif (cmd != 'C')\n-\t\treturn -1; /* that is not a -M option */\n-\n-\topt1 = parse_rename_score(&opt);\n-\tif (*opt != 0)\n-\t\treturn -1;\n-\treturn opt1;\n-}\n-\n struct diff_queue_struct diff_queued_diff;\n \n void diff_q(struct diff_queue_struct *queue, struct diff_filepair *dp)\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369460","messageId":"20190216113655.25728-18-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113655.25728-1-pclouds@gmail.com","subject":"[PATCH v3 17/21] diff-parseopt: convert --find-copies-harder","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:36:51Z","receivedAt":"2019-02-16T11:38:34Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"--no-find-copies-harder is also added on purpose (because I don't see\nwhy we should not have the --no- version for this)\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 35bac115cc..abb1566f95 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5085,6 +5085,8 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       N_(\"detect copies\"),\n \t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n \t\t\t       diff_opt_find_copies),\n+\t\tOPT_BOOL(0, \"find-copies-harder\", &options->flags.find_copies_harder,\n+\t\t\t N_(\"use unmodified files as source to find copies\")),\n \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n@@ -5191,8 +5193,6 @@ int diff_opt_parse(struct diff_options *options,\n \t\toptions->flags.text = 1;\n \telse if (!strcmp(arg, \"-R\"))\n \t\toptions->flags.reverse_diff = 1;\n-\telse if (!strcmp(arg, \"--find-copies-harder\"))\n-\t\toptions->flags.find_copies_harder = 1;\n \telse if (!strcmp(arg, \"--follow\"))\n \t\toptions->flags.follow_renames = 1;\n \telse if (!strcmp(arg, \"--no-follow\")) {\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369461","messageId":"20190216113655.25728-19-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113655.25728-1-pclouds@gmail.com","subject":"[PATCH v3 18/21] diff-parseopt: convert --no-renames|--[no--rename-empty","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:36:52Z","receivedAt":"2019-02-16T11:38:39Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"For --rename-empty, see 90d43b0768 (teach diffcore-rename to\noptionally ignore empty content - 2012-03-22) for more information.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/diff-options.txt |  3 +++\n diff.c                         | 13 ++++++-------\n 2 files changed, 9 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt\nindex d3e8d634b2..4c0d40881b 100644\n--- a/Documentation/diff-options.txt\n+++ b/Documentation/diff-options.txt\n@@ -392,6 +392,9 @@ endif::git-format-patch[]\n \tTurn off rename detection, even when the configuration\n \tfile gives the default to do so.\n \n+--[no-]rename-empty::\n+\tWhether to use empty blobs as rename source.\n+\n ifndef::git-format-patch[]\n --check::\n \tWarn if changes introduce conflict markers or whitespace errors.\ndiff --git a/diff.c b/diff.c\nindex abb1566f95..d423a06b41 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5087,6 +5087,11 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       diff_opt_find_copies),\n \t\tOPT_BOOL(0, \"find-copies-harder\", &options->flags.find_copies_harder,\n \t\t\t N_(\"use unmodified files as source to find copies\")),\n+\t\tOPT_SET_INT_F(0, \"no-renames\", &options->detect_rename,\n+\t\t\t      N_(\"disable rename detection\"),\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 \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n@@ -5121,13 +5126,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* renames options */\n-\tif (!strcmp(arg, \"--no-renames\"))\n-\t\toptions->detect_rename = 0;\n-\telse if (!strcmp(arg, \"--rename-empty\"))\n-\t\toptions->flags.rename_empty = 1;\n-\telse if (!strcmp(arg, \"--no-rename-empty\"))\n-\t\toptions->flags.rename_empty = 0;\n-\telse if (skip_to_optional_arg_default(arg, \"--relative\", &arg, NULL)) {\n+\tif (skip_to_optional_arg_default(arg, \"--relative\", &arg, NULL)) {\n \t\toptions->flags.relative_name = 1;\n \t\tif (arg)\n \t\t\toptions->prefix = arg;\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369462","messageId":"20190216113655.25728-20-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113655.25728-1-pclouds@gmail.com","subject":"[PATCH v3 19/21] diff-parseopt: convert --relative","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:36:53Z","receivedAt":"2019-02-16T11:38:44Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 25 +++++++++++++++++--------\n 1 file changed, 17 insertions(+), 8 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex d423a06b41..b9c267a199 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4960,6 +4960,18 @@ static enum parse_opt_result diff_opt_output(struct parse_opt_ctx_t *ctx,\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+\tstruct diff_options *options = opt->value;\n+\n+\tBUG_ON_OPT_NEG(unset);\n+\toptions->flags.relative_name = 1;\n+\tif (arg)\n+\t\toptions->prefix = arg;\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@@ -5094,6 +5106,10 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t N_(\"use empty blobs as rename source\")),\n \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n+\t\tOPT_CALLBACK_F(0, \"relative\", options, N_(\"<prefix>\"),\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\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@@ -5125,15 +5141,8 @@ int diff_opt_parse(struct diff_options *options,\n \tif (ac)\n \t\treturn ac;\n \n-\t/* renames options */\n-\tif (skip_to_optional_arg_default(arg, \"--relative\", &arg, NULL)) {\n-\t\toptions->flags.relative_name = 1;\n-\t\tif (arg)\n-\t\t\toptions->prefix = arg;\n-\t}\n-\n \t/* xdiff options */\n-\telse if (!strcmp(arg, \"--minimal\"))\n+\tif (!strcmp(arg, \"--minimal\"))\n \t\tDIFF_XDL_SET(options, NEED_MINIMAL);\n \telse if (!strcmp(arg, \"--no-minimal\"))\n \t\tDIFF_XDL_CLR(options, NEED_MINIMAL);\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369463","messageId":"20190216113655.25728-21-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113655.25728-1-pclouds@gmail.com","subject":"[PATCH v3 20/21] diff-parseopt: convert --[no-]minimal","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:36:54Z","receivedAt":"2019-02-16T11:38:48Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 11 ++++++-----\n 1 file changed, 6 insertions(+), 5 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex b9c267a199..33492e754f 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5105,6 +5105,11 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BOOL(0, \"rename-empty\", &options->flags.rename_empty,\n \t\t\t N_(\"use empty blobs as rename source\")),\n \n+\t\tOPT_GROUP(N_(\"Diff algorithm options\")),\n+\t\tOPT_BIT(0, \"minimal\", &options->xdl_opts,\n+\t\t\tN_(\"produce the smallest possible diff\"),\n+\t\t\tXDF_NEED_MINIMAL),\n+\n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\tOPT_CALLBACK_F(0, \"relative\", options, N_(\"<prefix>\"),\n \t\t\t       N_(\"when run from subdir, exclude changes outside and show relative paths\"),\n@@ -5142,11 +5147,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* xdiff options */\n-\tif (!strcmp(arg, \"--minimal\"))\n-\t\tDIFF_XDL_SET(options, NEED_MINIMAL);\n-\telse if (!strcmp(arg, \"--no-minimal\"))\n-\t\tDIFF_XDL_CLR(options, NEED_MINIMAL);\n-\telse if (!strcmp(arg, \"-w\") || !strcmp(arg, \"--ignore-all-space\"))\n+\tif (!strcmp(arg, \"-w\") || !strcmp(arg, \"--ignore-all-space\"))\n \t\tDIFF_XDL_SET(options, IGNORE_WHITESPACE);\n \telse if (!strcmp(arg, \"-b\") || !strcmp(arg, \"--ignore-space-change\"))\n \t\tDIFF_XDL_SET(options, IGNORE_WHITESPACE_CHANGE);\n-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369464","messageId":"20190216113655.25728-22-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113655.25728-1-pclouds@gmail.com","subject":"[PATCH v3 21/21] diff-parseopt: convert --ignore-some-changes","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-16T11:36:55Z","receivedAt":"2019-02-16T11:38:54Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 27 ++++++++++++++++-----------\n 1 file changed, 16 insertions(+), 11 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 33492e754f..a63ee4a44d 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5109,6 +5109,21 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT(0, \"minimal\", &options->xdl_opts,\n \t\t\tN_(\"produce the smallest possible diff\"),\n \t\t\tXDF_NEED_MINIMAL),\n+\t\tOPT_BIT_F('w', \"ignore-all-space\", &options->xdl_opts,\n+\t\t\t  N_(\"ignore whitespace when comparing lines\"),\n+\t\t\t  XDF_IGNORE_WHITESPACE, PARSE_OPT_NONEG),\n+\t\tOPT_BIT_F('b', \"ignore-space-change\", &options->xdl_opts,\n+\t\t\t  N_(\"ignore changes in amount of whitespace\"),\n+\t\t\t  XDF_IGNORE_WHITESPACE_CHANGE, PARSE_OPT_NONEG),\n+\t\tOPT_BIT_F(0, \"ignore-space-at-eol\", &options->xdl_opts,\n+\t\t\t  N_(\"ignore changes in whitespace at EOL\"),\n+\t\t\t  XDF_IGNORE_WHITESPACE_AT_EOL, PARSE_OPT_NONEG),\n+\t\tOPT_BIT_F(0, \"ignore-cr-at-eol\", &options->xdl_opts,\n+\t\t\t  N_(\"ignore carrier-return at the end of line\"),\n+\t\t\t  XDF_IGNORE_CR_AT_EOL, PARSE_OPT_NONEG),\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 \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\tOPT_CALLBACK_F(0, \"relative\", options, N_(\"<prefix>\"),\n@@ -5147,17 +5162,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* xdiff options */\n-\tif (!strcmp(arg, \"-w\") || !strcmp(arg, \"--ignore-all-space\"))\n-\t\tDIFF_XDL_SET(options, IGNORE_WHITESPACE);\n-\telse if (!strcmp(arg, \"-b\") || !strcmp(arg, \"--ignore-space-change\"))\n-\t\tDIFF_XDL_SET(options, IGNORE_WHITESPACE_CHANGE);\n-\telse if (!strcmp(arg, \"--ignore-space-at-eol\"))\n-\t\tDIFF_XDL_SET(options, IGNORE_WHITESPACE_AT_EOL);\n-\telse if (!strcmp(arg, \"--ignore-cr-at-eol\"))\n-\t\tDIFF_XDL_SET(options, IGNORE_CR_AT_EOL);\n-\telse if (!strcmp(arg, \"--ignore-blank-lines\"))\n-\t\tDIFF_XDL_SET(options, IGNORE_BLANK_LINES);\n-\telse if (!strcmp(arg, \"--indent-heuristic\"))\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-- \n2.21.0.rc0.328.g0e39304f8d\n\n"},{"id":"369511","messageId":"7cb0cee2-0776-29f3-1904-c5c091c67e79@gmail.com","threadId":"50424","inReplyTo":"20190216113655.25728-4-pclouds@gmail.com","subject":"Re: [PATCH v3 03/21] diff-parseopt: convert --dirstat and friends","fromName":"Andrei Rybak","fromEmail":"rybak.a.v@gmail.com","sentAt":"2019-02-17T13:39:53Z","receivedAt":"2019-02-17T13:40:03Z","isPatch":true,"sender":{"key":"rybak.a.v@gmail.com","avatar":"https://avatars.githubusercontent.com/u/624072?v=4"},"body":"On 2/16/19 12:36 PM, Nguyễn Thái Ngọc Duy wrote:\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>  Documentation/diff-options.txt |  7 ++++++\n>  diff.c                         | 39 +++++++++++++++++++++++++---------\n>  2 files changed, 36 insertions(+), 10 deletions(-)\n> \n> diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt\n> index 0711734b12..058d93ec4f 100644\n> --- a/Documentation/diff-options.txt\n> +++ b/Documentation/diff-options.txt\n> @@ -148,6 +148,7 @@ These parameters can also be set individually with `--stat-width=<width>`,\n>  \tnumber of modified files, as well as number of added and deleted\n>  \tlines.\n>  \n> +-X<param1,param2,...>::\n>  --dirstat[=<param1,param2,...>]::\n\n<param1,param2,...> should probably marked as optional for -X\n\n>  \tOutput the distribution of relative amount of changes for each\n>  \tsub-directory. The behavior of `--dirstat` can be customized by\n> @@ -192,6 +193,12 @@ directories with less than 10% of the total amount of changed files,\n>  and accumulating child directory counts in the parent directories:\n>  `--dirstat=files,10,cumulative`.\n>  \n> +--cumulative::\n> +\tSynonym for --dirstat=cumulative\n> +\n> +--dirstat-by-file[=<param1,param2>...]::\n> +\tSynonym for --dirstat=files,param1,param2...\n> +\n>  --summary::\n>  \tOutput a condensed summary of extended header information\n>  \tsuch as creations, renames and mode changes.\n"},{"id":"369736","messageId":"xmqq5ztew5t9.fsf@gitster-ct.c.googlers.com","threadId":"50424","inReplyTo":"20190216113655.25728-2-pclouds@gmail.com","subject":"Re: [PATCH v3 01/21] diff-parseopt: convert --patch-with-raw","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-02-20T20:41:54Z","receivedAt":"2019-02-20T20:42:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>  diff.c | 9 +++++----\n>  1 file changed, 5 insertions(+), 4 deletions(-)\n>\n> diff --git a/diff.c b/diff.c\n> index 4bc9df7362..12e333c67f 100644\n> --- a/diff.c\n> +++ b/diff.c\n> @@ -4901,6 +4901,10 @@ static void prep_parse_options(struct diff_options *options)\n>  \t\tOPT_BIT_F(0, \"raw\", &options->output_format,\n>  \t\t\t  N_(\"generate the diff in raw format\"),\n>  \t\t\t  DIFF_FORMAT_RAW, PARSE_OPT_NONEG),\n> +\t\tOPT_BITOP(0, \"patch-with-raw\", &options->output_format,\n> +\t\t\t  N_(\"synonym for '-p --raw'\"),\n> +\t\t\t  DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW,\n> +\t\t\t  DIFF_FORMAT_NO_OUTPUT),\n>  \t\tOPT_END()\n>  \t};\n>  \n> @@ -4929,10 +4933,7 @@ int diff_opt_parse(struct diff_options *options,\n>  \t\treturn ac;\n>  \n>  \t/* Output format options */\n> -\tif (!strcmp(arg, \"--patch-with-raw\")) {\n> -\t\tenable_patch_output(&options->output_format);\n> -\t\toptions->output_format |= DIFF_FORMAT_RAW;\n> -\t} else if (!strcmp(arg, \"--numstat\"))\n> +\tif (!strcmp(arg, \"--numstat\"))\n>  \t\toptions->output_format |= DIFF_FORMAT_NUMSTAT;\n>  \telse if (!strcmp(arg, \"--shortstat\"))\n>  \t\toptions->output_format |= DIFF_FORMAT_SHORTSTAT;\n\nQuite straight-forward, and makes us anticipate the eventual removal\nof enable_patch_output() helper function  ;-)\n\n"},{"id":"369739","messageId":"xmqq1s42w4k7.fsf@gitster-ct.c.googlers.com","threadId":"50424","inReplyTo":"20190216113655.25728-11-pclouds@gmail.com","subject":"Re: [PATCH v3 10/21] diff-parseopt: convert --stat*","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-02-20T21:08:56Z","receivedAt":"2019-02-20T21:09:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> -static int stat_opt(struct diff_options *options, const char **av)\n> +static int diff_opt_stat(const struct option *opt, const char *value, int unset)\n>  {\n> -\tconst char *arg = av[0];\n> -\tchar *end;\n> +\tstruct diff_options *options = opt->value;\n> ...\n> -\tswitch (*arg) {\n> -\tcase '-':\n> -\t\tif (skip_prefix(arg, \"-width\", &arg)) {\n> -\t\t\tif (*arg == '=')\n> -\t\t\t\twidth = strtoul(arg + 1, &end, 10);\n> -\t\t\telse if (!*arg && !av[1])\n> -\t\t\t\tdie_want_option(\"--stat-width\");\n> -\t\t\telse if (!*arg) {\n> -\t\t\t\twidth = strtoul(av[1], &end, 10);\n> -\t\t\t\targcount = 2;\n> -\t\t\t}\n> ...\n> +\tif (!strcmp(opt->long_name, \"stat\")) {\n> +\t\tif (value) {\n> +\t\t\twidth = strtoul(value, &end, 10);\n> +\t\t\tif (*end == ',')\n> +\t\t\t\tname_width = strtoul(end+1, &end, 10);\n> +\t\t\tif (*end == ',')\n> +\t\t\t\tcount = strtoul(end+1, &end, 10);\n> +\t\t\tif (*end)\n> +\t\t\t\treturn error(_(\"invalid --stat value: %s\"), value);\n>  \t\t}\n\nIt took me a while to recall and figure out what the original is\ndoing, primarily because the code was designed to handle both\n\"-$option $arg\" and \"--$option=$arg\".  But thanks to the switch to\nparse-options API, this helper no longer has to worry about that,\nwhich is a very big plus.  It only needs to parse what is in value.\n\nVery nice.\n"},{"id":"369741","messageId":"xmqqwoluuns8.fsf@gitster-ct.c.googlers.com","threadId":"50424","inReplyTo":"20190216113346.25000-1-pclouds@gmail.com","subject":"Re: [PATCH v2 00/21] nd/diff-parseopt part 2","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-02-20T21:56:39Z","receivedAt":"2019-02-20T21:56:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> v2 changes the subject line to help clarify in \"git log --oneline\"\n\nSome were not straight-forward converison, but nevertheless looked\ncorrect.  Thanks.\n\n>\n> Nguyễn Thái Ngọc Duy (21):\n>   diff-parseopt: convert --patch-with-raw\n>   diff-parseopt: convert --numstat and --shortstat\n>   diff-parseopt: convert --dirstat and friends\n>   diff-parseopt: convert --check\n>   diff-parseopt: convert --summary\n>   diff-parseopt: convert --patch-with-stat\n>   diff-parseopt: convert --name-only\n>   diff-parseopt: convert --name-status\n>   diff-parseopt: convert -s|--no-patch\n>   diff-parseopt: convert --stat*\n>   diff-parseopt: convert --[no-]compact-summary\n>   diff-parseopt: convert --output-*\n>   diff-parseopt: convert -B|--break-rewrites\n>   diff-parseopt: convert -M|--find-renames\n>   diff-parseopt: convert -D|--irreversible-delete\n>   diff-parseopt: convert -C|--find-copies\n>   diff-parseopt: convert --find-copies-harder\n>   diff-parseopt: convert --no-renames|--[no--rename-empty\n>   diff-parseopt: convert --relative\n>   diff-parseopt: convert --[no-]minimal\n>   diff-parseopt: convert --ignore-some-changes\n>\n>  Documentation/diff-options.txt |  20 ++\n>  diff.c                         | 510 +++++++++++++++++++--------------\n>  2 files changed, 319 insertions(+), 211 deletions(-)\n"},{"id":"369770","messageId":"20190221111621.27180-1-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190216113655.25728-1-pclouds@gmail.com","subject":"[PATCH v4 00/21] nd/diff-parseopt-2 updates","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-21T11:16:00Z","receivedAt":"2019-02-21T11:16:35Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Super tiny document update noticed by Andrei.\n\nRange-diff dựa trên v3:\n 1:  38230c7de4 !  1:  070164af4d diff-parseopt: convert --dirstat and friends\n    @@ -3,7 +3,6 @@\n         diff-parseopt: convert --dirstat and friends\n     \n         Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n    -    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n     \n      diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt\n      --- a/Documentation/diff-options.txt\n    @@ -12,7 +11,7 @@\n      \tnumber of modified files, as well as number of added and deleted\n      \tlines.\n      \n    -+-X<param1,param2,...>::\n    ++-X[<param1,param2,...>]::\n      --dirstat[=<param1,param2,...>]::\n      \tOutput the distribution of relative amount of changes for each\n      \tsub-directory. The behavior of `--dirstat` can be customized by\n 2:  3ae4e6cd92 =  2:  89b1103e76 diff-parseopt: convert --check\n 3:  127056f59c =  3:  fedf018125 diff-parseopt: convert --summary\n 4:  f6329c8d41 =  4:  13cb7ab220 diff-parseopt: convert --patch-with-stat\n 5:  aec0afbe0d =  5:  f1aad0dd16 diff-parseopt: convert --name-only\n 6:  bcbeaf3792 =  6:  69724a34d5 diff-parseopt: convert --name-status\n 7:  23a9f378ed =  7:  6d388db7ae diff-parseopt: convert -s|--no-patch\n 8:  3376918b02 =  8:  c378c333fe diff-parseopt: convert --stat*\n 9:  6bc89cece3 =  9:  089d37bc74 diff-parseopt: convert --[no-]compact-summary\n10:  327e4ce71d = 10:  36731a8c60 diff-parseopt: convert --output-*\n11:  a7fd8b2637 = 11:  c043243fac diff-parseopt: convert -B|--break-rewrites\n12:  abe34ced9b = 12:  52da05a2fe diff-parseopt: convert -M|--find-renames\n13:  27a03cf277 = 13:  4fe9111123 diff-parseopt: convert -D|--irreversible-delete\n14:  d0e744740a = 14:  b85e3bb302 diff-parseopt: convert -C|--find-copies\n15:  71d80976eb = 15:  bd7f8fe4ae diff-parseopt: convert --find-copies-harder\n16:  e066d3b245 = 16:  ed3b271d82 diff-parseopt: convert --no-renames|--[no--rename-empty\n17:  f35c5d409d = 17:  6bebd80fee diff-parseopt: convert --relative\n18:  a560fa8cd6 = 18:  a6ae538b90 diff-parseopt: convert --[no-]minimal\n19:  97c424c1ce = 19:  ed3634e0bd diff-parseopt: convert --ignore-some-changes\n\nNguyễn Thái Ngọc Duy (21):\n  diff-parseopt: convert --patch-with-raw\n  diff-parseopt: convert --numstat and --shortstat\n  diff-parseopt: convert --dirstat and friends\n  diff-parseopt: convert --check\n  diff-parseopt: convert --summary\n  diff-parseopt: convert --patch-with-stat\n  diff-parseopt: convert --name-only\n  diff-parseopt: convert --name-status\n  diff-parseopt: convert -s|--no-patch\n  diff-parseopt: convert --stat*\n  diff-parseopt: convert --[no-]compact-summary\n  diff-parseopt: convert --output-*\n  diff-parseopt: convert -B|--break-rewrites\n  diff-parseopt: convert -M|--find-renames\n  diff-parseopt: convert -D|--irreversible-delete\n  diff-parseopt: convert -C|--find-copies\n  diff-parseopt: convert --find-copies-harder\n  diff-parseopt: convert --no-renames|--[no--rename-empty\n  diff-parseopt: convert --relative\n  diff-parseopt: convert --[no-]minimal\n  diff-parseopt: convert --ignore-some-changes\n\n Documentation/diff-options.txt |  20 ++\n diff.c                         | 510 +++++++++++++++++++--------------\n 2 files changed, 319 insertions(+), 211 deletions(-)\n\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"369771","messageId":"20190221111621.27180-2-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190221111621.27180-1-pclouds@gmail.com","subject":"[PATCH v4 01/21] diff-parseopt: convert --patch-with-raw","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-21T11:16:01Z","receivedAt":"2019-02-21T11:16:39Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 9 +++++----\n 1 file changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 4bc9df7362..12e333c67f 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4901,6 +4901,10 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT_F(0, \"raw\", &options->output_format,\n \t\t\t  N_(\"generate the diff in raw format\"),\n \t\t\t  DIFF_FORMAT_RAW, PARSE_OPT_NONEG),\n+\t\tOPT_BITOP(0, \"patch-with-raw\", &options->output_format,\n+\t\t\t  N_(\"synonym for '-p --raw'\"),\n+\t\t\t  DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW,\n+\t\t\t  DIFF_FORMAT_NO_OUTPUT),\n \t\tOPT_END()\n \t};\n \n@@ -4929,10 +4933,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--patch-with-raw\")) {\n-\t\tenable_patch_output(&options->output_format);\n-\t\toptions->output_format |= DIFF_FORMAT_RAW;\n-\t} else if (!strcmp(arg, \"--numstat\"))\n+\tif (!strcmp(arg, \"--numstat\"))\n \t\toptions->output_format |= DIFF_FORMAT_NUMSTAT;\n \telse if (!strcmp(arg, \"--shortstat\"))\n \t\toptions->output_format |= DIFF_FORMAT_SHORTSTAT;\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"369772","messageId":"20190221111621.27180-3-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190221111621.27180-1-pclouds@gmail.com","subject":"[PATCH v4 02/21] diff-parseopt: convert --numstat and --shortstat","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-21T11:16:02Z","receivedAt":"2019-02-21T11:16:45Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 12 +++++++-----\n 1 file changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 12e333c67f..419b6ac4ae 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4905,6 +4905,12 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t  N_(\"synonym for '-p --raw'\"),\n \t\t\t  DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW,\n \t\t\t  DIFF_FORMAT_NO_OUTPUT),\n+\t\tOPT_BIT_F(0, \"numstat\", &options->output_format,\n+\t\t\t  N_(\"machine friendly --stat\"),\n+\t\t\t  DIFF_FORMAT_NUMSTAT, PARSE_OPT_NONEG),\n+\t\tOPT_BIT_F(0, \"shortstat\", &options->output_format,\n+\t\t\t  N_(\"output only the last line of --stat\"),\n+\t\t\t  DIFF_FORMAT_SHORTSTAT, PARSE_OPT_NONEG),\n \t\tOPT_END()\n \t};\n \n@@ -4933,11 +4939,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--numstat\"))\n-\t\toptions->output_format |= DIFF_FORMAT_NUMSTAT;\n-\telse if (!strcmp(arg, \"--shortstat\"))\n-\t\toptions->output_format |= DIFF_FORMAT_SHORTSTAT;\n-\telse if (skip_prefix(arg, \"-X\", &arg) ||\n+\tif (skip_prefix(arg, \"-X\", &arg) ||\n \t\t skip_to_optional_arg(arg, \"--dirstat\", &arg))\n \t\treturn parse_dirstat_opt(options, arg);\n \telse if (!strcmp(arg, \"--cumulative\"))\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"369773","messageId":"20190221111621.27180-4-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190221111621.27180-1-pclouds@gmail.com","subject":"[PATCH v4 03/21] diff-parseopt: convert --dirstat and friends","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-21T11:16:03Z","receivedAt":"2019-02-21T11:16: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 Documentation/diff-options.txt |  7 ++++++\n diff.c                         | 39 +++++++++++++++++++++++++---------\n 2 files changed, 36 insertions(+), 10 deletions(-)\n\ndiff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt\nindex 0711734b12..7b81b852ca 100644\n--- a/Documentation/diff-options.txt\n+++ b/Documentation/diff-options.txt\n@@ -148,6 +148,7 @@ These parameters can also be set individually with `--stat-width=<width>`,\n \tnumber of modified files, as well as number of added and deleted\n \tlines.\n \n+-X[<param1,param2,...>]::\n --dirstat[=<param1,param2,...>]::\n \tOutput the distribution of relative amount of changes for each\n \tsub-directory. The behavior of `--dirstat` can be customized by\n@@ -192,6 +193,12 @@ directories with less than 10% of the total amount of changed files,\n and accumulating child directory counts in the parent directories:\n `--dirstat=files,10,cumulative`.\n \n+--cumulative::\n+\tSynonym for --dirstat=cumulative\n+\n+--dirstat-by-file[=<param1,param2>...]::\n+\tSynonym for --dirstat=files,param1,param2...\n+\n --summary::\n \tOutput a condensed summary of extended header information\n \tsuch as creations, renames and mode changes.\ndiff --git a/diff.c b/diff.c\nindex 419b6ac4ae..1cdbe8e688 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4867,6 +4867,22 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)\n \treturn 1;\n }\n \n+static int diff_opt_dirstat(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 (!strcmp(opt->long_name, \"cumulative\")) {\n+\t\tif (arg)\n+\t\t\tBUG(\"how come --cumulative take a value?\");\n+\t\targ = \"cumulative\";\n+\t} else if (!strcmp(opt->long_name, \"dirstat-by-file\"))\n+\t\tparse_dirstat_opt(options, \"files\");\n+\tparse_dirstat_opt(options, arg ? arg : \"\");\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@@ -4911,6 +4927,18 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT_F(0, \"shortstat\", &options->output_format,\n \t\t\t  N_(\"output only the last line of --stat\"),\n \t\t\t  DIFF_FORMAT_SHORTSTAT, PARSE_OPT_NONEG),\n+\t\tOPT_CALLBACK_F('X', \"dirstat\", options, N_(\"<param1,param2>...\"),\n+\t\t\t       N_(\"output the distribution of relative amount of changes for each sub-directory\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n+\t\t\t       diff_opt_dirstat),\n+\t\tOPT_CALLBACK_F(0, \"cumulative\", options, NULL,\n+\t\t\t       N_(\"synonym for --dirstat=cumulative\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_NOARG,\n+\t\t\t       diff_opt_dirstat),\n+\t\tOPT_CALLBACK_F(0, \"dirstat-by-file\", options, N_(\"<param1,param2>...\"),\n+\t\t\t       N_(\"synonym for --dirstat=files,param1,param2...\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n+\t\t\t       diff_opt_dirstat),\n \t\tOPT_END()\n \t};\n \n@@ -4939,16 +4967,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (skip_prefix(arg, \"-X\", &arg) ||\n-\t\t skip_to_optional_arg(arg, \"--dirstat\", &arg))\n-\t\treturn parse_dirstat_opt(options, arg);\n-\telse if (!strcmp(arg, \"--cumulative\"))\n-\t\treturn parse_dirstat_opt(options, \"cumulative\");\n-\telse if (skip_to_optional_arg(arg, \"--dirstat-by-file\", &arg)) {\n-\t\tparse_dirstat_opt(options, \"files\");\n-\t\treturn parse_dirstat_opt(options, arg);\n-\t}\n-\telse if (!strcmp(arg, \"--check\"))\n+\tif (!strcmp(arg, \"--check\"))\n \t\toptions->output_format |= DIFF_FORMAT_CHECKDIFF;\n \telse if (!strcmp(arg, \"--summary\"))\n \t\toptions->output_format |= DIFF_FORMAT_SUMMARY;\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"369774","messageId":"20190221111621.27180-5-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190221111621.27180-1-pclouds@gmail.com","subject":"[PATCH v4 04/21] diff-parseopt: convert --check","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-21T11:16:04Z","receivedAt":"2019-02-21T11:16: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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 1cdbe8e688..5e16082091 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4939,6 +4939,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       N_(\"synonym for --dirstat=files,param1,param2...\"),\n \t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n \t\t\t       diff_opt_dirstat),\n+\t\tOPT_BIT_F(0, \"check\", &options->output_format,\n+\t\t\t  N_(\"warn if changes introduce conflict markers or whitespace errors\"),\n+\t\t\t  DIFF_FORMAT_CHECKDIFF, PARSE_OPT_NONEG),\n \t\tOPT_END()\n \t};\n \n@@ -4967,9 +4970,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--check\"))\n-\t\toptions->output_format |= DIFF_FORMAT_CHECKDIFF;\n-\telse if (!strcmp(arg, \"--summary\"))\n+\tif (!strcmp(arg, \"--summary\"))\n \t\toptions->output_format |= DIFF_FORMAT_SUMMARY;\n \telse if (!strcmp(arg, \"--patch-with-stat\")) {\n \t\tenable_patch_output(&options->output_format);\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"369775","messageId":"20190221111621.27180-6-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190221111621.27180-1-pclouds@gmail.com","subject":"[PATCH v4 05/21] diff-parseopt: convert --summary","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-21T11:16:05Z","receivedAt":"2019-02-21T11:16:59Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 5e16082091..0276f25200 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4942,6 +4942,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT_F(0, \"check\", &options->output_format,\n \t\t\t  N_(\"warn if changes introduce conflict markers or whitespace errors\"),\n \t\t\t  DIFF_FORMAT_CHECKDIFF, PARSE_OPT_NONEG),\n+\t\tOPT_BIT_F(0, \"summary\", &options->output_format,\n+\t\t\t  N_(\"condensed summary such as creations, renames and mode changes\"),\n+\t\t\t  DIFF_FORMAT_SUMMARY, PARSE_OPT_NONEG),\n \t\tOPT_END()\n \t};\n \n@@ -4970,9 +4973,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--summary\"))\n-\t\toptions->output_format |= DIFF_FORMAT_SUMMARY;\n-\telse if (!strcmp(arg, \"--patch-with-stat\")) {\n+\tif (!strcmp(arg, \"--patch-with-stat\")) {\n \t\tenable_patch_output(&options->output_format);\n \t\toptions->output_format |= DIFF_FORMAT_DIFFSTAT;\n \t} else if (!strcmp(arg, \"--name-only\"))\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"369776","messageId":"20190221111621.27180-7-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190221111621.27180-1-pclouds@gmail.com","subject":"[PATCH v4 06/21] diff-parseopt: convert --patch-with-stat","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-21T11:16:06Z","receivedAt":"2019-02-21T11:17: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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 9 +++++----\n 1 file changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 0276f25200..b9811aefef 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4921,6 +4921,10 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t  N_(\"synonym for '-p --raw'\"),\n \t\t\t  DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW,\n \t\t\t  DIFF_FORMAT_NO_OUTPUT),\n+\t\tOPT_BITOP(0, \"patch-with-stat\", &options->output_format,\n+\t\t\t  N_(\"synonym for '-p --stat'\"),\n+\t\t\t  DIFF_FORMAT_PATCH | DIFF_FORMAT_DIFFSTAT,\n+\t\t\t  DIFF_FORMAT_NO_OUTPUT),\n \t\tOPT_BIT_F(0, \"numstat\", &options->output_format,\n \t\t\t  N_(\"machine friendly --stat\"),\n \t\t\t  DIFF_FORMAT_NUMSTAT, PARSE_OPT_NONEG),\n@@ -4973,10 +4977,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--patch-with-stat\")) {\n-\t\tenable_patch_output(&options->output_format);\n-\t\toptions->output_format |= DIFF_FORMAT_DIFFSTAT;\n-\t} else if (!strcmp(arg, \"--name-only\"))\n+\tif (!strcmp(arg, \"--name-only\"))\n \t\toptions->output_format |= DIFF_FORMAT_NAME;\n \telse if (!strcmp(arg, \"--name-status\"))\n \t\toptions->output_format |= DIFF_FORMAT_NAME_STATUS;\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"369777","messageId":"20190221111621.27180-8-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190221111621.27180-1-pclouds@gmail.com","subject":"[PATCH v4 07/21] diff-parseopt: convert --name-only","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-21T11:16:07Z","receivedAt":"2019-02-21T11:17:10Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex b9811aefef..7ea308814f 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4949,6 +4949,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT_F(0, \"summary\", &options->output_format,\n \t\t\t  N_(\"condensed summary such as creations, renames and mode changes\"),\n \t\t\t  DIFF_FORMAT_SUMMARY, PARSE_OPT_NONEG),\n+\t\tOPT_BIT_F(0, \"name-only\", &options->output_format,\n+\t\t\t  N_(\"show only names of changed files\"),\n+\t\t\t  DIFF_FORMAT_NAME, PARSE_OPT_NONEG),\n \t\tOPT_END()\n \t};\n \n@@ -4977,9 +4980,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--name-only\"))\n-\t\toptions->output_format |= DIFF_FORMAT_NAME;\n-\telse if (!strcmp(arg, \"--name-status\"))\n+\tif (!strcmp(arg, \"--name-status\"))\n \t\toptions->output_format |= DIFF_FORMAT_NAME_STATUS;\n \telse if (!strcmp(arg, \"-s\") || !strcmp(arg, \"--no-patch\"))\n \t\toptions->output_format |= DIFF_FORMAT_NO_OUTPUT;\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"369778","messageId":"20190221111621.27180-9-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190221111621.27180-1-pclouds@gmail.com","subject":"[PATCH v4 08/21] diff-parseopt: convert --name-status","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-21T11:16:08Z","receivedAt":"2019-02-21T11:17: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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 7ea308814f..99047fb5fe 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4952,6 +4952,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT_F(0, \"name-only\", &options->output_format,\n \t\t\t  N_(\"show only names of changed files\"),\n \t\t\t  DIFF_FORMAT_NAME, PARSE_OPT_NONEG),\n+\t\tOPT_BIT_F(0, \"name-status\", &options->output_format,\n+\t\t\t  N_(\"show only names and status of changed files\"),\n+\t\t\t  DIFF_FORMAT_NAME_STATUS, PARSE_OPT_NONEG),\n \t\tOPT_END()\n \t};\n \n@@ -4980,9 +4983,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--name-status\"))\n-\t\toptions->output_format |= DIFF_FORMAT_NAME_STATUS;\n-\telse if (!strcmp(arg, \"-s\") || !strcmp(arg, \"--no-patch\"))\n+\tif (!strcmp(arg, \"-s\") || !strcmp(arg, \"--no-patch\"))\n \t\toptions->output_format |= DIFF_FORMAT_NO_OUTPUT;\n \telse if (starts_with(arg, \"--stat\"))\n \t\t/* --stat, --stat-width, --stat-name-width, or --stat-count */\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"369779","messageId":"20190221111621.27180-10-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190221111621.27180-1-pclouds@gmail.com","subject":"[PATCH v4 09/21] diff-parseopt: convert -s|--no-patch","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-21T11:16:09Z","receivedAt":"2019-02-21T11:17:20Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 99047fb5fe..9c8f5336bc 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4906,6 +4906,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BITOP('p', \"patch\", &options->output_format,\n \t\t\t  N_(\"generate patch\"),\n \t\t\t  DIFF_FORMAT_PATCH, DIFF_FORMAT_NO_OUTPUT),\n+\t\tOPT_BIT_F('s', \"no-patch\", &options->output_format,\n+\t\t\t  N_(\"suppress diff output\"),\n+\t\t\t  DIFF_FORMAT_NO_OUTPUT, PARSE_OPT_NONEG),\n \t\tOPT_BITOP('u', NULL, &options->output_format,\n \t\t\t  N_(\"generate patch\"),\n \t\t\t  DIFF_FORMAT_PATCH, DIFF_FORMAT_NO_OUTPUT),\n@@ -4983,9 +4986,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"-s\") || !strcmp(arg, \"--no-patch\"))\n-\t\toptions->output_format |= DIFF_FORMAT_NO_OUTPUT;\n-\telse if (starts_with(arg, \"--stat\"))\n+\tif (starts_with(arg, \"--stat\"))\n \t\t/* --stat, --stat-width, --stat-name-width, or --stat-count */\n \t\treturn stat_opt(options, av);\n \telse if (!strcmp(arg, \"--compact-summary\")) {\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"369780","messageId":"20190221111621.27180-11-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190221111621.27180-1-pclouds@gmail.com","subject":"[PATCH v4 10/21] diff-parseopt: convert --stat*","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-21T11:16:10Z","receivedAt":"2019-02-21T11:17:25Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 118 +++++++++++++++++++++++++--------------------------------\n 1 file changed, 52 insertions(+), 66 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 9c8f5336bc..1feb13deb3 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -104,11 +104,6 @@ static const char *color_diff_slots[] = {\n \t[DIFF_FILE_NEW_BOLD]\t      = \"newBold\",\n };\n \n-static NORETURN void die_want_option(const char *option_name)\n-{\n-\tdie(_(\"option '%s' requires a value\"), option_name);\n-}\n-\n define_list_config_array_extra(color_diff_slots, {\"plain\"});\n \n static int parse_diff_color_slot(const char *var)\n@@ -4661,77 +4656,56 @@ int parse_long_opt(const char *opt, const char **argv,\n \treturn 2;\n }\n \n-static int stat_opt(struct diff_options *options, const char **av)\n+static int diff_opt_stat(const struct option *opt, const char *value, int unset)\n {\n-\tconst char *arg = av[0];\n-\tchar *end;\n+\tstruct diff_options *options = opt->value;\n \tint width = options->stat_width;\n \tint name_width = options->stat_name_width;\n \tint graph_width = options->stat_graph_width;\n \tint count = options->stat_count;\n-\tint argcount = 1;\n+\tchar *end;\n \n-\tif (!skip_prefix(arg, \"--stat\", &arg))\n-\t\tBUG(\"stat option does not begin with --stat: %s\", arg);\n-\tend = (char *)arg;\n+\tBUG_ON_OPT_NEG(unset);\n \n-\tswitch (*arg) {\n-\tcase '-':\n-\t\tif (skip_prefix(arg, \"-width\", &arg)) {\n-\t\t\tif (*arg == '=')\n-\t\t\t\twidth = strtoul(arg + 1, &end, 10);\n-\t\t\telse if (!*arg && !av[1])\n-\t\t\t\tdie_want_option(\"--stat-width\");\n-\t\t\telse if (!*arg) {\n-\t\t\t\twidth = strtoul(av[1], &end, 10);\n-\t\t\t\targcount = 2;\n-\t\t\t}\n-\t\t} else if (skip_prefix(arg, \"-name-width\", &arg)) {\n-\t\t\tif (*arg == '=')\n-\t\t\t\tname_width = strtoul(arg + 1, &end, 10);\n-\t\t\telse if (!*arg && !av[1])\n-\t\t\t\tdie_want_option(\"--stat-name-width\");\n-\t\t\telse if (!*arg) {\n-\t\t\t\tname_width = strtoul(av[1], &end, 10);\n-\t\t\t\targcount = 2;\n-\t\t\t}\n-\t\t} else if (skip_prefix(arg, \"-graph-width\", &arg)) {\n-\t\t\tif (*arg == '=')\n-\t\t\t\tgraph_width = strtoul(arg + 1, &end, 10);\n-\t\t\telse if (!*arg && !av[1])\n-\t\t\t\tdie_want_option(\"--stat-graph-width\");\n-\t\t\telse if (!*arg) {\n-\t\t\t\tgraph_width = strtoul(av[1], &end, 10);\n-\t\t\t\targcount = 2;\n-\t\t\t}\n-\t\t} else if (skip_prefix(arg, \"-count\", &arg)) {\n-\t\t\tif (*arg == '=')\n-\t\t\t\tcount = strtoul(arg + 1, &end, 10);\n-\t\t\telse if (!*arg && !av[1])\n-\t\t\t\tdie_want_option(\"--stat-count\");\n-\t\t\telse if (!*arg) {\n-\t\t\t\tcount = strtoul(av[1], &end, 10);\n-\t\t\t\targcount = 2;\n-\t\t\t}\n+\tif (!strcmp(opt->long_name, \"stat\")) {\n+\t\tif (value) {\n+\t\t\twidth = strtoul(value, &end, 10);\n+\t\t\tif (*end == ',')\n+\t\t\t\tname_width = strtoul(end+1, &end, 10);\n+\t\t\tif (*end == ',')\n+\t\t\t\tcount = strtoul(end+1, &end, 10);\n+\t\t\tif (*end)\n+\t\t\t\treturn error(_(\"invalid --stat value: %s\"), value);\n \t\t}\n-\t\tbreak;\n-\tcase '=':\n-\t\twidth = strtoul(arg+1, &end, 10);\n-\t\tif (*end == ',')\n-\t\t\tname_width = strtoul(end+1, &end, 10);\n-\t\tif (*end == ',')\n-\t\t\tcount = strtoul(end+1, &end, 10);\n-\t}\n+\t} else if (!strcmp(opt->long_name, \"stat-width\")) {\n+\t\twidth = strtoul(value, &end, 10);\n+\t\tif (*end)\n+\t\t\treturn error(_(\"%s expects a numerical value\"),\n+\t\t\t\t     opt->long_name);\n+\t} else if (!strcmp(opt->long_name, \"stat-name-width\")) {\n+\t\tname_width = strtoul(value, &end, 10);\n+\t\tif (*end)\n+\t\t\treturn error(_(\"%s expects a numerical value\"),\n+\t\t\t\t     opt->long_name);\n+\t} else if (!strcmp(opt->long_name, \"stat-graph-width\")) {\n+\t\tgraph_width = strtoul(value, &end, 10);\n+\t\tif (*end)\n+\t\t\treturn error(_(\"%s expects a numerical value\"),\n+\t\t\t\t     opt->long_name);\n+\t} else if (!strcmp(opt->long_name, \"stat-count\")) {\n+\t\tcount = strtoul(value, &end, 10);\n+\t\tif (*end)\n+\t\t\treturn error(_(\"%s expects a numerical value\"),\n+\t\t\t\t     opt->long_name);\n+\t} else\n+\t\tBUG(\"%s should not get here\", opt->long_name);\n \n-\t/* Important! This checks all the error cases! */\n-\tif (*end)\n-\t\treturn 0;\n \toptions->output_format |= DIFF_FORMAT_DIFFSTAT;\n \toptions->stat_name_width = name_width;\n \toptions->stat_graph_width = graph_width;\n \toptions->stat_width = width;\n \toptions->stat_count = count;\n-\treturn argcount;\n+\treturn 0;\n }\n \n static int parse_dirstat_opt(struct diff_options *options, const char *params)\n@@ -4958,6 +4932,21 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT_F(0, \"name-status\", &options->output_format,\n \t\t\t  N_(\"show only names and status of changed files\"),\n \t\t\t  DIFF_FORMAT_NAME_STATUS, PARSE_OPT_NONEG),\n+\t\tOPT_CALLBACK_F(0, \"stat\", options, N_(\"<width>[,<name-width>[,<count>]]\"),\n+\t\t\t       N_(\"generate diffstat\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_stat),\n+\t\tOPT_CALLBACK_F(0, \"stat-width\", options, N_(\"<width>\"),\n+\t\t\t       N_(\"generate diffstat with a given width\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_stat),\n+\t\tOPT_CALLBACK_F(0, \"stat-name-width\", options, N_(\"<width>\"),\n+\t\t\t       N_(\"generate diffstat with a given name width\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_stat),\n+\t\tOPT_CALLBACK_F(0, \"stat-graph-width\", options, N_(\"<width>\"),\n+\t\t\t       N_(\"generate diffstat with a given graph width\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_stat),\n+\t\tOPT_CALLBACK_F(0, \"stat-count\", options, N_(\"<count>\"),\n+\t\t\t       N_(\"generate diffstat with limited lines\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_stat),\n \t\tOPT_END()\n \t};\n \n@@ -4986,10 +4975,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (starts_with(arg, \"--stat\"))\n-\t\t/* --stat, --stat-width, --stat-name-width, or --stat-count */\n-\t\treturn stat_opt(options, av);\n-\telse if (!strcmp(arg, \"--compact-summary\")) {\n+\tif (!strcmp(arg, \"--compact-summary\")) {\n \t\t options->flags.stat_with_summary = 1;\n \t\t options->output_format |= DIFF_FORMAT_DIFFSTAT;\n \t} else if (!strcmp(arg, \"--no-compact-summary\"))\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"369781","messageId":"20190221111621.27180-12-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190221111621.27180-1-pclouds@gmail.com","subject":"[PATCH v4 11/21] diff-parseopt: convert --[no-]compact-summary","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-21T11:16:11Z","receivedAt":"2019-02-21T11:17:29Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 25 +++++++++++++++++++------\n 1 file changed, 19 insertions(+), 6 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 1feb13deb3..b24f6825a1 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4841,6 +4841,21 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)\n \treturn 1;\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+\tstruct diff_options *options = opt->value;\n+\n+\tBUG_ON_OPT_ARG(arg);\n+\tif (unset) {\n+\t\toptions->flags.stat_with_summary = 0;\n+\t} else {\n+\t\toptions->flags.stat_with_summary = 1;\n+\t\toptions->output_format |= DIFF_FORMAT_DIFFSTAT;\n+\t}\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@@ -4947,6 +4962,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_CALLBACK_F(0, \"stat-count\", options, N_(\"<count>\"),\n \t\t\t       N_(\"generate diffstat with limited lines\"),\n \t\t\t       PARSE_OPT_NONEG, diff_opt_stat),\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_END()\n \t};\n \n@@ -4975,12 +4993,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* Output format options */\n-\tif (!strcmp(arg, \"--compact-summary\")) {\n-\t\t options->flags.stat_with_summary = 1;\n-\t\t options->output_format |= DIFF_FORMAT_DIFFSTAT;\n-\t} else if (!strcmp(arg, \"--no-compact-summary\"))\n-\t\t options->flags.stat_with_summary = 0;\n-\telse if (skip_prefix(arg, \"--output-indicator-new=\", &arg))\n+\tif (skip_prefix(arg, \"--output-indicator-new=\", &arg))\n \t\toptions->output_indicators[OUTPUT_INDICATOR_NEW] = arg[0];\n \telse if (skip_prefix(arg, \"--output-indicator-old=\", &arg))\n \t\toptions->output_indicators[OUTPUT_INDICATOR_OLD] = arg[0];\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"369782","messageId":"20190221111621.27180-13-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190221111621.27180-1-pclouds@gmail.com","subject":"[PATCH v4 12/21] diff-parseopt: convert --output-*","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-21T11:16:12Z","receivedAt":"2019-02-21T11:17:36Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This also validates that the user specifies a single character in\n--output-indicator-*, not a string.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/diff-options.txt | 10 +++++\n diff.c                         | 71 +++++++++++++++++++++++++---------\n 2 files changed, 63 insertions(+), 18 deletions(-)\n\ndiff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt\nindex 7b81b852ca..56b731eae5 100644\n--- a/Documentation/diff-options.txt\n+++ b/Documentation/diff-options.txt\n@@ -41,6 +41,16 @@ ifndef::git-format-patch[]\n \tImplies `-p`.\n endif::git-format-patch[]\n \n+--output=<file>::\n+\tOutput to a specific file instead of stdout.\n+\n+--output-indicator-new=<char>::\n+--output-indicator-old=<char>::\n+--output-indicator-context=<char>::\n+\tSpecify the character used to indicate new, old or context\n+\tlines in the generated patch. Normally they are '+', '-' and\n+\t' ' respectively.\n+\n ifndef::git-format-patch[]\n --raw::\n ifndef::git-log[]\ndiff --git a/diff.c b/diff.c\nindex b24f6825a1..8df396cb9a 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4841,6 +4841,19 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)\n \treturn 1;\n }\n \n+static int diff_opt_char(const struct option *opt,\n+\t\t\t const char *arg, int unset)\n+{\n+\tchar *value = opt->value;\n+\n+\tBUG_ON_OPT_NEG(unset);\n+\tif (arg[1])\n+\t\treturn error(_(\"%s expects a character, got '%s'\"),\n+\t\t\t     opt->long_name, arg);\n+\t*value = arg[0];\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@@ -4872,6 +4885,23 @@ static int diff_opt_dirstat(const struct option *opt,\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+{\n+\tstruct diff_options *options = opt->value;\n+\tchar *path;\n+\n+\tBUG_ON_OPT_NEG(unset);\n+\tpath = prefix_filename(ctx->prefix, arg);\n+\toptions->file = xfopen(path, \"w\");\n+\toptions->close_file = 1;\n+\tif (options->use_color != GIT_COLOR_ALWAYS)\n+\t\toptions->use_color = GIT_COLOR_NEVER;\n+\tfree(path);\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@@ -4965,6 +4995,27 @@ 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, \"output-indicator-new\",\n+\t\t\t       &options->output_indicators[OUTPUT_INDICATOR_NEW],\n+\t\t\t       N_(\"<char>\"),\n+\t\t\t       N_(\"specify the character to indicate a new line instead of '+'\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_char),\n+\t\tOPT_CALLBACK_F(0, \"output-indicator-old\",\n+\t\t\t       &options->output_indicators[OUTPUT_INDICATOR_OLD],\n+\t\t\t       N_(\"<char>\"),\n+\t\t\t       N_(\"specify the character to indicate an old line instead of '-'\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_char),\n+\t\tOPT_CALLBACK_F(0, \"output-indicator-context\",\n+\t\t\t       &options->output_indicators[OUTPUT_INDICATOR_CONTEXT],\n+\t\t\t       N_(\"<char>\"),\n+\t\t\t       N_(\"specify the character to indicate a context instead of ' '\"),\n+\t\t\t       PARSE_OPT_NONEG, diff_opt_char),\n+\n+\t\tOPT_GROUP(N_(\"Diff other options\")),\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+\n \t\tOPT_END()\n \t};\n \n@@ -4992,16 +5043,8 @@ int diff_opt_parse(struct diff_options *options,\n \tif (ac)\n \t\treturn ac;\n \n-\t/* Output format options */\n-\tif (skip_prefix(arg, \"--output-indicator-new=\", &arg))\n-\t\toptions->output_indicators[OUTPUT_INDICATOR_NEW] = arg[0];\n-\telse if (skip_prefix(arg, \"--output-indicator-old=\", &arg))\n-\t\toptions->output_indicators[OUTPUT_INDICATOR_OLD] = arg[0];\n-\telse if (skip_prefix(arg, \"--output-indicator-context=\", &arg))\n-\t\toptions->output_indicators[OUTPUT_INDICATOR_CONTEXT] = arg[0];\n-\n \t/* renames options */\n-\telse if (starts_with(arg, \"-B\") ||\n+\tif (starts_with(arg, \"-B\") ||\n \t\t skip_to_optional_arg(arg, \"--break-rewrites\", NULL)) {\n \t\tif ((options->break_opt = diff_scoreopt_parse(arg)) == -1)\n \t\t\treturn error(\"invalid argument to -B: %s\", arg+2);\n@@ -5242,15 +5285,7 @@ int diff_opt_parse(struct diff_options *options,\n \telse if (opt_arg(arg, '\\0', \"inter-hunk-context\",\n \t\t\t &options->interhunkcontext))\n \t\t;\n-\telse if ((argcount = parse_long_opt(\"output\", av, &optarg))) {\n-\t\tchar *path = prefix_filename(prefix, optarg);\n-\t\toptions->file = xfopen(path, \"w\");\n-\t\toptions->close_file = 1;\n-\t\tif (options->use_color != GIT_COLOR_ALWAYS)\n-\t\t\toptions->use_color = GIT_COLOR_NEVER;\n-\t\tfree(path);\n-\t\treturn argcount;\n-\t} else\n+\telse\n \t\treturn 0;\n \treturn 1;\n }\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"369783","messageId":"20190221111621.27180-14-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190221111621.27180-1-pclouds@gmail.com","subject":"[PATCH v4 13/21] diff-parseopt: convert -B|--break-rewrites","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-21T11:16:13Z","receivedAt":"2019-02-21T11:17:41Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 62 ++++++++++++++++++++++++++++++++++------------------------\n 1 file changed, 36 insertions(+), 26 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 8df396cb9a..d2139082b7 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4841,6 +4841,30 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)\n \treturn 1;\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+\tint *break_opt = opt->value;\n+\tint opt1, opt2;\n+\n+\tBUG_ON_OPT_NEG(unset);\n+\tif (!arg)\n+\t\targ = \"\";\n+\topt1 = parse_rename_score(&arg);\n+\tif (*arg == 0)\n+\t\topt2 = 0;\n+\telse if (*arg != '/')\n+\t\treturn error(_(\"%s expects <n>/<m> form\"), opt->long_name);\n+\telse {\n+\t\targ++;\n+\t\topt2 = parse_rename_score(&arg);\n+\t}\n+\tif (*arg != 0)\n+\t\treturn error(_(\"%s expects <n>/<m> form\"), opt->long_name);\n+\t*break_opt = opt1 | (opt2 << 16);\n+\treturn 0;\n+}\n+\n static int diff_opt_char(const struct option *opt,\n \t\t\t const char *arg, int unset)\n {\n@@ -5011,6 +5035,12 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       N_(\"specify the character to indicate a context instead of ' '\"),\n \t\t\t       PARSE_OPT_NONEG, diff_opt_char),\n \n+\t\tOPT_GROUP(N_(\"Diff rename options\")),\n+\t\tOPT_CALLBACK_F('B', \"break-rewrites\", &options->break_opt, N_(\"<n>[/<m>]\"),\n+\t\t\t       N_(\"break complete rewrite changes into pairs of delete and create\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n+\t\t\t       diff_opt_break_rewrites),\n+\n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n \t\t  N_(\"Output to a specific file\"),\n@@ -5044,12 +5074,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* renames options */\n-\tif (starts_with(arg, \"-B\") ||\n-\t\t skip_to_optional_arg(arg, \"--break-rewrites\", NULL)) {\n-\t\tif ((options->break_opt = diff_scoreopt_parse(arg)) == -1)\n-\t\t\treturn error(\"invalid argument to -B: %s\", arg+2);\n-\t}\n-\telse if (starts_with(arg, \"-M\") ||\n+\tif (starts_with(arg, \"-M\") ||\n \t\t skip_to_optional_arg(arg, \"--find-renames\", NULL)) {\n \t\tif ((options->rename_score = diff_scoreopt_parse(arg)) == -1)\n \t\t\treturn error(\"invalid argument to -M: %s\", arg+2);\n@@ -5328,17 +5353,14 @@ int parse_rename_score(const char **cp_p)\n \n static int diff_scoreopt_parse(const char *opt)\n {\n-\tint opt1, opt2, cmd;\n+\tint opt1, cmd;\n \n \tif (*opt++ != '-')\n \t\treturn -1;\n \tcmd = *opt++;\n \tif (cmd == '-') {\n \t\t/* convert the long-form arguments into short-form versions */\n-\t\tif (skip_prefix(opt, \"break-rewrites\", &opt)) {\n-\t\t\tif (*opt == 0 || *opt++ == '=')\n-\t\t\t\tcmd = 'B';\n-\t\t} else if (skip_prefix(opt, \"find-copies\", &opt)) {\n+\t\tif (skip_prefix(opt, \"find-copies\", &opt)) {\n \t\t\tif (*opt == 0 || *opt++ == '=')\n \t\t\t\tcmd = 'C';\n \t\t} else if (skip_prefix(opt, \"find-renames\", &opt)) {\n@@ -5346,25 +5368,13 @@ static int diff_scoreopt_parse(const char *opt)\n \t\t\t\tcmd = 'M';\n \t\t}\n \t}\n-\tif (cmd != 'M' && cmd != 'C' && cmd != 'B')\n-\t\treturn -1; /* that is not a -M, -C, or -B option */\n+\tif (cmd != 'M' && cmd != 'C')\n+\t\treturn -1; /* that is not a -M, or -C option */\n \n \topt1 = parse_rename_score(&opt);\n-\tif (cmd != 'B')\n-\t\topt2 = 0;\n-\telse {\n-\t\tif (*opt == 0)\n-\t\t\topt2 = 0;\n-\t\telse if (*opt != '/')\n-\t\t\treturn -1; /* we expect -B80/99 or -B80 */\n-\t\telse {\n-\t\t\topt++;\n-\t\t\topt2 = parse_rename_score(&opt);\n-\t\t}\n-\t}\n \tif (*opt != 0)\n \t\treturn -1;\n-\treturn opt1 | (opt2 << 16);\n+\treturn opt1;\n }\n \n struct diff_queue_struct diff_queued_diff;\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"369784","messageId":"20190221111621.27180-15-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190221111621.27180-1-pclouds@gmail.com","subject":"[PATCH v4 14/21] diff-parseopt: convert -M|--find-renames","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-21T11:16:14Z","receivedAt":"2019-02-21T11:17: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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 35 +++++++++++++++++++++++------------\n 1 file changed, 23 insertions(+), 12 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex d2139082b7..2c904e0526 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4909,6 +4909,22 @@ static int diff_opt_dirstat(const struct option *opt,\n \treturn 0;\n }\n \n+static int diff_opt_find_renames(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 = \"\";\n+\toptions->rename_score = parse_rename_score(&arg);\n+\tif (*arg != 0)\n+\t\treturn error(_(\"invalid argument to %s\"), opt->long_name);\n+\n+\toptions->detect_rename = DIFF_DETECT_RENAME;\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@@ -5040,6 +5056,10 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       N_(\"break complete rewrite changes into pairs of delete and create\"),\n \t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n \t\t\t       diff_opt_break_rewrites),\n+\t\tOPT_CALLBACK_F('M', \"find-renames\", options, N_(\"<n>\"),\n+\t\t\t       N_(\"detect renames\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n+\t\t\t       diff_opt_find_renames),\n \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n@@ -5074,13 +5094,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* renames options */\n-\tif (starts_with(arg, \"-M\") ||\n-\t\t skip_to_optional_arg(arg, \"--find-renames\", NULL)) {\n-\t\tif ((options->rename_score = diff_scoreopt_parse(arg)) == -1)\n-\t\t\treturn error(\"invalid argument to -M: %s\", arg+2);\n-\t\toptions->detect_rename = DIFF_DETECT_RENAME;\n-\t}\n-\telse if (!strcmp(arg, \"-D\") || !strcmp(arg, \"--irreversible-delete\")) {\n+\tif (!strcmp(arg, \"-D\") || !strcmp(arg, \"--irreversible-delete\")) {\n \t\toptions->irreversible_delete = 1;\n \t}\n \telse if (starts_with(arg, \"-C\") ||\n@@ -5363,13 +5377,10 @@ static int diff_scoreopt_parse(const char *opt)\n \t\tif (skip_prefix(opt, \"find-copies\", &opt)) {\n \t\t\tif (*opt == 0 || *opt++ == '=')\n \t\t\t\tcmd = 'C';\n-\t\t} else if (skip_prefix(opt, \"find-renames\", &opt)) {\n-\t\t\tif (*opt == 0 || *opt++ == '=')\n-\t\t\t\tcmd = 'M';\n \t\t}\n \t}\n-\tif (cmd != 'M' && cmd != 'C')\n-\t\treturn -1; /* that is not a -M, or -C option */\n+\tif (cmd != 'C')\n+\t\treturn -1; /* that is not a -M option */\n \n \topt1 = parse_rename_score(&opt);\n \tif (*opt != 0)\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"369785","messageId":"20190221111621.27180-16-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190221111621.27180-1-pclouds@gmail.com","subject":"[PATCH v4 15/21] diff-parseopt: convert -D|--irreversible-delete","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-21T11:16:15Z","receivedAt":"2019-02-21T11:17: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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 2c904e0526..e51f6b3005 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5060,6 +5060,9 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       N_(\"detect renames\"),\n \t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n \t\t\t       diff_opt_find_renames),\n+\t\tOPT_SET_INT_F('D', \"irreversible-delete\", &options->irreversible_delete,\n+\t\t\t      N_(\"omit the preimage for deletes\"),\n+\t\t\t      1, PARSE_OPT_NONEG),\n \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n@@ -5094,10 +5097,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* renames options */\n-\tif (!strcmp(arg, \"-D\") || !strcmp(arg, \"--irreversible-delete\")) {\n-\t\toptions->irreversible_delete = 1;\n-\t}\n-\telse if (starts_with(arg, \"-C\") ||\n+\tif (starts_with(arg, \"-C\") ||\n \t\t skip_to_optional_arg(arg, \"--find-copies\", NULL)) {\n \t\tif (options->detect_rename == DIFF_DETECT_COPY)\n \t\t\toptions->flags.find_copies_harder = 1;\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"369786","messageId":"20190221111621.27180-17-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190221111621.27180-1-pclouds@gmail.com","subject":"[PATCH v4 16/21] diff-parseopt: convert -C|--find-copies","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-21T11:16:16Z","receivedAt":"2019-02-21T11:17: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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 59 +++++++++++++++++++++++++---------------------------------\n 1 file changed, 25 insertions(+), 34 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex e51f6b3005..35bac115cc 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4617,8 +4617,6 @@ static int opt_arg(const char *arg, int arg_short, const char *arg_long, int *va\n \treturn 1;\n }\n \n-static int diff_scoreopt_parse(const char *opt);\n-\n static inline int short_opt(char opt, const char **argv,\n \t\t\t    const char **optarg)\n {\n@@ -4909,6 +4907,26 @@ static int diff_opt_dirstat(const struct option *opt,\n \treturn 0;\n }\n \n+static int diff_opt_find_copies(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+\tif (!arg)\n+\t\targ = \"\";\n+\toptions->rename_score = parse_rename_score(&arg);\n+\tif (*arg != 0)\n+\t\treturn error(_(\"invalid argument to %s\"), opt->long_name);\n+\n+\tif (options->detect_rename == DIFF_DETECT_COPY)\n+\t\toptions->flags.find_copies_harder = 1;\n+\telse\n+\t\toptions->detect_rename = DIFF_DETECT_COPY;\n+\n+\treturn 0;\n+}\n+\n static int diff_opt_find_renames(const struct option *opt,\n \t\t\t\t const char *arg, int unset)\n {\n@@ -5063,6 +5081,10 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_SET_INT_F('D', \"irreversible-delete\", &options->irreversible_delete,\n \t\t\t      N_(\"omit the preimage for deletes\"),\n \t\t\t      1, PARSE_OPT_NONEG),\n+\t\tOPT_CALLBACK_F('C', \"find-copies\", options, N_(\"<n>\"),\n+\t\t\t       N_(\"detect copies\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n+\t\t\t       diff_opt_find_copies),\n \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n@@ -5097,15 +5119,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* renames options */\n-\tif (starts_with(arg, \"-C\") ||\n-\t\t skip_to_optional_arg(arg, \"--find-copies\", NULL)) {\n-\t\tif (options->detect_rename == DIFF_DETECT_COPY)\n-\t\t\toptions->flags.find_copies_harder = 1;\n-\t\tif ((options->rename_score = diff_scoreopt_parse(arg)) == -1)\n-\t\t\treturn error(\"invalid argument to -C: %s\", arg+2);\n-\t\toptions->detect_rename = DIFF_DETECT_COPY;\n-\t}\n-\telse if (!strcmp(arg, \"--no-renames\"))\n+\tif (!strcmp(arg, \"--no-renames\"))\n \t\toptions->detect_rename = 0;\n \telse if (!strcmp(arg, \"--rename-empty\"))\n \t\toptions->flags.rename_empty = 1;\n@@ -5365,29 +5379,6 @@ int parse_rename_score(const char **cp_p)\n \treturn (int)((num >= scale) ? MAX_SCORE : (MAX_SCORE * num / scale));\n }\n \n-static int diff_scoreopt_parse(const char *opt)\n-{\n-\tint opt1, cmd;\n-\n-\tif (*opt++ != '-')\n-\t\treturn -1;\n-\tcmd = *opt++;\n-\tif (cmd == '-') {\n-\t\t/* convert the long-form arguments into short-form versions */\n-\t\tif (skip_prefix(opt, \"find-copies\", &opt)) {\n-\t\t\tif (*opt == 0 || *opt++ == '=')\n-\t\t\t\tcmd = 'C';\n-\t\t}\n-\t}\n-\tif (cmd != 'C')\n-\t\treturn -1; /* that is not a -M option */\n-\n-\topt1 = parse_rename_score(&opt);\n-\tif (*opt != 0)\n-\t\treturn -1;\n-\treturn opt1;\n-}\n-\n struct diff_queue_struct diff_queued_diff;\n \n void diff_q(struct diff_queue_struct *queue, struct diff_filepair *dp)\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"369787","messageId":"20190221111621.27180-18-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190221111621.27180-1-pclouds@gmail.com","subject":"[PATCH v4 17/21] diff-parseopt: convert --find-copies-harder","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-21T11:16:17Z","receivedAt":"2019-02-21T11:18:01Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"--no-find-copies-harder is also added on purpose (because I don't see\nwhy we should not have the --no- version for this)\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 35bac115cc..abb1566f95 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5085,6 +5085,8 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       N_(\"detect copies\"),\n \t\t\t       PARSE_OPT_NONEG | PARSE_OPT_OPTARG,\n \t\t\t       diff_opt_find_copies),\n+\t\tOPT_BOOL(0, \"find-copies-harder\", &options->flags.find_copies_harder,\n+\t\t\t N_(\"use unmodified files as source to find copies\")),\n \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n@@ -5191,8 +5193,6 @@ int diff_opt_parse(struct diff_options *options,\n \t\toptions->flags.text = 1;\n \telse if (!strcmp(arg, \"-R\"))\n \t\toptions->flags.reverse_diff = 1;\n-\telse if (!strcmp(arg, \"--find-copies-harder\"))\n-\t\toptions->flags.find_copies_harder = 1;\n \telse if (!strcmp(arg, \"--follow\"))\n \t\toptions->flags.follow_renames = 1;\n \telse if (!strcmp(arg, \"--no-follow\")) {\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"369788","messageId":"20190221111621.27180-19-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190221111621.27180-1-pclouds@gmail.com","subject":"[PATCH v4 18/21] diff-parseopt: convert --no-renames|--[no--rename-empty","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-21T11:16:18Z","receivedAt":"2019-02-21T11:18:05Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"For --rename-empty, see 90d43b0768 (teach diffcore-rename to\noptionally ignore empty content - 2012-03-22) for more information.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/diff-options.txt |  3 +++\n diff.c                         | 13 ++++++-------\n 2 files changed, 9 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt\nindex 56b731eae5..915f2fec8b 100644\n--- a/Documentation/diff-options.txt\n+++ b/Documentation/diff-options.txt\n@@ -392,6 +392,9 @@ endif::git-format-patch[]\n \tTurn off rename detection, even when the configuration\n \tfile gives the default to do so.\n \n+--[no-]rename-empty::\n+\tWhether to use empty blobs as rename source.\n+\n ifndef::git-format-patch[]\n --check::\n \tWarn if changes introduce conflict markers or whitespace errors.\ndiff --git a/diff.c b/diff.c\nindex abb1566f95..d423a06b41 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5087,6 +5087,11 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t       diff_opt_find_copies),\n \t\tOPT_BOOL(0, \"find-copies-harder\", &options->flags.find_copies_harder,\n \t\t\t N_(\"use unmodified files as source to find copies\")),\n+\t\tOPT_SET_INT_F(0, \"no-renames\", &options->detect_rename,\n+\t\t\t      N_(\"disable rename detection\"),\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 \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\t{ OPTION_CALLBACK, 0, \"output\", options, N_(\"<file>\"),\n@@ -5121,13 +5126,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* renames options */\n-\tif (!strcmp(arg, \"--no-renames\"))\n-\t\toptions->detect_rename = 0;\n-\telse if (!strcmp(arg, \"--rename-empty\"))\n-\t\toptions->flags.rename_empty = 1;\n-\telse if (!strcmp(arg, \"--no-rename-empty\"))\n-\t\toptions->flags.rename_empty = 0;\n-\telse if (skip_to_optional_arg_default(arg, \"--relative\", &arg, NULL)) {\n+\tif (skip_to_optional_arg_default(arg, \"--relative\", &arg, NULL)) {\n \t\toptions->flags.relative_name = 1;\n \t\tif (arg)\n \t\t\toptions->prefix = arg;\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"369789","messageId":"20190221111621.27180-20-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190221111621.27180-1-pclouds@gmail.com","subject":"[PATCH v4 19/21] diff-parseopt: convert --relative","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-21T11:16:19Z","receivedAt":"2019-02-21T11:18:11Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 25 +++++++++++++++++--------\n 1 file changed, 17 insertions(+), 8 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex d423a06b41..b9c267a199 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4960,6 +4960,18 @@ static enum parse_opt_result diff_opt_output(struct parse_opt_ctx_t *ctx,\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+\tstruct diff_options *options = opt->value;\n+\n+\tBUG_ON_OPT_NEG(unset);\n+\toptions->flags.relative_name = 1;\n+\tif (arg)\n+\t\toptions->prefix = arg;\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@@ -5094,6 +5106,10 @@ static void prep_parse_options(struct diff_options *options)\n \t\t\t N_(\"use empty blobs as rename source\")),\n \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n+\t\tOPT_CALLBACK_F(0, \"relative\", options, N_(\"<prefix>\"),\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\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@@ -5125,15 +5141,8 @@ int diff_opt_parse(struct diff_options *options,\n \tif (ac)\n \t\treturn ac;\n \n-\t/* renames options */\n-\tif (skip_to_optional_arg_default(arg, \"--relative\", &arg, NULL)) {\n-\t\toptions->flags.relative_name = 1;\n-\t\tif (arg)\n-\t\t\toptions->prefix = arg;\n-\t}\n-\n \t/* xdiff options */\n-\telse if (!strcmp(arg, \"--minimal\"))\n+\tif (!strcmp(arg, \"--minimal\"))\n \t\tDIFF_XDL_SET(options, NEED_MINIMAL);\n \telse if (!strcmp(arg, \"--no-minimal\"))\n \t\tDIFF_XDL_CLR(options, NEED_MINIMAL);\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"369790","messageId":"20190221111621.27180-21-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190221111621.27180-1-pclouds@gmail.com","subject":"[PATCH v4 20/21] diff-parseopt: convert --[no-]minimal","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-21T11:16:20Z","receivedAt":"2019-02-21T11:18: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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 11 ++++++-----\n 1 file changed, 6 insertions(+), 5 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex b9c267a199..33492e754f 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5105,6 +5105,11 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BOOL(0, \"rename-empty\", &options->flags.rename_empty,\n \t\t\t N_(\"use empty blobs as rename source\")),\n \n+\t\tOPT_GROUP(N_(\"Diff algorithm options\")),\n+\t\tOPT_BIT(0, \"minimal\", &options->xdl_opts,\n+\t\t\tN_(\"produce the smallest possible diff\"),\n+\t\t\tXDF_NEED_MINIMAL),\n+\n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\tOPT_CALLBACK_F(0, \"relative\", options, N_(\"<prefix>\"),\n \t\t\t       N_(\"when run from subdir, exclude changes outside and show relative paths\"),\n@@ -5142,11 +5147,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* xdiff options */\n-\tif (!strcmp(arg, \"--minimal\"))\n-\t\tDIFF_XDL_SET(options, NEED_MINIMAL);\n-\telse if (!strcmp(arg, \"--no-minimal\"))\n-\t\tDIFF_XDL_CLR(options, NEED_MINIMAL);\n-\telse if (!strcmp(arg, \"-w\") || !strcmp(arg, \"--ignore-all-space\"))\n+\tif (!strcmp(arg, \"-w\") || !strcmp(arg, \"--ignore-all-space\"))\n \t\tDIFF_XDL_SET(options, IGNORE_WHITESPACE);\n \telse if (!strcmp(arg, \"-b\") || !strcmp(arg, \"--ignore-space-change\"))\n \t\tDIFF_XDL_SET(options, IGNORE_WHITESPACE_CHANGE);\n-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"},{"id":"369791","messageId":"20190221111621.27180-22-pclouds@gmail.com","threadId":"50424","inReplyTo":"20190221111621.27180-1-pclouds@gmail.com","subject":"[PATCH v4 21/21] diff-parseopt: convert --ignore-some-changes","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-02-21T11:16:21Z","receivedAt":"2019-02-21T11:18:20Z","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>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 27 ++++++++++++++++-----------\n 1 file changed, 16 insertions(+), 11 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 33492e754f..a63ee4a44d 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5109,6 +5109,21 @@ static void prep_parse_options(struct diff_options *options)\n \t\tOPT_BIT(0, \"minimal\", &options->xdl_opts,\n \t\t\tN_(\"produce the smallest possible diff\"),\n \t\t\tXDF_NEED_MINIMAL),\n+\t\tOPT_BIT_F('w', \"ignore-all-space\", &options->xdl_opts,\n+\t\t\t  N_(\"ignore whitespace when comparing lines\"),\n+\t\t\t  XDF_IGNORE_WHITESPACE, PARSE_OPT_NONEG),\n+\t\tOPT_BIT_F('b', \"ignore-space-change\", &options->xdl_opts,\n+\t\t\t  N_(\"ignore changes in amount of whitespace\"),\n+\t\t\t  XDF_IGNORE_WHITESPACE_CHANGE, PARSE_OPT_NONEG),\n+\t\tOPT_BIT_F(0, \"ignore-space-at-eol\", &options->xdl_opts,\n+\t\t\t  N_(\"ignore changes in whitespace at EOL\"),\n+\t\t\t  XDF_IGNORE_WHITESPACE_AT_EOL, PARSE_OPT_NONEG),\n+\t\tOPT_BIT_F(0, \"ignore-cr-at-eol\", &options->xdl_opts,\n+\t\t\t  N_(\"ignore carrier-return at the end of line\"),\n+\t\t\t  XDF_IGNORE_CR_AT_EOL, PARSE_OPT_NONEG),\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 \n \t\tOPT_GROUP(N_(\"Diff other options\")),\n \t\tOPT_CALLBACK_F(0, \"relative\", options, N_(\"<prefix>\"),\n@@ -5147,17 +5162,7 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn ac;\n \n \t/* xdiff options */\n-\tif (!strcmp(arg, \"-w\") || !strcmp(arg, \"--ignore-all-space\"))\n-\t\tDIFF_XDL_SET(options, IGNORE_WHITESPACE);\n-\telse if (!strcmp(arg, \"-b\") || !strcmp(arg, \"--ignore-space-change\"))\n-\t\tDIFF_XDL_SET(options, IGNORE_WHITESPACE_CHANGE);\n-\telse if (!strcmp(arg, \"--ignore-space-at-eol\"))\n-\t\tDIFF_XDL_SET(options, IGNORE_WHITESPACE_AT_EOL);\n-\telse if (!strcmp(arg, \"--ignore-cr-at-eol\"))\n-\t\tDIFF_XDL_SET(options, IGNORE_CR_AT_EOL);\n-\telse if (!strcmp(arg, \"--ignore-blank-lines\"))\n-\t\tDIFF_XDL_SET(options, IGNORE_BLANK_LINES);\n-\telse if (!strcmp(arg, \"--indent-heuristic\"))\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-- \n2.21.0.rc1.337.gdf7f8d0522\n\n"}]}