* [PATCH v3 01/21] diff-parseopt: convert --patch-with-raw
2019-02-16 11:36 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
@ 2019-02-16 11:36 ` Nguyễn Thái Ngọc Duy
2019-02-20 20:41 ` Junio C Hamano
2019-02-16 11:36 ` [PATCH v3 02/21] diff-parseopt: convert --numstat and --shortstat Nguyễn Thái Ngọc Duy
` (20 subsequent siblings)
21 siblings, 1 reply; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-16 11:36 UTC (permalink / raw)
To: pclouds; +Cc: git, gitster, SZEDER Gábor
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/diff.c b/diff.c
index 4bc9df7362..12e333c67f 100644
--- a/diff.c
+++ b/diff.c
@@ -4901,6 +4901,10 @@ static void prep_parse_options(struct diff_options *options)
OPT_BIT_F(0, "raw", &options->output_format,
N_("generate the diff in raw format"),
DIFF_FORMAT_RAW, PARSE_OPT_NONEG),
+ OPT_BITOP(0, "patch-with-raw", &options->output_format,
+ N_("synonym for '-p --raw'"),
+ DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW,
+ DIFF_FORMAT_NO_OUTPUT),
OPT_END()
};
@@ -4929,10 +4933,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* Output format options */
- if (!strcmp(arg, "--patch-with-raw")) {
- enable_patch_output(&options->output_format);
- options->output_format |= DIFF_FORMAT_RAW;
- } else if (!strcmp(arg, "--numstat"))
+ if (!strcmp(arg, "--numstat"))
options->output_format |= DIFF_FORMAT_NUMSTAT;
else if (!strcmp(arg, "--shortstat"))
options->output_format |= DIFF_FORMAT_SHORTSTAT;
--
2.21.0.rc0.328.g0e39304f8d
^ permalink raw reply related [flat|nested] 80+ messages in thread
* Re: [PATCH v3 01/21] diff-parseopt: convert --patch-with-raw
2019-02-16 11:36 ` [PATCH v3 01/21] diff-parseopt: convert --patch-with-raw Nguyễn Thái Ngọc Duy
@ 2019-02-20 20:41 ` Junio C Hamano
0 siblings, 0 replies; 80+ messages in thread
From: Junio C Hamano @ 2019-02-20 20:41 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git, SZEDER Gábor
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
> diff.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/diff.c b/diff.c
> index 4bc9df7362..12e333c67f 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -4901,6 +4901,10 @@ static void prep_parse_options(struct diff_options *options)
> OPT_BIT_F(0, "raw", &options->output_format,
> N_("generate the diff in raw format"),
> DIFF_FORMAT_RAW, PARSE_OPT_NONEG),
> + OPT_BITOP(0, "patch-with-raw", &options->output_format,
> + N_("synonym for '-p --raw'"),
> + DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW,
> + DIFF_FORMAT_NO_OUTPUT),
> OPT_END()
> };
>
> @@ -4929,10 +4933,7 @@ int diff_opt_parse(struct diff_options *options,
> return ac;
>
> /* Output format options */
> - if (!strcmp(arg, "--patch-with-raw")) {
> - enable_patch_output(&options->output_format);
> - options->output_format |= DIFF_FORMAT_RAW;
> - } else if (!strcmp(arg, "--numstat"))
> + if (!strcmp(arg, "--numstat"))
> options->output_format |= DIFF_FORMAT_NUMSTAT;
> else if (!strcmp(arg, "--shortstat"))
> options->output_format |= DIFF_FORMAT_SHORTSTAT;
Quite straight-forward, and makes us anticipate the eventual removal
of enable_patch_output() helper function ;-)
^ permalink raw reply [flat|nested] 80+ messages in thread
* [PATCH v3 02/21] diff-parseopt: convert --numstat and --shortstat
2019-02-16 11:36 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
2019-02-16 11:36 ` [PATCH v3 01/21] diff-parseopt: convert --patch-with-raw Nguyễn Thái Ngọc Duy
@ 2019-02-16 11:36 ` Nguyễn Thái Ngọc Duy
2019-02-16 11:36 ` [PATCH v3 03/21] diff-parseopt: convert --dirstat and friends Nguyễn Thái Ngọc Duy
` (19 subsequent siblings)
21 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-16 11:36 UTC (permalink / raw)
To: pclouds; +Cc: git, gitster, SZEDER Gábor
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/diff.c b/diff.c
index 12e333c67f..419b6ac4ae 100644
--- a/diff.c
+++ b/diff.c
@@ -4905,6 +4905,12 @@ static void prep_parse_options(struct diff_options *options)
N_("synonym for '-p --raw'"),
DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW,
DIFF_FORMAT_NO_OUTPUT),
+ OPT_BIT_F(0, "numstat", &options->output_format,
+ N_("machine friendly --stat"),
+ DIFF_FORMAT_NUMSTAT, PARSE_OPT_NONEG),
+ OPT_BIT_F(0, "shortstat", &options->output_format,
+ N_("output only the last line of --stat"),
+ DIFF_FORMAT_SHORTSTAT, PARSE_OPT_NONEG),
OPT_END()
};
@@ -4933,11 +4939,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* Output format options */
- if (!strcmp(arg, "--numstat"))
- options->output_format |= DIFF_FORMAT_NUMSTAT;
- else if (!strcmp(arg, "--shortstat"))
- options->output_format |= DIFF_FORMAT_SHORTSTAT;
- else if (skip_prefix(arg, "-X", &arg) ||
+ if (skip_prefix(arg, "-X", &arg) ||
skip_to_optional_arg(arg, "--dirstat", &arg))
return parse_dirstat_opt(options, arg);
else if (!strcmp(arg, "--cumulative"))
--
2.21.0.rc0.328.g0e39304f8d
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v3 03/21] diff-parseopt: convert --dirstat and friends
2019-02-16 11:36 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
2019-02-16 11:36 ` [PATCH v3 01/21] diff-parseopt: convert --patch-with-raw Nguyễn Thái Ngọc Duy
2019-02-16 11:36 ` [PATCH v3 02/21] diff-parseopt: convert --numstat and --shortstat Nguyễn Thái Ngọc Duy
@ 2019-02-16 11:36 ` Nguyễn Thái Ngọc Duy
2019-02-17 13:39 ` Andrei Rybak
2019-02-16 11:36 ` [PATCH v3 04/21] diff-parseopt: convert --check Nguyễn Thái Ngọc Duy
` (18 subsequent siblings)
21 siblings, 1 reply; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-16 11:36 UTC (permalink / raw)
To: pclouds; +Cc: git, gitster, SZEDER Gábor
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
Documentation/diff-options.txt | 7 ++++++
diff.c | 39 +++++++++++++++++++++++++---------
2 files changed, 36 insertions(+), 10 deletions(-)
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 0711734b12..058d93ec4f 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -148,6 +148,7 @@ These parameters can also be set individually with `--stat-width=<width>`,
number of modified files, as well as number of added and deleted
lines.
+-X<param1,param2,...>::
--dirstat[=<param1,param2,...>]::
Output the distribution of relative amount of changes for each
sub-directory. The behavior of `--dirstat` can be customized by
@@ -192,6 +193,12 @@ directories with less than 10% of the total amount of changed files,
and accumulating child directory counts in the parent directories:
`--dirstat=files,10,cumulative`.
+--cumulative::
+ Synonym for --dirstat=cumulative
+
+--dirstat-by-file[=<param1,param2>...]::
+ Synonym for --dirstat=files,param1,param2...
+
--summary::
Output a condensed summary of extended header information
such as creations, renames and mode changes.
diff --git a/diff.c b/diff.c
index 419b6ac4ae..1cdbe8e688 100644
--- a/diff.c
+++ b/diff.c
@@ -4867,6 +4867,22 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)
return 1;
}
+static int diff_opt_dirstat(const struct option *opt,
+ const char *arg, int unset)
+{
+ struct diff_options *options = opt->value;
+
+ BUG_ON_OPT_NEG(unset);
+ if (!strcmp(opt->long_name, "cumulative")) {
+ if (arg)
+ BUG("how come --cumulative take a value?");
+ arg = "cumulative";
+ } else if (!strcmp(opt->long_name, "dirstat-by-file"))
+ parse_dirstat_opt(options, "files");
+ parse_dirstat_opt(options, arg ? arg : "");
+ return 0;
+}
+
static int diff_opt_unified(const struct option *opt,
const char *arg, int unset)
{
@@ -4911,6 +4927,18 @@ static void prep_parse_options(struct diff_options *options)
OPT_BIT_F(0, "shortstat", &options->output_format,
N_("output only the last line of --stat"),
DIFF_FORMAT_SHORTSTAT, PARSE_OPT_NONEG),
+ OPT_CALLBACK_F('X', "dirstat", options, N_("<param1,param2>..."),
+ N_("output the distribution of relative amount of changes for each sub-directory"),
+ PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
+ diff_opt_dirstat),
+ OPT_CALLBACK_F(0, "cumulative", options, NULL,
+ N_("synonym for --dirstat=cumulative"),
+ PARSE_OPT_NONEG | PARSE_OPT_NOARG,
+ diff_opt_dirstat),
+ OPT_CALLBACK_F(0, "dirstat-by-file", options, N_("<param1,param2>..."),
+ N_("synonym for --dirstat=files,param1,param2..."),
+ PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
+ diff_opt_dirstat),
OPT_END()
};
@@ -4939,16 +4967,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* Output format options */
- if (skip_prefix(arg, "-X", &arg) ||
- skip_to_optional_arg(arg, "--dirstat", &arg))
- return parse_dirstat_opt(options, arg);
- else if (!strcmp(arg, "--cumulative"))
- return parse_dirstat_opt(options, "cumulative");
- else if (skip_to_optional_arg(arg, "--dirstat-by-file", &arg)) {
- parse_dirstat_opt(options, "files");
- return parse_dirstat_opt(options, arg);
- }
- else if (!strcmp(arg, "--check"))
+ if (!strcmp(arg, "--check"))
options->output_format |= DIFF_FORMAT_CHECKDIFF;
else if (!strcmp(arg, "--summary"))
options->output_format |= DIFF_FORMAT_SUMMARY;
--
2.21.0.rc0.328.g0e39304f8d
^ permalink raw reply related [flat|nested] 80+ messages in thread
* Re: [PATCH v3 03/21] diff-parseopt: convert --dirstat and friends
2019-02-16 11:36 ` [PATCH v3 03/21] diff-parseopt: convert --dirstat and friends Nguyễn Thái Ngọc Duy
@ 2019-02-17 13:39 ` Andrei Rybak
0 siblings, 0 replies; 80+ messages in thread
From: Andrei Rybak @ 2019-02-17 13:39 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git, gitster, SZEDER Gábor
On 2/16/19 12:36 PM, Nguyễn Thái Ngọc Duy wrote:
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
> Documentation/diff-options.txt | 7 ++++++
> diff.c | 39 +++++++++++++++++++++++++---------
> 2 files changed, 36 insertions(+), 10 deletions(-)
>
> diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
> index 0711734b12..058d93ec4f 100644
> --- a/Documentation/diff-options.txt
> +++ b/Documentation/diff-options.txt
> @@ -148,6 +148,7 @@ These parameters can also be set individually with `--stat-width=<width>`,
> number of modified files, as well as number of added and deleted
> lines.
>
> +-X<param1,param2,...>::
> --dirstat[=<param1,param2,...>]::
<param1,param2,...> should probably marked as optional for -X
> Output the distribution of relative amount of changes for each
> sub-directory. The behavior of `--dirstat` can be customized by
> @@ -192,6 +193,12 @@ directories with less than 10% of the total amount of changed files,
> and accumulating child directory counts in the parent directories:
> `--dirstat=files,10,cumulative`.
>
> +--cumulative::
> + Synonym for --dirstat=cumulative
> +
> +--dirstat-by-file[=<param1,param2>...]::
> + Synonym for --dirstat=files,param1,param2...
> +
> --summary::
> Output a condensed summary of extended header information
> such as creations, renames and mode changes.
^ permalink raw reply [flat|nested] 80+ messages in thread
* [PATCH v3 04/21] diff-parseopt: convert --check
2019-02-16 11:36 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
` (2 preceding siblings ...)
2019-02-16 11:36 ` [PATCH v3 03/21] diff-parseopt: convert --dirstat and friends Nguyễn Thái Ngọc Duy
@ 2019-02-16 11:36 ` Nguyễn Thái Ngọc Duy
2019-02-16 11:36 ` [PATCH v3 05/21] diff-parseopt: convert --summary Nguyễn Thái Ngọc Duy
` (17 subsequent siblings)
21 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-16 11:36 UTC (permalink / raw)
To: pclouds; +Cc: git, gitster, SZEDER Gábor
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/diff.c b/diff.c
index 1cdbe8e688..5e16082091 100644
--- a/diff.c
+++ b/diff.c
@@ -4939,6 +4939,9 @@ static void prep_parse_options(struct diff_options *options)
N_("synonym for --dirstat=files,param1,param2..."),
PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
diff_opt_dirstat),
+ OPT_BIT_F(0, "check", &options->output_format,
+ N_("warn if changes introduce conflict markers or whitespace errors"),
+ DIFF_FORMAT_CHECKDIFF, PARSE_OPT_NONEG),
OPT_END()
};
@@ -4967,9 +4970,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* Output format options */
- if (!strcmp(arg, "--check"))
- options->output_format |= DIFF_FORMAT_CHECKDIFF;
- else if (!strcmp(arg, "--summary"))
+ if (!strcmp(arg, "--summary"))
options->output_format |= DIFF_FORMAT_SUMMARY;
else if (!strcmp(arg, "--patch-with-stat")) {
enable_patch_output(&options->output_format);
--
2.21.0.rc0.328.g0e39304f8d
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v3 05/21] diff-parseopt: convert --summary
2019-02-16 11:36 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
` (3 preceding siblings ...)
2019-02-16 11:36 ` [PATCH v3 04/21] diff-parseopt: convert --check Nguyễn Thái Ngọc Duy
@ 2019-02-16 11:36 ` Nguyễn Thái Ngọc Duy
2019-02-16 11:36 ` [PATCH v3 06/21] diff-parseopt: convert --patch-with-stat Nguyễn Thái Ngọc Duy
` (16 subsequent siblings)
21 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-16 11:36 UTC (permalink / raw)
To: pclouds; +Cc: git, gitster, SZEDER Gábor
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/diff.c b/diff.c
index 5e16082091..0276f25200 100644
--- a/diff.c
+++ b/diff.c
@@ -4942,6 +4942,9 @@ static void prep_parse_options(struct diff_options *options)
OPT_BIT_F(0, "check", &options->output_format,
N_("warn if changes introduce conflict markers or whitespace errors"),
DIFF_FORMAT_CHECKDIFF, PARSE_OPT_NONEG),
+ OPT_BIT_F(0, "summary", &options->output_format,
+ N_("condensed summary such as creations, renames and mode changes"),
+ DIFF_FORMAT_SUMMARY, PARSE_OPT_NONEG),
OPT_END()
};
@@ -4970,9 +4973,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* Output format options */
- if (!strcmp(arg, "--summary"))
- options->output_format |= DIFF_FORMAT_SUMMARY;
- else if (!strcmp(arg, "--patch-with-stat")) {
+ if (!strcmp(arg, "--patch-with-stat")) {
enable_patch_output(&options->output_format);
options->output_format |= DIFF_FORMAT_DIFFSTAT;
} else if (!strcmp(arg, "--name-only"))
--
2.21.0.rc0.328.g0e39304f8d
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v3 06/21] diff-parseopt: convert --patch-with-stat
2019-02-16 11:36 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
` (4 preceding siblings ...)
2019-02-16 11:36 ` [PATCH v3 05/21] diff-parseopt: convert --summary Nguyễn Thái Ngọc Duy
@ 2019-02-16 11:36 ` Nguyễn Thái Ngọc Duy
2019-02-16 11:36 ` [PATCH v3 07/21] diff-parseopt: convert --name-only Nguyễn Thái Ngọc Duy
` (15 subsequent siblings)
21 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-16 11:36 UTC (permalink / raw)
To: pclouds; +Cc: git, gitster, SZEDER Gábor
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/diff.c b/diff.c
index 0276f25200..b9811aefef 100644
--- a/diff.c
+++ b/diff.c
@@ -4921,6 +4921,10 @@ static void prep_parse_options(struct diff_options *options)
N_("synonym for '-p --raw'"),
DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW,
DIFF_FORMAT_NO_OUTPUT),
+ OPT_BITOP(0, "patch-with-stat", &options->output_format,
+ N_("synonym for '-p --stat'"),
+ DIFF_FORMAT_PATCH | DIFF_FORMAT_DIFFSTAT,
+ DIFF_FORMAT_NO_OUTPUT),
OPT_BIT_F(0, "numstat", &options->output_format,
N_("machine friendly --stat"),
DIFF_FORMAT_NUMSTAT, PARSE_OPT_NONEG),
@@ -4973,10 +4977,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* Output format options */
- if (!strcmp(arg, "--patch-with-stat")) {
- enable_patch_output(&options->output_format);
- options->output_format |= DIFF_FORMAT_DIFFSTAT;
- } else if (!strcmp(arg, "--name-only"))
+ if (!strcmp(arg, "--name-only"))
options->output_format |= DIFF_FORMAT_NAME;
else if (!strcmp(arg, "--name-status"))
options->output_format |= DIFF_FORMAT_NAME_STATUS;
--
2.21.0.rc0.328.g0e39304f8d
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v3 07/21] diff-parseopt: convert --name-only
2019-02-16 11:36 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
` (5 preceding siblings ...)
2019-02-16 11:36 ` [PATCH v3 06/21] diff-parseopt: convert --patch-with-stat Nguyễn Thái Ngọc Duy
@ 2019-02-16 11:36 ` Nguyễn Thái Ngọc Duy
2019-02-16 11:36 ` [PATCH v3 08/21] diff-parseopt: convert --name-status Nguyễn Thái Ngọc Duy
` (14 subsequent siblings)
21 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-16 11:36 UTC (permalink / raw)
To: pclouds; +Cc: git, gitster, SZEDER Gábor
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/diff.c b/diff.c
index b9811aefef..7ea308814f 100644
--- a/diff.c
+++ b/diff.c
@@ -4949,6 +4949,9 @@ static void prep_parse_options(struct diff_options *options)
OPT_BIT_F(0, "summary", &options->output_format,
N_("condensed summary such as creations, renames and mode changes"),
DIFF_FORMAT_SUMMARY, PARSE_OPT_NONEG),
+ OPT_BIT_F(0, "name-only", &options->output_format,
+ N_("show only names of changed files"),
+ DIFF_FORMAT_NAME, PARSE_OPT_NONEG),
OPT_END()
};
@@ -4977,9 +4980,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* Output format options */
- if (!strcmp(arg, "--name-only"))
- options->output_format |= DIFF_FORMAT_NAME;
- else if (!strcmp(arg, "--name-status"))
+ if (!strcmp(arg, "--name-status"))
options->output_format |= DIFF_FORMAT_NAME_STATUS;
else if (!strcmp(arg, "-s") || !strcmp(arg, "--no-patch"))
options->output_format |= DIFF_FORMAT_NO_OUTPUT;
--
2.21.0.rc0.328.g0e39304f8d
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v3 08/21] diff-parseopt: convert --name-status
2019-02-16 11:36 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
` (6 preceding siblings ...)
2019-02-16 11:36 ` [PATCH v3 07/21] diff-parseopt: convert --name-only Nguyễn Thái Ngọc Duy
@ 2019-02-16 11:36 ` Nguyễn Thái Ngọc Duy
2019-02-16 11:36 ` [PATCH v3 09/21] diff-parseopt: convert -s|--no-patch Nguyễn Thái Ngọc Duy
` (13 subsequent siblings)
21 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-16 11:36 UTC (permalink / raw)
To: pclouds; +Cc: git, gitster, SZEDER Gábor
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/diff.c b/diff.c
index 7ea308814f..99047fb5fe 100644
--- a/diff.c
+++ b/diff.c
@@ -4952,6 +4952,9 @@ static void prep_parse_options(struct diff_options *options)
OPT_BIT_F(0, "name-only", &options->output_format,
N_("show only names of changed files"),
DIFF_FORMAT_NAME, PARSE_OPT_NONEG),
+ OPT_BIT_F(0, "name-status", &options->output_format,
+ N_("show only names and status of changed files"),
+ DIFF_FORMAT_NAME_STATUS, PARSE_OPT_NONEG),
OPT_END()
};
@@ -4980,9 +4983,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* Output format options */
- if (!strcmp(arg, "--name-status"))
- options->output_format |= DIFF_FORMAT_NAME_STATUS;
- else if (!strcmp(arg, "-s") || !strcmp(arg, "--no-patch"))
+ if (!strcmp(arg, "-s") || !strcmp(arg, "--no-patch"))
options->output_format |= DIFF_FORMAT_NO_OUTPUT;
else if (starts_with(arg, "--stat"))
/* --stat, --stat-width, --stat-name-width, or --stat-count */
--
2.21.0.rc0.328.g0e39304f8d
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v3 09/21] diff-parseopt: convert -s|--no-patch
2019-02-16 11:36 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
` (7 preceding siblings ...)
2019-02-16 11:36 ` [PATCH v3 08/21] diff-parseopt: convert --name-status Nguyễn Thái Ngọc Duy
@ 2019-02-16 11:36 ` Nguyễn Thái Ngọc Duy
2019-02-16 11:36 ` [PATCH v3 10/21] diff-parseopt: convert --stat* Nguyễn Thái Ngọc Duy
` (12 subsequent siblings)
21 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-16 11:36 UTC (permalink / raw)
To: pclouds; +Cc: git, gitster, SZEDER Gábor
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/diff.c b/diff.c
index 99047fb5fe..9c8f5336bc 100644
--- a/diff.c
+++ b/diff.c
@@ -4906,6 +4906,9 @@ static void prep_parse_options(struct diff_options *options)
OPT_BITOP('p', "patch", &options->output_format,
N_("generate patch"),
DIFF_FORMAT_PATCH, DIFF_FORMAT_NO_OUTPUT),
+ OPT_BIT_F('s', "no-patch", &options->output_format,
+ N_("suppress diff output"),
+ DIFF_FORMAT_NO_OUTPUT, PARSE_OPT_NONEG),
OPT_BITOP('u', NULL, &options->output_format,
N_("generate patch"),
DIFF_FORMAT_PATCH, DIFF_FORMAT_NO_OUTPUT),
@@ -4983,9 +4986,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* Output format options */
- if (!strcmp(arg, "-s") || !strcmp(arg, "--no-patch"))
- options->output_format |= DIFF_FORMAT_NO_OUTPUT;
- else if (starts_with(arg, "--stat"))
+ if (starts_with(arg, "--stat"))
/* --stat, --stat-width, --stat-name-width, or --stat-count */
return stat_opt(options, av);
else if (!strcmp(arg, "--compact-summary")) {
--
2.21.0.rc0.328.g0e39304f8d
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v3 10/21] diff-parseopt: convert --stat*
2019-02-16 11:36 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
` (8 preceding siblings ...)
2019-02-16 11:36 ` [PATCH v3 09/21] diff-parseopt: convert -s|--no-patch Nguyễn Thái Ngọc Duy
@ 2019-02-16 11:36 ` Nguyễn Thái Ngọc Duy
2019-02-20 21:08 ` Junio C Hamano
2019-02-16 11:36 ` [PATCH v3 11/21] diff-parseopt: convert --[no-]compact-summary Nguyễn Thái Ngọc Duy
` (11 subsequent siblings)
21 siblings, 1 reply; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-16 11:36 UTC (permalink / raw)
To: pclouds; +Cc: git, gitster, SZEDER Gábor
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 118 +++++++++++++++++++++++++--------------------------------
1 file changed, 52 insertions(+), 66 deletions(-)
diff --git a/diff.c b/diff.c
index 9c8f5336bc..1feb13deb3 100644
--- a/diff.c
+++ b/diff.c
@@ -104,11 +104,6 @@ static const char *color_diff_slots[] = {
[DIFF_FILE_NEW_BOLD] = "newBold",
};
-static NORETURN void die_want_option(const char *option_name)
-{
- die(_("option '%s' requires a value"), option_name);
-}
-
define_list_config_array_extra(color_diff_slots, {"plain"});
static int parse_diff_color_slot(const char *var)
@@ -4661,77 +4656,56 @@ int parse_long_opt(const char *opt, const char **argv,
return 2;
}
-static int stat_opt(struct diff_options *options, const char **av)
+static int diff_opt_stat(const struct option *opt, const char *value, int unset)
{
- const char *arg = av[0];
- char *end;
+ struct diff_options *options = opt->value;
int width = options->stat_width;
int name_width = options->stat_name_width;
int graph_width = options->stat_graph_width;
int count = options->stat_count;
- int argcount = 1;
+ char *end;
- if (!skip_prefix(arg, "--stat", &arg))
- BUG("stat option does not begin with --stat: %s", arg);
- end = (char *)arg;
+ BUG_ON_OPT_NEG(unset);
- switch (*arg) {
- case '-':
- if (skip_prefix(arg, "-width", &arg)) {
- if (*arg == '=')
- width = strtoul(arg + 1, &end, 10);
- else if (!*arg && !av[1])
- die_want_option("--stat-width");
- else if (!*arg) {
- width = strtoul(av[1], &end, 10);
- argcount = 2;
- }
- } else if (skip_prefix(arg, "-name-width", &arg)) {
- if (*arg == '=')
- name_width = strtoul(arg + 1, &end, 10);
- else if (!*arg && !av[1])
- die_want_option("--stat-name-width");
- else if (!*arg) {
- name_width = strtoul(av[1], &end, 10);
- argcount = 2;
- }
- } else if (skip_prefix(arg, "-graph-width", &arg)) {
- if (*arg == '=')
- graph_width = strtoul(arg + 1, &end, 10);
- else if (!*arg && !av[1])
- die_want_option("--stat-graph-width");
- else if (!*arg) {
- graph_width = strtoul(av[1], &end, 10);
- argcount = 2;
- }
- } else if (skip_prefix(arg, "-count", &arg)) {
- if (*arg == '=')
- count = strtoul(arg + 1, &end, 10);
- else if (!*arg && !av[1])
- die_want_option("--stat-count");
- else if (!*arg) {
- count = strtoul(av[1], &end, 10);
- argcount = 2;
- }
+ if (!strcmp(opt->long_name, "stat")) {
+ if (value) {
+ width = strtoul(value, &end, 10);
+ if (*end == ',')
+ name_width = strtoul(end+1, &end, 10);
+ if (*end == ',')
+ count = strtoul(end+1, &end, 10);
+ if (*end)
+ return error(_("invalid --stat value: %s"), value);
}
- break;
- case '=':
- width = strtoul(arg+1, &end, 10);
- if (*end == ',')
- name_width = strtoul(end+1, &end, 10);
- if (*end == ',')
- count = strtoul(end+1, &end, 10);
- }
+ } else if (!strcmp(opt->long_name, "stat-width")) {
+ width = strtoul(value, &end, 10);
+ if (*end)
+ return error(_("%s expects a numerical value"),
+ opt->long_name);
+ } else if (!strcmp(opt->long_name, "stat-name-width")) {
+ name_width = strtoul(value, &end, 10);
+ if (*end)
+ return error(_("%s expects a numerical value"),
+ opt->long_name);
+ } else if (!strcmp(opt->long_name, "stat-graph-width")) {
+ graph_width = strtoul(value, &end, 10);
+ if (*end)
+ return error(_("%s expects a numerical value"),
+ opt->long_name);
+ } else if (!strcmp(opt->long_name, "stat-count")) {
+ count = strtoul(value, &end, 10);
+ if (*end)
+ return error(_("%s expects a numerical value"),
+ opt->long_name);
+ } else
+ BUG("%s should not get here", opt->long_name);
- /* Important! This checks all the error cases! */
- if (*end)
- return 0;
options->output_format |= DIFF_FORMAT_DIFFSTAT;
options->stat_name_width = name_width;
options->stat_graph_width = graph_width;
options->stat_width = width;
options->stat_count = count;
- return argcount;
+ return 0;
}
static int parse_dirstat_opt(struct diff_options *options, const char *params)
@@ -4958,6 +4932,21 @@ static void prep_parse_options(struct diff_options *options)
OPT_BIT_F(0, "name-status", &options->output_format,
N_("show only names and status of changed files"),
DIFF_FORMAT_NAME_STATUS, PARSE_OPT_NONEG),
+ OPT_CALLBACK_F(0, "stat", options, N_("<width>[,<name-width>[,<count>]]"),
+ N_("generate diffstat"),
+ PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_stat),
+ OPT_CALLBACK_F(0, "stat-width", options, N_("<width>"),
+ N_("generate diffstat with a given width"),
+ PARSE_OPT_NONEG, diff_opt_stat),
+ OPT_CALLBACK_F(0, "stat-name-width", options, N_("<width>"),
+ N_("generate diffstat with a given name width"),
+ PARSE_OPT_NONEG, diff_opt_stat),
+ OPT_CALLBACK_F(0, "stat-graph-width", options, N_("<width>"),
+ N_("generate diffstat with a given graph width"),
+ PARSE_OPT_NONEG, diff_opt_stat),
+ OPT_CALLBACK_F(0, "stat-count", options, N_("<count>"),
+ N_("generate diffstat with limited lines"),
+ PARSE_OPT_NONEG, diff_opt_stat),
OPT_END()
};
@@ -4986,10 +4975,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* Output format options */
- if (starts_with(arg, "--stat"))
- /* --stat, --stat-width, --stat-name-width, or --stat-count */
- return stat_opt(options, av);
- else if (!strcmp(arg, "--compact-summary")) {
+ if (!strcmp(arg, "--compact-summary")) {
options->flags.stat_with_summary = 1;
options->output_format |= DIFF_FORMAT_DIFFSTAT;
} else if (!strcmp(arg, "--no-compact-summary"))
--
2.21.0.rc0.328.g0e39304f8d
^ permalink raw reply related [flat|nested] 80+ messages in thread
* Re: [PATCH v3 10/21] diff-parseopt: convert --stat*
2019-02-16 11:36 ` [PATCH v3 10/21] diff-parseopt: convert --stat* Nguyễn Thái Ngọc Duy
@ 2019-02-20 21:08 ` Junio C Hamano
0 siblings, 0 replies; 80+ messages in thread
From: Junio C Hamano @ 2019-02-20 21:08 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git, SZEDER Gábor
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> -static int stat_opt(struct diff_options *options, const char **av)
> +static int diff_opt_stat(const struct option *opt, const char *value, int unset)
> {
> - const char *arg = av[0];
> - char *end;
> + struct diff_options *options = opt->value;
> ...
> - switch (*arg) {
> - case '-':
> - if (skip_prefix(arg, "-width", &arg)) {
> - if (*arg == '=')
> - width = strtoul(arg + 1, &end, 10);
> - else if (!*arg && !av[1])
> - die_want_option("--stat-width");
> - else if (!*arg) {
> - width = strtoul(av[1], &end, 10);
> - argcount = 2;
> - }
> ...
> + if (!strcmp(opt->long_name, "stat")) {
> + if (value) {
> + width = strtoul(value, &end, 10);
> + if (*end == ',')
> + name_width = strtoul(end+1, &end, 10);
> + if (*end == ',')
> + count = strtoul(end+1, &end, 10);
> + if (*end)
> + return error(_("invalid --stat value: %s"), value);
> }
It took me a while to recall and figure out what the original is
doing, primarily because the code was designed to handle both
"-$option $arg" and "--$option=$arg". But thanks to the switch to
parse-options API, this helper no longer has to worry about that,
which is a very big plus. It only needs to parse what is in value.
Very nice.
^ permalink raw reply [flat|nested] 80+ messages in thread
* [PATCH v3 11/21] diff-parseopt: convert --[no-]compact-summary
2019-02-16 11:36 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
` (9 preceding siblings ...)
2019-02-16 11:36 ` [PATCH v3 10/21] diff-parseopt: convert --stat* Nguyễn Thái Ngọc Duy
@ 2019-02-16 11:36 ` Nguyễn Thái Ngọc Duy
2019-02-16 11:36 ` [PATCH v3 12/21] diff-parseopt: convert --output-* Nguyễn Thái Ngọc Duy
` (10 subsequent siblings)
21 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-16 11:36 UTC (permalink / raw)
To: pclouds; +Cc: git, gitster, SZEDER Gábor
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/diff.c b/diff.c
index 1feb13deb3..b24f6825a1 100644
--- a/diff.c
+++ b/diff.c
@@ -4841,6 +4841,21 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)
return 1;
}
+static int diff_opt_compact_summary(const struct option *opt,
+ const char *arg, int unset)
+{
+ struct diff_options *options = opt->value;
+
+ BUG_ON_OPT_ARG(arg);
+ if (unset) {
+ options->flags.stat_with_summary = 0;
+ } else {
+ options->flags.stat_with_summary = 1;
+ options->output_format |= DIFF_FORMAT_DIFFSTAT;
+ }
+ return 0;
+}
+
static int diff_opt_dirstat(const struct option *opt,
const char *arg, int unset)
{
@@ -4947,6 +4962,9 @@ static void prep_parse_options(struct diff_options *options)
OPT_CALLBACK_F(0, "stat-count", options, N_("<count>"),
N_("generate diffstat with limited lines"),
PARSE_OPT_NONEG, diff_opt_stat),
+ OPT_CALLBACK_F(0, "compact-summary", options, NULL,
+ N_("generate compact summary in diffstat"),
+ PARSE_OPT_NOARG, diff_opt_compact_summary),
OPT_END()
};
@@ -4975,12 +4993,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* Output format options */
- if (!strcmp(arg, "--compact-summary")) {
- options->flags.stat_with_summary = 1;
- options->output_format |= DIFF_FORMAT_DIFFSTAT;
- } else if (!strcmp(arg, "--no-compact-summary"))
- options->flags.stat_with_summary = 0;
- else if (skip_prefix(arg, "--output-indicator-new=", &arg))
+ if (skip_prefix(arg, "--output-indicator-new=", &arg))
options->output_indicators[OUTPUT_INDICATOR_NEW] = arg[0];
else if (skip_prefix(arg, "--output-indicator-old=", &arg))
options->output_indicators[OUTPUT_INDICATOR_OLD] = arg[0];
--
2.21.0.rc0.328.g0e39304f8d
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v3 12/21] diff-parseopt: convert --output-*
2019-02-16 11:36 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
` (10 preceding siblings ...)
2019-02-16 11:36 ` [PATCH v3 11/21] diff-parseopt: convert --[no-]compact-summary Nguyễn Thái Ngọc Duy
@ 2019-02-16 11:36 ` Nguyễn Thái Ngọc Duy
2019-02-16 11:36 ` [PATCH v3 13/21] diff-parseopt: convert -B|--break-rewrites Nguyễn Thái Ngọc Duy
` (9 subsequent siblings)
21 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-16 11:36 UTC (permalink / raw)
To: pclouds; +Cc: git, gitster, SZEDER Gábor
This also validates that the user specifies a single character in
--output-indicator-*, not a string.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
Documentation/diff-options.txt | 10 +++++
diff.c | 71 +++++++++++++++++++++++++---------
2 files changed, 63 insertions(+), 18 deletions(-)
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 058d93ec4f..d3e8d634b2 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -41,6 +41,16 @@ ifndef::git-format-patch[]
Implies `-p`.
endif::git-format-patch[]
+--output=<file>::
+ Output to a specific file instead of stdout.
+
+--output-indicator-new=<char>::
+--output-indicator-old=<char>::
+--output-indicator-context=<char>::
+ Specify the character used to indicate new, old or context
+ lines in the generated patch. Normally they are '+', '-' and
+ ' ' respectively.
+
ifndef::git-format-patch[]
--raw::
ifndef::git-log[]
diff --git a/diff.c b/diff.c
index b24f6825a1..8df396cb9a 100644
--- a/diff.c
+++ b/diff.c
@@ -4841,6 +4841,19 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)
return 1;
}
+static int diff_opt_char(const struct option *opt,
+ const char *arg, int unset)
+{
+ char *value = opt->value;
+
+ BUG_ON_OPT_NEG(unset);
+ if (arg[1])
+ return error(_("%s expects a character, got '%s'"),
+ opt->long_name, arg);
+ *value = arg[0];
+ return 0;
+}
+
static int diff_opt_compact_summary(const struct option *opt,
const char *arg, int unset)
{
@@ -4872,6 +4885,23 @@ static int diff_opt_dirstat(const struct option *opt,
return 0;
}
+static enum parse_opt_result diff_opt_output(struct parse_opt_ctx_t *ctx,
+ const struct option *opt,
+ const char *arg, int unset)
+{
+ struct diff_options *options = opt->value;
+ char *path;
+
+ BUG_ON_OPT_NEG(unset);
+ path = prefix_filename(ctx->prefix, arg);
+ options->file = xfopen(path, "w");
+ options->close_file = 1;
+ if (options->use_color != GIT_COLOR_ALWAYS)
+ options->use_color = GIT_COLOR_NEVER;
+ free(path);
+ return 0;
+}
+
static int diff_opt_unified(const struct option *opt,
const char *arg, int unset)
{
@@ -4965,6 +4995,27 @@ static void prep_parse_options(struct diff_options *options)
OPT_CALLBACK_F(0, "compact-summary", options, NULL,
N_("generate compact summary in diffstat"),
PARSE_OPT_NOARG, diff_opt_compact_summary),
+ OPT_CALLBACK_F(0, "output-indicator-new",
+ &options->output_indicators[OUTPUT_INDICATOR_NEW],
+ N_("<char>"),
+ N_("specify the character to indicate a new line instead of '+'"),
+ PARSE_OPT_NONEG, diff_opt_char),
+ OPT_CALLBACK_F(0, "output-indicator-old",
+ &options->output_indicators[OUTPUT_INDICATOR_OLD],
+ N_("<char>"),
+ N_("specify the character to indicate an old line instead of '-'"),
+ PARSE_OPT_NONEG, diff_opt_char),
+ OPT_CALLBACK_F(0, "output-indicator-context",
+ &options->output_indicators[OUTPUT_INDICATOR_CONTEXT],
+ N_("<char>"),
+ N_("specify the character to indicate a context instead of ' '"),
+ PARSE_OPT_NONEG, diff_opt_char),
+
+ OPT_GROUP(N_("Diff other options")),
+ { OPTION_CALLBACK, 0, "output", options, N_("<file>"),
+ N_("Output to a specific file"),
+ PARSE_OPT_NONEG, NULL, 0, diff_opt_output },
+
OPT_END()
};
@@ -4992,16 +5043,8 @@ int diff_opt_parse(struct diff_options *options,
if (ac)
return ac;
- /* Output format options */
- if (skip_prefix(arg, "--output-indicator-new=", &arg))
- options->output_indicators[OUTPUT_INDICATOR_NEW] = arg[0];
- else if (skip_prefix(arg, "--output-indicator-old=", &arg))
- options->output_indicators[OUTPUT_INDICATOR_OLD] = arg[0];
- else if (skip_prefix(arg, "--output-indicator-context=", &arg))
- options->output_indicators[OUTPUT_INDICATOR_CONTEXT] = arg[0];
-
/* renames options */
- else if (starts_with(arg, "-B") ||
+ if (starts_with(arg, "-B") ||
skip_to_optional_arg(arg, "--break-rewrites", NULL)) {
if ((options->break_opt = diff_scoreopt_parse(arg)) == -1)
return error("invalid argument to -B: %s", arg+2);
@@ -5242,15 +5285,7 @@ int diff_opt_parse(struct diff_options *options,
else if (opt_arg(arg, '\0', "inter-hunk-context",
&options->interhunkcontext))
;
- else if ((argcount = parse_long_opt("output", av, &optarg))) {
- char *path = prefix_filename(prefix, optarg);
- options->file = xfopen(path, "w");
- options->close_file = 1;
- if (options->use_color != GIT_COLOR_ALWAYS)
- options->use_color = GIT_COLOR_NEVER;
- free(path);
- return argcount;
- } else
+ else
return 0;
return 1;
}
--
2.21.0.rc0.328.g0e39304f8d
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v3 13/21] diff-parseopt: convert -B|--break-rewrites
2019-02-16 11:36 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
` (11 preceding siblings ...)
2019-02-16 11:36 ` [PATCH v3 12/21] diff-parseopt: convert --output-* Nguyễn Thái Ngọc Duy
@ 2019-02-16 11:36 ` Nguyễn Thái Ngọc Duy
2019-02-16 11:36 ` [PATCH v3 14/21] diff-parseopt: convert -M|--find-renames Nguyễn Thái Ngọc Duy
` (8 subsequent siblings)
21 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-16 11:36 UTC (permalink / raw)
To: pclouds; +Cc: git, gitster, SZEDER Gábor
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
diff.c | 62 ++++++++++++++++++++++++++++++++++------------------------
1 file changed, 36 insertions(+), 26 deletions(-)
diff --git a/diff.c b/diff.c
index 8df396cb9a..d2139082b7 100644
--- a/diff.c
+++ b/diff.c
@@ -4841,6 +4841,30 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)
return 1;
}
+static int diff_opt_break_rewrites(const struct option *opt,
+ const char *arg, int unset)
+{
+ int *break_opt = opt->value;
+ int opt1, opt2;
+
+ BUG_ON_OPT_NEG(unset);
+ if (!arg)
+ arg = "";
+ opt1 = parse_rename_score(&arg);
+ if (*arg == 0)
+ opt2 = 0;
+ else if (*arg != '/')
+ return error(_("%s expects <n>/<m> form"), opt->long_name);
+ else {
+ arg++;
+ opt2 = parse_rename_score(&arg);
+ }
+ if (*arg != 0)
+ return error(_("%s expects <n>/<m> form"), opt->long_name);
+ *break_opt = opt1 | (opt2 << 16);
+ return 0;
+}
+
static int diff_opt_char(const struct option *opt,
const char *arg, int unset)
{
@@ -5011,6 +5035,12 @@ static void prep_parse_options(struct diff_options *options)
N_("specify the character to indicate a context instead of ' '"),
PARSE_OPT_NONEG, diff_opt_char),
+ OPT_GROUP(N_("Diff rename options")),
+ OPT_CALLBACK_F('B', "break-rewrites", &options->break_opt, N_("<n>[/<m>]"),
+ N_("break complete rewrite changes into pairs of delete and create"),
+ PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
+ diff_opt_break_rewrites),
+
OPT_GROUP(N_("Diff other options")),
{ OPTION_CALLBACK, 0, "output", options, N_("<file>"),
N_("Output to a specific file"),
@@ -5044,12 +5074,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* renames options */
- if (starts_with(arg, "-B") ||
- skip_to_optional_arg(arg, "--break-rewrites", NULL)) {
- if ((options->break_opt = diff_scoreopt_parse(arg)) == -1)
- return error("invalid argument to -B: %s", arg+2);
- }
- else if (starts_with(arg, "-M") ||
+ if (starts_with(arg, "-M") ||
skip_to_optional_arg(arg, "--find-renames", NULL)) {
if ((options->rename_score = diff_scoreopt_parse(arg)) == -1)
return error("invalid argument to -M: %s", arg+2);
@@ -5328,17 +5353,14 @@ int parse_rename_score(const char **cp_p)
static int diff_scoreopt_parse(const char *opt)
{
- int opt1, opt2, cmd;
+ int opt1, cmd;
if (*opt++ != '-')
return -1;
cmd = *opt++;
if (cmd == '-') {
/* convert the long-form arguments into short-form versions */
- if (skip_prefix(opt, "break-rewrites", &opt)) {
- if (*opt == 0 || *opt++ == '=')
- cmd = 'B';
- } else if (skip_prefix(opt, "find-copies", &opt)) {
+ if (skip_prefix(opt, "find-copies", &opt)) {
if (*opt == 0 || *opt++ == '=')
cmd = 'C';
} else if (skip_prefix(opt, "find-renames", &opt)) {
@@ -5346,25 +5368,13 @@ static int diff_scoreopt_parse(const char *opt)
cmd = 'M';
}
}
- if (cmd != 'M' && cmd != 'C' && cmd != 'B')
- return -1; /* that is not a -M, -C, or -B option */
+ if (cmd != 'M' && cmd != 'C')
+ return -1; /* that is not a -M, or -C option */
opt1 = parse_rename_score(&opt);
- if (cmd != 'B')
- opt2 = 0;
- else {
- if (*opt == 0)
- opt2 = 0;
- else if (*opt != '/')
- return -1; /* we expect -B80/99 or -B80 */
- else {
- opt++;
- opt2 = parse_rename_score(&opt);
- }
- }
if (*opt != 0)
return -1;
- return opt1 | (opt2 << 16);
+ return opt1;
}
struct diff_queue_struct diff_queued_diff;
--
2.21.0.rc0.328.g0e39304f8d
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v3 14/21] diff-parseopt: convert -M|--find-renames
2019-02-16 11:36 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
` (12 preceding siblings ...)
2019-02-16 11:36 ` [PATCH v3 13/21] diff-parseopt: convert -B|--break-rewrites Nguyễn Thái Ngọc Duy
@ 2019-02-16 11:36 ` Nguyễn Thái Ngọc Duy
2019-02-16 11:36 ` [PATCH v3 15/21] diff-parseopt: convert -D|--irreversible-delete Nguyễn Thái Ngọc Duy
` (7 subsequent siblings)
21 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-16 11:36 UTC (permalink / raw)
To: pclouds; +Cc: git, gitster, SZEDER Gábor
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 35 +++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/diff.c b/diff.c
index d2139082b7..2c904e0526 100644
--- a/diff.c
+++ b/diff.c
@@ -4909,6 +4909,22 @@ static int diff_opt_dirstat(const struct option *opt,
return 0;
}
+static int diff_opt_find_renames(const struct option *opt,
+ const char *arg, int unset)
+{
+ struct diff_options *options = opt->value;
+
+ BUG_ON_OPT_NEG(unset);
+ if (!arg)
+ arg = "";
+ options->rename_score = parse_rename_score(&arg);
+ if (*arg != 0)
+ return error(_("invalid argument to %s"), opt->long_name);
+
+ options->detect_rename = DIFF_DETECT_RENAME;
+ return 0;
+}
+
static enum parse_opt_result diff_opt_output(struct parse_opt_ctx_t *ctx,
const struct option *opt,
const char *arg, int unset)
@@ -5040,6 +5056,10 @@ static void prep_parse_options(struct diff_options *options)
N_("break complete rewrite changes into pairs of delete and create"),
PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
diff_opt_break_rewrites),
+ OPT_CALLBACK_F('M', "find-renames", options, N_("<n>"),
+ N_("detect renames"),
+ PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
+ diff_opt_find_renames),
OPT_GROUP(N_("Diff other options")),
{ OPTION_CALLBACK, 0, "output", options, N_("<file>"),
@@ -5074,13 +5094,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* renames options */
- if (starts_with(arg, "-M") ||
- skip_to_optional_arg(arg, "--find-renames", NULL)) {
- if ((options->rename_score = diff_scoreopt_parse(arg)) == -1)
- return error("invalid argument to -M: %s", arg+2);
- options->detect_rename = DIFF_DETECT_RENAME;
- }
- else if (!strcmp(arg, "-D") || !strcmp(arg, "--irreversible-delete")) {
+ if (!strcmp(arg, "-D") || !strcmp(arg, "--irreversible-delete")) {
options->irreversible_delete = 1;
}
else if (starts_with(arg, "-C") ||
@@ -5363,13 +5377,10 @@ static int diff_scoreopt_parse(const char *opt)
if (skip_prefix(opt, "find-copies", &opt)) {
if (*opt == 0 || *opt++ == '=')
cmd = 'C';
- } else if (skip_prefix(opt, "find-renames", &opt)) {
- if (*opt == 0 || *opt++ == '=')
- cmd = 'M';
}
}
- if (cmd != 'M' && cmd != 'C')
- return -1; /* that is not a -M, or -C option */
+ if (cmd != 'C')
+ return -1; /* that is not a -M option */
opt1 = parse_rename_score(&opt);
if (*opt != 0)
--
2.21.0.rc0.328.g0e39304f8d
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v3 15/21] diff-parseopt: convert -D|--irreversible-delete
2019-02-16 11:36 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
` (13 preceding siblings ...)
2019-02-16 11:36 ` [PATCH v3 14/21] diff-parseopt: convert -M|--find-renames Nguyễn Thái Ngọc Duy
@ 2019-02-16 11:36 ` Nguyễn Thái Ngọc Duy
2019-02-16 11:36 ` [PATCH v3 16/21] diff-parseopt: convert -C|--find-copies Nguyễn Thái Ngọc Duy
` (6 subsequent siblings)
21 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-16 11:36 UTC (permalink / raw)
To: pclouds; +Cc: git, gitster, SZEDER Gábor
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/diff.c b/diff.c
index 2c904e0526..e51f6b3005 100644
--- a/diff.c
+++ b/diff.c
@@ -5060,6 +5060,9 @@ static void prep_parse_options(struct diff_options *options)
N_("detect renames"),
PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
diff_opt_find_renames),
+ OPT_SET_INT_F('D', "irreversible-delete", &options->irreversible_delete,
+ N_("omit the preimage for deletes"),
+ 1, PARSE_OPT_NONEG),
OPT_GROUP(N_("Diff other options")),
{ OPTION_CALLBACK, 0, "output", options, N_("<file>"),
@@ -5094,10 +5097,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* renames options */
- if (!strcmp(arg, "-D") || !strcmp(arg, "--irreversible-delete")) {
- options->irreversible_delete = 1;
- }
- else if (starts_with(arg, "-C") ||
+ if (starts_with(arg, "-C") ||
skip_to_optional_arg(arg, "--find-copies", NULL)) {
if (options->detect_rename == DIFF_DETECT_COPY)
options->flags.find_copies_harder = 1;
--
2.21.0.rc0.328.g0e39304f8d
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v3 16/21] diff-parseopt: convert -C|--find-copies
2019-02-16 11:36 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
` (14 preceding siblings ...)
2019-02-16 11:36 ` [PATCH v3 15/21] diff-parseopt: convert -D|--irreversible-delete Nguyễn Thái Ngọc Duy
@ 2019-02-16 11:36 ` Nguyễn Thái Ngọc Duy
2019-02-16 11:36 ` [PATCH v3 17/21] diff-parseopt: convert --find-copies-harder Nguyễn Thái Ngọc Duy
` (5 subsequent siblings)
21 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-16 11:36 UTC (permalink / raw)
To: pclouds; +Cc: git, gitster, SZEDER Gábor
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 59 +++++++++++++++++++++++++---------------------------------
1 file changed, 25 insertions(+), 34 deletions(-)
diff --git a/diff.c b/diff.c
index e51f6b3005..35bac115cc 100644
--- a/diff.c
+++ b/diff.c
@@ -4617,8 +4617,6 @@ static int opt_arg(const char *arg, int arg_short, const char *arg_long, int *va
return 1;
}
-static int diff_scoreopt_parse(const char *opt);
-
static inline int short_opt(char opt, const char **argv,
const char **optarg)
{
@@ -4909,6 +4907,26 @@ static int diff_opt_dirstat(const struct option *opt,
return 0;
}
+static int diff_opt_find_copies(const struct option *opt,
+ const char *arg, int unset)
+{
+ struct diff_options *options = opt->value;
+
+ BUG_ON_OPT_NEG(unset);
+ if (!arg)
+ arg = "";
+ options->rename_score = parse_rename_score(&arg);
+ if (*arg != 0)
+ return error(_("invalid argument to %s"), opt->long_name);
+
+ if (options->detect_rename == DIFF_DETECT_COPY)
+ options->flags.find_copies_harder = 1;
+ else
+ options->detect_rename = DIFF_DETECT_COPY;
+
+ return 0;
+}
+
static int diff_opt_find_renames(const struct option *opt,
const char *arg, int unset)
{
@@ -5063,6 +5081,10 @@ static void prep_parse_options(struct diff_options *options)
OPT_SET_INT_F('D', "irreversible-delete", &options->irreversible_delete,
N_("omit the preimage for deletes"),
1, PARSE_OPT_NONEG),
+ OPT_CALLBACK_F('C', "find-copies", options, N_("<n>"),
+ N_("detect copies"),
+ PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
+ diff_opt_find_copies),
OPT_GROUP(N_("Diff other options")),
{ OPTION_CALLBACK, 0, "output", options, N_("<file>"),
@@ -5097,15 +5119,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* renames options */
- if (starts_with(arg, "-C") ||
- skip_to_optional_arg(arg, "--find-copies", NULL)) {
- if (options->detect_rename == DIFF_DETECT_COPY)
- options->flags.find_copies_harder = 1;
- if ((options->rename_score = diff_scoreopt_parse(arg)) == -1)
- return error("invalid argument to -C: %s", arg+2);
- options->detect_rename = DIFF_DETECT_COPY;
- }
- else if (!strcmp(arg, "--no-renames"))
+ if (!strcmp(arg, "--no-renames"))
options->detect_rename = 0;
else if (!strcmp(arg, "--rename-empty"))
options->flags.rename_empty = 1;
@@ -5365,29 +5379,6 @@ int parse_rename_score(const char **cp_p)
return (int)((num >= scale) ? MAX_SCORE : (MAX_SCORE * num / scale));
}
-static int diff_scoreopt_parse(const char *opt)
-{
- int opt1, cmd;
-
- if (*opt++ != '-')
- return -1;
- cmd = *opt++;
- if (cmd == '-') {
- /* convert the long-form arguments into short-form versions */
- if (skip_prefix(opt, "find-copies", &opt)) {
- if (*opt == 0 || *opt++ == '=')
- cmd = 'C';
- }
- }
- if (cmd != 'C')
- return -1; /* that is not a -M option */
-
- opt1 = parse_rename_score(&opt);
- if (*opt != 0)
- return -1;
- return opt1;
-}
-
struct diff_queue_struct diff_queued_diff;
void diff_q(struct diff_queue_struct *queue, struct diff_filepair *dp)
--
2.21.0.rc0.328.g0e39304f8d
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v3 17/21] diff-parseopt: convert --find-copies-harder
2019-02-16 11:36 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
` (15 preceding siblings ...)
2019-02-16 11:36 ` [PATCH v3 16/21] diff-parseopt: convert -C|--find-copies Nguyễn Thái Ngọc Duy
@ 2019-02-16 11:36 ` Nguyễn Thái Ngọc Duy
2019-02-16 11:36 ` [PATCH v3 18/21] diff-parseopt: convert --no-renames|--[no--rename-empty Nguyễn Thái Ngọc Duy
` (4 subsequent siblings)
21 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-16 11:36 UTC (permalink / raw)
To: pclouds; +Cc: git, gitster, SZEDER Gábor
--no-find-copies-harder is also added on purpose (because I don't see
why we should not have the --no- version for this)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/diff.c b/diff.c
index 35bac115cc..abb1566f95 100644
--- a/diff.c
+++ b/diff.c
@@ -5085,6 +5085,8 @@ static void prep_parse_options(struct diff_options *options)
N_("detect copies"),
PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
diff_opt_find_copies),
+ OPT_BOOL(0, "find-copies-harder", &options->flags.find_copies_harder,
+ N_("use unmodified files as source to find copies")),
OPT_GROUP(N_("Diff other options")),
{ OPTION_CALLBACK, 0, "output", options, N_("<file>"),
@@ -5191,8 +5193,6 @@ int diff_opt_parse(struct diff_options *options,
options->flags.text = 1;
else if (!strcmp(arg, "-R"))
options->flags.reverse_diff = 1;
- else if (!strcmp(arg, "--find-copies-harder"))
- options->flags.find_copies_harder = 1;
else if (!strcmp(arg, "--follow"))
options->flags.follow_renames = 1;
else if (!strcmp(arg, "--no-follow")) {
--
2.21.0.rc0.328.g0e39304f8d
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v3 18/21] diff-parseopt: convert --no-renames|--[no--rename-empty
2019-02-16 11:36 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
` (16 preceding siblings ...)
2019-02-16 11:36 ` [PATCH v3 17/21] diff-parseopt: convert --find-copies-harder Nguyễn Thái Ngọc Duy
@ 2019-02-16 11:36 ` Nguyễn Thái Ngọc Duy
2019-02-16 11:36 ` [PATCH v3 19/21] diff-parseopt: convert --relative Nguyễn Thái Ngọc Duy
` (3 subsequent siblings)
21 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-16 11:36 UTC (permalink / raw)
To: pclouds; +Cc: git, gitster, SZEDER Gábor
For --rename-empty, see 90d43b0768 (teach diffcore-rename to
optionally ignore empty content - 2012-03-22) for more information.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
Documentation/diff-options.txt | 3 +++
diff.c | 13 ++++++-------
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index d3e8d634b2..4c0d40881b 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -392,6 +392,9 @@ endif::git-format-patch[]
Turn off rename detection, even when the configuration
file gives the default to do so.
+--[no-]rename-empty::
+ Whether to use empty blobs as rename source.
+
ifndef::git-format-patch[]
--check::
Warn if changes introduce conflict markers or whitespace errors.
diff --git a/diff.c b/diff.c
index abb1566f95..d423a06b41 100644
--- a/diff.c
+++ b/diff.c
@@ -5087,6 +5087,11 @@ static void prep_parse_options(struct diff_options *options)
diff_opt_find_copies),
OPT_BOOL(0, "find-copies-harder", &options->flags.find_copies_harder,
N_("use unmodified files as source to find copies")),
+ OPT_SET_INT_F(0, "no-renames", &options->detect_rename,
+ N_("disable rename detection"),
+ 0, PARSE_OPT_NONEG),
+ OPT_BOOL(0, "rename-empty", &options->flags.rename_empty,
+ N_("use empty blobs as rename source")),
OPT_GROUP(N_("Diff other options")),
{ OPTION_CALLBACK, 0, "output", options, N_("<file>"),
@@ -5121,13 +5126,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* renames options */
- if (!strcmp(arg, "--no-renames"))
- options->detect_rename = 0;
- else if (!strcmp(arg, "--rename-empty"))
- options->flags.rename_empty = 1;
- else if (!strcmp(arg, "--no-rename-empty"))
- options->flags.rename_empty = 0;
- else if (skip_to_optional_arg_default(arg, "--relative", &arg, NULL)) {
+ if (skip_to_optional_arg_default(arg, "--relative", &arg, NULL)) {
options->flags.relative_name = 1;
if (arg)
options->prefix = arg;
--
2.21.0.rc0.328.g0e39304f8d
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v3 19/21] diff-parseopt: convert --relative
2019-02-16 11:36 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
` (17 preceding siblings ...)
2019-02-16 11:36 ` [PATCH v3 18/21] diff-parseopt: convert --no-renames|--[no--rename-empty Nguyễn Thái Ngọc Duy
@ 2019-02-16 11:36 ` Nguyễn Thái Ngọc Duy
2019-02-16 11:36 ` [PATCH v3 20/21] diff-parseopt: convert --[no-]minimal Nguyễn Thái Ngọc Duy
` (2 subsequent siblings)
21 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-16 11:36 UTC (permalink / raw)
To: pclouds; +Cc: git, gitster, SZEDER Gábor
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/diff.c b/diff.c
index d423a06b41..b9c267a199 100644
--- a/diff.c
+++ b/diff.c
@@ -4960,6 +4960,18 @@ static enum parse_opt_result diff_opt_output(struct parse_opt_ctx_t *ctx,
return 0;
}
+static int diff_opt_relative(const struct option *opt,
+ const char *arg, int unset)
+{
+ struct diff_options *options = opt->value;
+
+ BUG_ON_OPT_NEG(unset);
+ options->flags.relative_name = 1;
+ if (arg)
+ options->prefix = arg;
+ return 0;
+}
+
static int diff_opt_unified(const struct option *opt,
const char *arg, int unset)
{
@@ -5094,6 +5106,10 @@ static void prep_parse_options(struct diff_options *options)
N_("use empty blobs as rename source")),
OPT_GROUP(N_("Diff other options")),
+ OPT_CALLBACK_F(0, "relative", options, N_("<prefix>"),
+ N_("when run from subdir, exclude changes outside and show relative paths"),
+ PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
+ diff_opt_relative),
{ OPTION_CALLBACK, 0, "output", options, N_("<file>"),
N_("Output to a specific file"),
PARSE_OPT_NONEG, NULL, 0, diff_opt_output },
@@ -5125,15 +5141,8 @@ int diff_opt_parse(struct diff_options *options,
if (ac)
return ac;
- /* renames options */
- if (skip_to_optional_arg_default(arg, "--relative", &arg, NULL)) {
- options->flags.relative_name = 1;
- if (arg)
- options->prefix = arg;
- }
-
/* xdiff options */
- else if (!strcmp(arg, "--minimal"))
+ if (!strcmp(arg, "--minimal"))
DIFF_XDL_SET(options, NEED_MINIMAL);
else if (!strcmp(arg, "--no-minimal"))
DIFF_XDL_CLR(options, NEED_MINIMAL);
--
2.21.0.rc0.328.g0e39304f8d
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v3 20/21] diff-parseopt: convert --[no-]minimal
2019-02-16 11:36 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
` (18 preceding siblings ...)
2019-02-16 11:36 ` [PATCH v3 19/21] diff-parseopt: convert --relative Nguyễn Thái Ngọc Duy
@ 2019-02-16 11:36 ` Nguyễn Thái Ngọc Duy
2019-02-16 11:36 ` [PATCH v3 21/21] diff-parseopt: convert --ignore-some-changes Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 00/21] nd/diff-parseopt-2 updates Nguyễn Thái Ngọc Duy
21 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-16 11:36 UTC (permalink / raw)
To: pclouds; +Cc: git, gitster, SZEDER Gábor
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/diff.c b/diff.c
index b9c267a199..33492e754f 100644
--- a/diff.c
+++ b/diff.c
@@ -5105,6 +5105,11 @@ static void prep_parse_options(struct diff_options *options)
OPT_BOOL(0, "rename-empty", &options->flags.rename_empty,
N_("use empty blobs as rename source")),
+ OPT_GROUP(N_("Diff algorithm options")),
+ OPT_BIT(0, "minimal", &options->xdl_opts,
+ N_("produce the smallest possible diff"),
+ XDF_NEED_MINIMAL),
+
OPT_GROUP(N_("Diff other options")),
OPT_CALLBACK_F(0, "relative", options, N_("<prefix>"),
N_("when run from subdir, exclude changes outside and show relative paths"),
@@ -5142,11 +5147,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* xdiff options */
- if (!strcmp(arg, "--minimal"))
- DIFF_XDL_SET(options, NEED_MINIMAL);
- else if (!strcmp(arg, "--no-minimal"))
- DIFF_XDL_CLR(options, NEED_MINIMAL);
- else if (!strcmp(arg, "-w") || !strcmp(arg, "--ignore-all-space"))
+ if (!strcmp(arg, "-w") || !strcmp(arg, "--ignore-all-space"))
DIFF_XDL_SET(options, IGNORE_WHITESPACE);
else if (!strcmp(arg, "-b") || !strcmp(arg, "--ignore-space-change"))
DIFF_XDL_SET(options, IGNORE_WHITESPACE_CHANGE);
--
2.21.0.rc0.328.g0e39304f8d
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v3 21/21] diff-parseopt: convert --ignore-some-changes
2019-02-16 11:36 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
` (19 preceding siblings ...)
2019-02-16 11:36 ` [PATCH v3 20/21] diff-parseopt: convert --[no-]minimal Nguyễn Thái Ngọc Duy
@ 2019-02-16 11:36 ` Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 00/21] nd/diff-parseopt-2 updates Nguyễn Thái Ngọc Duy
21 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-16 11:36 UTC (permalink / raw)
To: pclouds; +Cc: git, gitster, SZEDER Gábor
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/diff.c b/diff.c
index 33492e754f..a63ee4a44d 100644
--- a/diff.c
+++ b/diff.c
@@ -5109,6 +5109,21 @@ static void prep_parse_options(struct diff_options *options)
OPT_BIT(0, "minimal", &options->xdl_opts,
N_("produce the smallest possible diff"),
XDF_NEED_MINIMAL),
+ OPT_BIT_F('w', "ignore-all-space", &options->xdl_opts,
+ N_("ignore whitespace when comparing lines"),
+ XDF_IGNORE_WHITESPACE, PARSE_OPT_NONEG),
+ OPT_BIT_F('b', "ignore-space-change", &options->xdl_opts,
+ N_("ignore changes in amount of whitespace"),
+ XDF_IGNORE_WHITESPACE_CHANGE, PARSE_OPT_NONEG),
+ OPT_BIT_F(0, "ignore-space-at-eol", &options->xdl_opts,
+ N_("ignore changes in whitespace at EOL"),
+ XDF_IGNORE_WHITESPACE_AT_EOL, PARSE_OPT_NONEG),
+ OPT_BIT_F(0, "ignore-cr-at-eol", &options->xdl_opts,
+ N_("ignore carrier-return at the end of line"),
+ XDF_IGNORE_CR_AT_EOL, PARSE_OPT_NONEG),
+ OPT_BIT_F(0, "ignore-blank-lines", &options->xdl_opts,
+ N_("ignore changes whose lines are all blank"),
+ XDF_IGNORE_BLANK_LINES, PARSE_OPT_NONEG),
OPT_GROUP(N_("Diff other options")),
OPT_CALLBACK_F(0, "relative", options, N_("<prefix>"),
@@ -5147,17 +5162,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* xdiff options */
- if (!strcmp(arg, "-w") || !strcmp(arg, "--ignore-all-space"))
- DIFF_XDL_SET(options, IGNORE_WHITESPACE);
- else if (!strcmp(arg, "-b") || !strcmp(arg, "--ignore-space-change"))
- DIFF_XDL_SET(options, IGNORE_WHITESPACE_CHANGE);
- else if (!strcmp(arg, "--ignore-space-at-eol"))
- DIFF_XDL_SET(options, IGNORE_WHITESPACE_AT_EOL);
- else if (!strcmp(arg, "--ignore-cr-at-eol"))
- DIFF_XDL_SET(options, IGNORE_CR_AT_EOL);
- else if (!strcmp(arg, "--ignore-blank-lines"))
- DIFF_XDL_SET(options, IGNORE_BLANK_LINES);
- else if (!strcmp(arg, "--indent-heuristic"))
+ if (!strcmp(arg, "--indent-heuristic"))
DIFF_XDL_SET(options, INDENT_HEURISTIC);
else if (!strcmp(arg, "--no-indent-heuristic"))
DIFF_XDL_CLR(options, INDENT_HEURISTIC);
--
2.21.0.rc0.328.g0e39304f8d
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v4 00/21] nd/diff-parseopt-2 updates
2019-02-16 11:36 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
` (20 preceding siblings ...)
2019-02-16 11:36 ` [PATCH v3 21/21] diff-parseopt: convert --ignore-some-changes Nguyễn Thái Ngọc Duy
@ 2019-02-21 11:16 ` Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 01/21] diff-parseopt: convert --patch-with-raw Nguyễn Thái Ngọc Duy
` (20 more replies)
21 siblings, 21 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-21 11:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, rybak.a.v, Nguyễn Thái Ngọc Duy
Super tiny document update noticed by Andrei.
Range-diff dựa trên v3:
1: 38230c7de4 ! 1: 070164af4d diff-parseopt: convert --dirstat and friends
@@ -3,7 +3,6 @@
diff-parseopt: convert --dirstat and friends
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
- Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
--- a/Documentation/diff-options.txt
@@ -12,7 +11,7 @@
number of modified files, as well as number of added and deleted
lines.
-+-X<param1,param2,...>::
++-X[<param1,param2,...>]::
--dirstat[=<param1,param2,...>]::
Output the distribution of relative amount of changes for each
sub-directory. The behavior of `--dirstat` can be customized by
2: 3ae4e6cd92 = 2: 89b1103e76 diff-parseopt: convert --check
3: 127056f59c = 3: fedf018125 diff-parseopt: convert --summary
4: f6329c8d41 = 4: 13cb7ab220 diff-parseopt: convert --patch-with-stat
5: aec0afbe0d = 5: f1aad0dd16 diff-parseopt: convert --name-only
6: bcbeaf3792 = 6: 69724a34d5 diff-parseopt: convert --name-status
7: 23a9f378ed = 7: 6d388db7ae diff-parseopt: convert -s|--no-patch
8: 3376918b02 = 8: c378c333fe diff-parseopt: convert --stat*
9: 6bc89cece3 = 9: 089d37bc74 diff-parseopt: convert --[no-]compact-summary
10: 327e4ce71d = 10: 36731a8c60 diff-parseopt: convert --output-*
11: a7fd8b2637 = 11: c043243fac diff-parseopt: convert -B|--break-rewrites
12: abe34ced9b = 12: 52da05a2fe diff-parseopt: convert -M|--find-renames
13: 27a03cf277 = 13: 4fe9111123 diff-parseopt: convert -D|--irreversible-delete
14: d0e744740a = 14: b85e3bb302 diff-parseopt: convert -C|--find-copies
15: 71d80976eb = 15: bd7f8fe4ae diff-parseopt: convert --find-copies-harder
16: e066d3b245 = 16: ed3b271d82 diff-parseopt: convert --no-renames|--[no--rename-empty
17: f35c5d409d = 17: 6bebd80fee diff-parseopt: convert --relative
18: a560fa8cd6 = 18: a6ae538b90 diff-parseopt: convert --[no-]minimal
19: 97c424c1ce = 19: ed3634e0bd diff-parseopt: convert --ignore-some-changes
Nguyễn Thái Ngọc Duy (21):
diff-parseopt: convert --patch-with-raw
diff-parseopt: convert --numstat and --shortstat
diff-parseopt: convert --dirstat and friends
diff-parseopt: convert --check
diff-parseopt: convert --summary
diff-parseopt: convert --patch-with-stat
diff-parseopt: convert --name-only
diff-parseopt: convert --name-status
diff-parseopt: convert -s|--no-patch
diff-parseopt: convert --stat*
diff-parseopt: convert --[no-]compact-summary
diff-parseopt: convert --output-*
diff-parseopt: convert -B|--break-rewrites
diff-parseopt: convert -M|--find-renames
diff-parseopt: convert -D|--irreversible-delete
diff-parseopt: convert -C|--find-copies
diff-parseopt: convert --find-copies-harder
diff-parseopt: convert --no-renames|--[no--rename-empty
diff-parseopt: convert --relative
diff-parseopt: convert --[no-]minimal
diff-parseopt: convert --ignore-some-changes
Documentation/diff-options.txt | 20 ++
diff.c | 510 +++++++++++++++++++--------------
2 files changed, 319 insertions(+), 211 deletions(-)
--
2.21.0.rc1.337.gdf7f8d0522
^ permalink raw reply [flat|nested] 80+ messages in thread
* [PATCH v4 01/21] diff-parseopt: convert --patch-with-raw
2019-02-21 11:16 ` [PATCH v4 00/21] nd/diff-parseopt-2 updates Nguyễn Thái Ngọc Duy
@ 2019-02-21 11:16 ` Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 02/21] diff-parseopt: convert --numstat and --shortstat Nguyễn Thái Ngọc Duy
` (19 subsequent siblings)
20 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-21 11:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, rybak.a.v, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/diff.c b/diff.c
index 4bc9df7362..12e333c67f 100644
--- a/diff.c
+++ b/diff.c
@@ -4901,6 +4901,10 @@ static void prep_parse_options(struct diff_options *options)
OPT_BIT_F(0, "raw", &options->output_format,
N_("generate the diff in raw format"),
DIFF_FORMAT_RAW, PARSE_OPT_NONEG),
+ OPT_BITOP(0, "patch-with-raw", &options->output_format,
+ N_("synonym for '-p --raw'"),
+ DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW,
+ DIFF_FORMAT_NO_OUTPUT),
OPT_END()
};
@@ -4929,10 +4933,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* Output format options */
- if (!strcmp(arg, "--patch-with-raw")) {
- enable_patch_output(&options->output_format);
- options->output_format |= DIFF_FORMAT_RAW;
- } else if (!strcmp(arg, "--numstat"))
+ if (!strcmp(arg, "--numstat"))
options->output_format |= DIFF_FORMAT_NUMSTAT;
else if (!strcmp(arg, "--shortstat"))
options->output_format |= DIFF_FORMAT_SHORTSTAT;
--
2.21.0.rc1.337.gdf7f8d0522
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v4 02/21] diff-parseopt: convert --numstat and --shortstat
2019-02-21 11:16 ` [PATCH v4 00/21] nd/diff-parseopt-2 updates Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 01/21] diff-parseopt: convert --patch-with-raw Nguyễn Thái Ngọc Duy
@ 2019-02-21 11:16 ` Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 03/21] diff-parseopt: convert --dirstat and friends Nguyễn Thái Ngọc Duy
` (18 subsequent siblings)
20 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-21 11:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, rybak.a.v, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/diff.c b/diff.c
index 12e333c67f..419b6ac4ae 100644
--- a/diff.c
+++ b/diff.c
@@ -4905,6 +4905,12 @@ static void prep_parse_options(struct diff_options *options)
N_("synonym for '-p --raw'"),
DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW,
DIFF_FORMAT_NO_OUTPUT),
+ OPT_BIT_F(0, "numstat", &options->output_format,
+ N_("machine friendly --stat"),
+ DIFF_FORMAT_NUMSTAT, PARSE_OPT_NONEG),
+ OPT_BIT_F(0, "shortstat", &options->output_format,
+ N_("output only the last line of --stat"),
+ DIFF_FORMAT_SHORTSTAT, PARSE_OPT_NONEG),
OPT_END()
};
@@ -4933,11 +4939,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* Output format options */
- if (!strcmp(arg, "--numstat"))
- options->output_format |= DIFF_FORMAT_NUMSTAT;
- else if (!strcmp(arg, "--shortstat"))
- options->output_format |= DIFF_FORMAT_SHORTSTAT;
- else if (skip_prefix(arg, "-X", &arg) ||
+ if (skip_prefix(arg, "-X", &arg) ||
skip_to_optional_arg(arg, "--dirstat", &arg))
return parse_dirstat_opt(options, arg);
else if (!strcmp(arg, "--cumulative"))
--
2.21.0.rc1.337.gdf7f8d0522
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v4 03/21] diff-parseopt: convert --dirstat and friends
2019-02-21 11:16 ` [PATCH v4 00/21] nd/diff-parseopt-2 updates Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 01/21] diff-parseopt: convert --patch-with-raw Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 02/21] diff-parseopt: convert --numstat and --shortstat Nguyễn Thái Ngọc Duy
@ 2019-02-21 11:16 ` Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 04/21] diff-parseopt: convert --check Nguyễn Thái Ngọc Duy
` (17 subsequent siblings)
20 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-21 11:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, rybak.a.v, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
Documentation/diff-options.txt | 7 ++++++
diff.c | 39 +++++++++++++++++++++++++---------
2 files changed, 36 insertions(+), 10 deletions(-)
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 0711734b12..7b81b852ca 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -148,6 +148,7 @@ These parameters can also be set individually with `--stat-width=<width>`,
number of modified files, as well as number of added and deleted
lines.
+-X[<param1,param2,...>]::
--dirstat[=<param1,param2,...>]::
Output the distribution of relative amount of changes for each
sub-directory. The behavior of `--dirstat` can be customized by
@@ -192,6 +193,12 @@ directories with less than 10% of the total amount of changed files,
and accumulating child directory counts in the parent directories:
`--dirstat=files,10,cumulative`.
+--cumulative::
+ Synonym for --dirstat=cumulative
+
+--dirstat-by-file[=<param1,param2>...]::
+ Synonym for --dirstat=files,param1,param2...
+
--summary::
Output a condensed summary of extended header information
such as creations, renames and mode changes.
diff --git a/diff.c b/diff.c
index 419b6ac4ae..1cdbe8e688 100644
--- a/diff.c
+++ b/diff.c
@@ -4867,6 +4867,22 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)
return 1;
}
+static int diff_opt_dirstat(const struct option *opt,
+ const char *arg, int unset)
+{
+ struct diff_options *options = opt->value;
+
+ BUG_ON_OPT_NEG(unset);
+ if (!strcmp(opt->long_name, "cumulative")) {
+ if (arg)
+ BUG("how come --cumulative take a value?");
+ arg = "cumulative";
+ } else if (!strcmp(opt->long_name, "dirstat-by-file"))
+ parse_dirstat_opt(options, "files");
+ parse_dirstat_opt(options, arg ? arg : "");
+ return 0;
+}
+
static int diff_opt_unified(const struct option *opt,
const char *arg, int unset)
{
@@ -4911,6 +4927,18 @@ static void prep_parse_options(struct diff_options *options)
OPT_BIT_F(0, "shortstat", &options->output_format,
N_("output only the last line of --stat"),
DIFF_FORMAT_SHORTSTAT, PARSE_OPT_NONEG),
+ OPT_CALLBACK_F('X', "dirstat", options, N_("<param1,param2>..."),
+ N_("output the distribution of relative amount of changes for each sub-directory"),
+ PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
+ diff_opt_dirstat),
+ OPT_CALLBACK_F(0, "cumulative", options, NULL,
+ N_("synonym for --dirstat=cumulative"),
+ PARSE_OPT_NONEG | PARSE_OPT_NOARG,
+ diff_opt_dirstat),
+ OPT_CALLBACK_F(0, "dirstat-by-file", options, N_("<param1,param2>..."),
+ N_("synonym for --dirstat=files,param1,param2..."),
+ PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
+ diff_opt_dirstat),
OPT_END()
};
@@ -4939,16 +4967,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* Output format options */
- if (skip_prefix(arg, "-X", &arg) ||
- skip_to_optional_arg(arg, "--dirstat", &arg))
- return parse_dirstat_opt(options, arg);
- else if (!strcmp(arg, "--cumulative"))
- return parse_dirstat_opt(options, "cumulative");
- else if (skip_to_optional_arg(arg, "--dirstat-by-file", &arg)) {
- parse_dirstat_opt(options, "files");
- return parse_dirstat_opt(options, arg);
- }
- else if (!strcmp(arg, "--check"))
+ if (!strcmp(arg, "--check"))
options->output_format |= DIFF_FORMAT_CHECKDIFF;
else if (!strcmp(arg, "--summary"))
options->output_format |= DIFF_FORMAT_SUMMARY;
--
2.21.0.rc1.337.gdf7f8d0522
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v4 04/21] diff-parseopt: convert --check
2019-02-21 11:16 ` [PATCH v4 00/21] nd/diff-parseopt-2 updates Nguyễn Thái Ngọc Duy
` (2 preceding siblings ...)
2019-02-21 11:16 ` [PATCH v4 03/21] diff-parseopt: convert --dirstat and friends Nguyễn Thái Ngọc Duy
@ 2019-02-21 11:16 ` Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 05/21] diff-parseopt: convert --summary Nguyễn Thái Ngọc Duy
` (16 subsequent siblings)
20 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-21 11:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, rybak.a.v, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/diff.c b/diff.c
index 1cdbe8e688..5e16082091 100644
--- a/diff.c
+++ b/diff.c
@@ -4939,6 +4939,9 @@ static void prep_parse_options(struct diff_options *options)
N_("synonym for --dirstat=files,param1,param2..."),
PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
diff_opt_dirstat),
+ OPT_BIT_F(0, "check", &options->output_format,
+ N_("warn if changes introduce conflict markers or whitespace errors"),
+ DIFF_FORMAT_CHECKDIFF, PARSE_OPT_NONEG),
OPT_END()
};
@@ -4967,9 +4970,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* Output format options */
- if (!strcmp(arg, "--check"))
- options->output_format |= DIFF_FORMAT_CHECKDIFF;
- else if (!strcmp(arg, "--summary"))
+ if (!strcmp(arg, "--summary"))
options->output_format |= DIFF_FORMAT_SUMMARY;
else if (!strcmp(arg, "--patch-with-stat")) {
enable_patch_output(&options->output_format);
--
2.21.0.rc1.337.gdf7f8d0522
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v4 05/21] diff-parseopt: convert --summary
2019-02-21 11:16 ` [PATCH v4 00/21] nd/diff-parseopt-2 updates Nguyễn Thái Ngọc Duy
` (3 preceding siblings ...)
2019-02-21 11:16 ` [PATCH v4 04/21] diff-parseopt: convert --check Nguyễn Thái Ngọc Duy
@ 2019-02-21 11:16 ` Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 06/21] diff-parseopt: convert --patch-with-stat Nguyễn Thái Ngọc Duy
` (15 subsequent siblings)
20 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-21 11:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, rybak.a.v, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/diff.c b/diff.c
index 5e16082091..0276f25200 100644
--- a/diff.c
+++ b/diff.c
@@ -4942,6 +4942,9 @@ static void prep_parse_options(struct diff_options *options)
OPT_BIT_F(0, "check", &options->output_format,
N_("warn if changes introduce conflict markers or whitespace errors"),
DIFF_FORMAT_CHECKDIFF, PARSE_OPT_NONEG),
+ OPT_BIT_F(0, "summary", &options->output_format,
+ N_("condensed summary such as creations, renames and mode changes"),
+ DIFF_FORMAT_SUMMARY, PARSE_OPT_NONEG),
OPT_END()
};
@@ -4970,9 +4973,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* Output format options */
- if (!strcmp(arg, "--summary"))
- options->output_format |= DIFF_FORMAT_SUMMARY;
- else if (!strcmp(arg, "--patch-with-stat")) {
+ if (!strcmp(arg, "--patch-with-stat")) {
enable_patch_output(&options->output_format);
options->output_format |= DIFF_FORMAT_DIFFSTAT;
} else if (!strcmp(arg, "--name-only"))
--
2.21.0.rc1.337.gdf7f8d0522
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v4 06/21] diff-parseopt: convert --patch-with-stat
2019-02-21 11:16 ` [PATCH v4 00/21] nd/diff-parseopt-2 updates Nguyễn Thái Ngọc Duy
` (4 preceding siblings ...)
2019-02-21 11:16 ` [PATCH v4 05/21] diff-parseopt: convert --summary Nguyễn Thái Ngọc Duy
@ 2019-02-21 11:16 ` Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 07/21] diff-parseopt: convert --name-only Nguyễn Thái Ngọc Duy
` (14 subsequent siblings)
20 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-21 11:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, rybak.a.v, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/diff.c b/diff.c
index 0276f25200..b9811aefef 100644
--- a/diff.c
+++ b/diff.c
@@ -4921,6 +4921,10 @@ static void prep_parse_options(struct diff_options *options)
N_("synonym for '-p --raw'"),
DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW,
DIFF_FORMAT_NO_OUTPUT),
+ OPT_BITOP(0, "patch-with-stat", &options->output_format,
+ N_("synonym for '-p --stat'"),
+ DIFF_FORMAT_PATCH | DIFF_FORMAT_DIFFSTAT,
+ DIFF_FORMAT_NO_OUTPUT),
OPT_BIT_F(0, "numstat", &options->output_format,
N_("machine friendly --stat"),
DIFF_FORMAT_NUMSTAT, PARSE_OPT_NONEG),
@@ -4973,10 +4977,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* Output format options */
- if (!strcmp(arg, "--patch-with-stat")) {
- enable_patch_output(&options->output_format);
- options->output_format |= DIFF_FORMAT_DIFFSTAT;
- } else if (!strcmp(arg, "--name-only"))
+ if (!strcmp(arg, "--name-only"))
options->output_format |= DIFF_FORMAT_NAME;
else if (!strcmp(arg, "--name-status"))
options->output_format |= DIFF_FORMAT_NAME_STATUS;
--
2.21.0.rc1.337.gdf7f8d0522
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v4 07/21] diff-parseopt: convert --name-only
2019-02-21 11:16 ` [PATCH v4 00/21] nd/diff-parseopt-2 updates Nguyễn Thái Ngọc Duy
` (5 preceding siblings ...)
2019-02-21 11:16 ` [PATCH v4 06/21] diff-parseopt: convert --patch-with-stat Nguyễn Thái Ngọc Duy
@ 2019-02-21 11:16 ` Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 08/21] diff-parseopt: convert --name-status Nguyễn Thái Ngọc Duy
` (13 subsequent siblings)
20 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-21 11:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, rybak.a.v, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/diff.c b/diff.c
index b9811aefef..7ea308814f 100644
--- a/diff.c
+++ b/diff.c
@@ -4949,6 +4949,9 @@ static void prep_parse_options(struct diff_options *options)
OPT_BIT_F(0, "summary", &options->output_format,
N_("condensed summary such as creations, renames and mode changes"),
DIFF_FORMAT_SUMMARY, PARSE_OPT_NONEG),
+ OPT_BIT_F(0, "name-only", &options->output_format,
+ N_("show only names of changed files"),
+ DIFF_FORMAT_NAME, PARSE_OPT_NONEG),
OPT_END()
};
@@ -4977,9 +4980,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* Output format options */
- if (!strcmp(arg, "--name-only"))
- options->output_format |= DIFF_FORMAT_NAME;
- else if (!strcmp(arg, "--name-status"))
+ if (!strcmp(arg, "--name-status"))
options->output_format |= DIFF_FORMAT_NAME_STATUS;
else if (!strcmp(arg, "-s") || !strcmp(arg, "--no-patch"))
options->output_format |= DIFF_FORMAT_NO_OUTPUT;
--
2.21.0.rc1.337.gdf7f8d0522
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v4 08/21] diff-parseopt: convert --name-status
2019-02-21 11:16 ` [PATCH v4 00/21] nd/diff-parseopt-2 updates Nguyễn Thái Ngọc Duy
` (6 preceding siblings ...)
2019-02-21 11:16 ` [PATCH v4 07/21] diff-parseopt: convert --name-only Nguyễn Thái Ngọc Duy
@ 2019-02-21 11:16 ` Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 09/21] diff-parseopt: convert -s|--no-patch Nguyễn Thái Ngọc Duy
` (12 subsequent siblings)
20 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-21 11:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, rybak.a.v, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/diff.c b/diff.c
index 7ea308814f..99047fb5fe 100644
--- a/diff.c
+++ b/diff.c
@@ -4952,6 +4952,9 @@ static void prep_parse_options(struct diff_options *options)
OPT_BIT_F(0, "name-only", &options->output_format,
N_("show only names of changed files"),
DIFF_FORMAT_NAME, PARSE_OPT_NONEG),
+ OPT_BIT_F(0, "name-status", &options->output_format,
+ N_("show only names and status of changed files"),
+ DIFF_FORMAT_NAME_STATUS, PARSE_OPT_NONEG),
OPT_END()
};
@@ -4980,9 +4983,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* Output format options */
- if (!strcmp(arg, "--name-status"))
- options->output_format |= DIFF_FORMAT_NAME_STATUS;
- else if (!strcmp(arg, "-s") || !strcmp(arg, "--no-patch"))
+ if (!strcmp(arg, "-s") || !strcmp(arg, "--no-patch"))
options->output_format |= DIFF_FORMAT_NO_OUTPUT;
else if (starts_with(arg, "--stat"))
/* --stat, --stat-width, --stat-name-width, or --stat-count */
--
2.21.0.rc1.337.gdf7f8d0522
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v4 09/21] diff-parseopt: convert -s|--no-patch
2019-02-21 11:16 ` [PATCH v4 00/21] nd/diff-parseopt-2 updates Nguyễn Thái Ngọc Duy
` (7 preceding siblings ...)
2019-02-21 11:16 ` [PATCH v4 08/21] diff-parseopt: convert --name-status Nguyễn Thái Ngọc Duy
@ 2019-02-21 11:16 ` Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 10/21] diff-parseopt: convert --stat* Nguyễn Thái Ngọc Duy
` (11 subsequent siblings)
20 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-21 11:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, rybak.a.v, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/diff.c b/diff.c
index 99047fb5fe..9c8f5336bc 100644
--- a/diff.c
+++ b/diff.c
@@ -4906,6 +4906,9 @@ static void prep_parse_options(struct diff_options *options)
OPT_BITOP('p', "patch", &options->output_format,
N_("generate patch"),
DIFF_FORMAT_PATCH, DIFF_FORMAT_NO_OUTPUT),
+ OPT_BIT_F('s', "no-patch", &options->output_format,
+ N_("suppress diff output"),
+ DIFF_FORMAT_NO_OUTPUT, PARSE_OPT_NONEG),
OPT_BITOP('u', NULL, &options->output_format,
N_("generate patch"),
DIFF_FORMAT_PATCH, DIFF_FORMAT_NO_OUTPUT),
@@ -4983,9 +4986,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* Output format options */
- if (!strcmp(arg, "-s") || !strcmp(arg, "--no-patch"))
- options->output_format |= DIFF_FORMAT_NO_OUTPUT;
- else if (starts_with(arg, "--stat"))
+ if (starts_with(arg, "--stat"))
/* --stat, --stat-width, --stat-name-width, or --stat-count */
return stat_opt(options, av);
else if (!strcmp(arg, "--compact-summary")) {
--
2.21.0.rc1.337.gdf7f8d0522
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v4 10/21] diff-parseopt: convert --stat*
2019-02-21 11:16 ` [PATCH v4 00/21] nd/diff-parseopt-2 updates Nguyễn Thái Ngọc Duy
` (8 preceding siblings ...)
2019-02-21 11:16 ` [PATCH v4 09/21] diff-parseopt: convert -s|--no-patch Nguyễn Thái Ngọc Duy
@ 2019-02-21 11:16 ` Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 11/21] diff-parseopt: convert --[no-]compact-summary Nguyễn Thái Ngọc Duy
` (10 subsequent siblings)
20 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-21 11:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, rybak.a.v, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 118 +++++++++++++++++++++++++--------------------------------
1 file changed, 52 insertions(+), 66 deletions(-)
diff --git a/diff.c b/diff.c
index 9c8f5336bc..1feb13deb3 100644
--- a/diff.c
+++ b/diff.c
@@ -104,11 +104,6 @@ static const char *color_diff_slots[] = {
[DIFF_FILE_NEW_BOLD] = "newBold",
};
-static NORETURN void die_want_option(const char *option_name)
-{
- die(_("option '%s' requires a value"), option_name);
-}
-
define_list_config_array_extra(color_diff_slots, {"plain"});
static int parse_diff_color_slot(const char *var)
@@ -4661,77 +4656,56 @@ int parse_long_opt(const char *opt, const char **argv,
return 2;
}
-static int stat_opt(struct diff_options *options, const char **av)
+static int diff_opt_stat(const struct option *opt, const char *value, int unset)
{
- const char *arg = av[0];
- char *end;
+ struct diff_options *options = opt->value;
int width = options->stat_width;
int name_width = options->stat_name_width;
int graph_width = options->stat_graph_width;
int count = options->stat_count;
- int argcount = 1;
+ char *end;
- if (!skip_prefix(arg, "--stat", &arg))
- BUG("stat option does not begin with --stat: %s", arg);
- end = (char *)arg;
+ BUG_ON_OPT_NEG(unset);
- switch (*arg) {
- case '-':
- if (skip_prefix(arg, "-width", &arg)) {
- if (*arg == '=')
- width = strtoul(arg + 1, &end, 10);
- else if (!*arg && !av[1])
- die_want_option("--stat-width");
- else if (!*arg) {
- width = strtoul(av[1], &end, 10);
- argcount = 2;
- }
- } else if (skip_prefix(arg, "-name-width", &arg)) {
- if (*arg == '=')
- name_width = strtoul(arg + 1, &end, 10);
- else if (!*arg && !av[1])
- die_want_option("--stat-name-width");
- else if (!*arg) {
- name_width = strtoul(av[1], &end, 10);
- argcount = 2;
- }
- } else if (skip_prefix(arg, "-graph-width", &arg)) {
- if (*arg == '=')
- graph_width = strtoul(arg + 1, &end, 10);
- else if (!*arg && !av[1])
- die_want_option("--stat-graph-width");
- else if (!*arg) {
- graph_width = strtoul(av[1], &end, 10);
- argcount = 2;
- }
- } else if (skip_prefix(arg, "-count", &arg)) {
- if (*arg == '=')
- count = strtoul(arg + 1, &end, 10);
- else if (!*arg && !av[1])
- die_want_option("--stat-count");
- else if (!*arg) {
- count = strtoul(av[1], &end, 10);
- argcount = 2;
- }
+ if (!strcmp(opt->long_name, "stat")) {
+ if (value) {
+ width = strtoul(value, &end, 10);
+ if (*end == ',')
+ name_width = strtoul(end+1, &end, 10);
+ if (*end == ',')
+ count = strtoul(end+1, &end, 10);
+ if (*end)
+ return error(_("invalid --stat value: %s"), value);
}
- break;
- case '=':
- width = strtoul(arg+1, &end, 10);
- if (*end == ',')
- name_width = strtoul(end+1, &end, 10);
- if (*end == ',')
- count = strtoul(end+1, &end, 10);
- }
+ } else if (!strcmp(opt->long_name, "stat-width")) {
+ width = strtoul(value, &end, 10);
+ if (*end)
+ return error(_("%s expects a numerical value"),
+ opt->long_name);
+ } else if (!strcmp(opt->long_name, "stat-name-width")) {
+ name_width = strtoul(value, &end, 10);
+ if (*end)
+ return error(_("%s expects a numerical value"),
+ opt->long_name);
+ } else if (!strcmp(opt->long_name, "stat-graph-width")) {
+ graph_width = strtoul(value, &end, 10);
+ if (*end)
+ return error(_("%s expects a numerical value"),
+ opt->long_name);
+ } else if (!strcmp(opt->long_name, "stat-count")) {
+ count = strtoul(value, &end, 10);
+ if (*end)
+ return error(_("%s expects a numerical value"),
+ opt->long_name);
+ } else
+ BUG("%s should not get here", opt->long_name);
- /* Important! This checks all the error cases! */
- if (*end)
- return 0;
options->output_format |= DIFF_FORMAT_DIFFSTAT;
options->stat_name_width = name_width;
options->stat_graph_width = graph_width;
options->stat_width = width;
options->stat_count = count;
- return argcount;
+ return 0;
}
static int parse_dirstat_opt(struct diff_options *options, const char *params)
@@ -4958,6 +4932,21 @@ static void prep_parse_options(struct diff_options *options)
OPT_BIT_F(0, "name-status", &options->output_format,
N_("show only names and status of changed files"),
DIFF_FORMAT_NAME_STATUS, PARSE_OPT_NONEG),
+ OPT_CALLBACK_F(0, "stat", options, N_("<width>[,<name-width>[,<count>]]"),
+ N_("generate diffstat"),
+ PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_stat),
+ OPT_CALLBACK_F(0, "stat-width", options, N_("<width>"),
+ N_("generate diffstat with a given width"),
+ PARSE_OPT_NONEG, diff_opt_stat),
+ OPT_CALLBACK_F(0, "stat-name-width", options, N_("<width>"),
+ N_("generate diffstat with a given name width"),
+ PARSE_OPT_NONEG, diff_opt_stat),
+ OPT_CALLBACK_F(0, "stat-graph-width", options, N_("<width>"),
+ N_("generate diffstat with a given graph width"),
+ PARSE_OPT_NONEG, diff_opt_stat),
+ OPT_CALLBACK_F(0, "stat-count", options, N_("<count>"),
+ N_("generate diffstat with limited lines"),
+ PARSE_OPT_NONEG, diff_opt_stat),
OPT_END()
};
@@ -4986,10 +4975,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* Output format options */
- if (starts_with(arg, "--stat"))
- /* --stat, --stat-width, --stat-name-width, or --stat-count */
- return stat_opt(options, av);
- else if (!strcmp(arg, "--compact-summary")) {
+ if (!strcmp(arg, "--compact-summary")) {
options->flags.stat_with_summary = 1;
options->output_format |= DIFF_FORMAT_DIFFSTAT;
} else if (!strcmp(arg, "--no-compact-summary"))
--
2.21.0.rc1.337.gdf7f8d0522
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v4 11/21] diff-parseopt: convert --[no-]compact-summary
2019-02-21 11:16 ` [PATCH v4 00/21] nd/diff-parseopt-2 updates Nguyễn Thái Ngọc Duy
` (9 preceding siblings ...)
2019-02-21 11:16 ` [PATCH v4 10/21] diff-parseopt: convert --stat* Nguyễn Thái Ngọc Duy
@ 2019-02-21 11:16 ` Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 12/21] diff-parseopt: convert --output-* Nguyễn Thái Ngọc Duy
` (9 subsequent siblings)
20 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-21 11:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, rybak.a.v, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/diff.c b/diff.c
index 1feb13deb3..b24f6825a1 100644
--- a/diff.c
+++ b/diff.c
@@ -4841,6 +4841,21 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)
return 1;
}
+static int diff_opt_compact_summary(const struct option *opt,
+ const char *arg, int unset)
+{
+ struct diff_options *options = opt->value;
+
+ BUG_ON_OPT_ARG(arg);
+ if (unset) {
+ options->flags.stat_with_summary = 0;
+ } else {
+ options->flags.stat_with_summary = 1;
+ options->output_format |= DIFF_FORMAT_DIFFSTAT;
+ }
+ return 0;
+}
+
static int diff_opt_dirstat(const struct option *opt,
const char *arg, int unset)
{
@@ -4947,6 +4962,9 @@ static void prep_parse_options(struct diff_options *options)
OPT_CALLBACK_F(0, "stat-count", options, N_("<count>"),
N_("generate diffstat with limited lines"),
PARSE_OPT_NONEG, diff_opt_stat),
+ OPT_CALLBACK_F(0, "compact-summary", options, NULL,
+ N_("generate compact summary in diffstat"),
+ PARSE_OPT_NOARG, diff_opt_compact_summary),
OPT_END()
};
@@ -4975,12 +4993,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* Output format options */
- if (!strcmp(arg, "--compact-summary")) {
- options->flags.stat_with_summary = 1;
- options->output_format |= DIFF_FORMAT_DIFFSTAT;
- } else if (!strcmp(arg, "--no-compact-summary"))
- options->flags.stat_with_summary = 0;
- else if (skip_prefix(arg, "--output-indicator-new=", &arg))
+ if (skip_prefix(arg, "--output-indicator-new=", &arg))
options->output_indicators[OUTPUT_INDICATOR_NEW] = arg[0];
else if (skip_prefix(arg, "--output-indicator-old=", &arg))
options->output_indicators[OUTPUT_INDICATOR_OLD] = arg[0];
--
2.21.0.rc1.337.gdf7f8d0522
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v4 12/21] diff-parseopt: convert --output-*
2019-02-21 11:16 ` [PATCH v4 00/21] nd/diff-parseopt-2 updates Nguyễn Thái Ngọc Duy
` (10 preceding siblings ...)
2019-02-21 11:16 ` [PATCH v4 11/21] diff-parseopt: convert --[no-]compact-summary Nguyễn Thái Ngọc Duy
@ 2019-02-21 11:16 ` Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 13/21] diff-parseopt: convert -B|--break-rewrites Nguyễn Thái Ngọc Duy
` (8 subsequent siblings)
20 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-21 11:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, rybak.a.v, Nguyễn Thái Ngọc Duy
This also validates that the user specifies a single character in
--output-indicator-*, not a string.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
Documentation/diff-options.txt | 10 +++++
diff.c | 71 +++++++++++++++++++++++++---------
2 files changed, 63 insertions(+), 18 deletions(-)
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 7b81b852ca..56b731eae5 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -41,6 +41,16 @@ ifndef::git-format-patch[]
Implies `-p`.
endif::git-format-patch[]
+--output=<file>::
+ Output to a specific file instead of stdout.
+
+--output-indicator-new=<char>::
+--output-indicator-old=<char>::
+--output-indicator-context=<char>::
+ Specify the character used to indicate new, old or context
+ lines in the generated patch. Normally they are '+', '-' and
+ ' ' respectively.
+
ifndef::git-format-patch[]
--raw::
ifndef::git-log[]
diff --git a/diff.c b/diff.c
index b24f6825a1..8df396cb9a 100644
--- a/diff.c
+++ b/diff.c
@@ -4841,6 +4841,19 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)
return 1;
}
+static int diff_opt_char(const struct option *opt,
+ const char *arg, int unset)
+{
+ char *value = opt->value;
+
+ BUG_ON_OPT_NEG(unset);
+ if (arg[1])
+ return error(_("%s expects a character, got '%s'"),
+ opt->long_name, arg);
+ *value = arg[0];
+ return 0;
+}
+
static int diff_opt_compact_summary(const struct option *opt,
const char *arg, int unset)
{
@@ -4872,6 +4885,23 @@ static int diff_opt_dirstat(const struct option *opt,
return 0;
}
+static enum parse_opt_result diff_opt_output(struct parse_opt_ctx_t *ctx,
+ const struct option *opt,
+ const char *arg, int unset)
+{
+ struct diff_options *options = opt->value;
+ char *path;
+
+ BUG_ON_OPT_NEG(unset);
+ path = prefix_filename(ctx->prefix, arg);
+ options->file = xfopen(path, "w");
+ options->close_file = 1;
+ if (options->use_color != GIT_COLOR_ALWAYS)
+ options->use_color = GIT_COLOR_NEVER;
+ free(path);
+ return 0;
+}
+
static int diff_opt_unified(const struct option *opt,
const char *arg, int unset)
{
@@ -4965,6 +4995,27 @@ static void prep_parse_options(struct diff_options *options)
OPT_CALLBACK_F(0, "compact-summary", options, NULL,
N_("generate compact summary in diffstat"),
PARSE_OPT_NOARG, diff_opt_compact_summary),
+ OPT_CALLBACK_F(0, "output-indicator-new",
+ &options->output_indicators[OUTPUT_INDICATOR_NEW],
+ N_("<char>"),
+ N_("specify the character to indicate a new line instead of '+'"),
+ PARSE_OPT_NONEG, diff_opt_char),
+ OPT_CALLBACK_F(0, "output-indicator-old",
+ &options->output_indicators[OUTPUT_INDICATOR_OLD],
+ N_("<char>"),
+ N_("specify the character to indicate an old line instead of '-'"),
+ PARSE_OPT_NONEG, diff_opt_char),
+ OPT_CALLBACK_F(0, "output-indicator-context",
+ &options->output_indicators[OUTPUT_INDICATOR_CONTEXT],
+ N_("<char>"),
+ N_("specify the character to indicate a context instead of ' '"),
+ PARSE_OPT_NONEG, diff_opt_char),
+
+ OPT_GROUP(N_("Diff other options")),
+ { OPTION_CALLBACK, 0, "output", options, N_("<file>"),
+ N_("Output to a specific file"),
+ PARSE_OPT_NONEG, NULL, 0, diff_opt_output },
+
OPT_END()
};
@@ -4992,16 +5043,8 @@ int diff_opt_parse(struct diff_options *options,
if (ac)
return ac;
- /* Output format options */
- if (skip_prefix(arg, "--output-indicator-new=", &arg))
- options->output_indicators[OUTPUT_INDICATOR_NEW] = arg[0];
- else if (skip_prefix(arg, "--output-indicator-old=", &arg))
- options->output_indicators[OUTPUT_INDICATOR_OLD] = arg[0];
- else if (skip_prefix(arg, "--output-indicator-context=", &arg))
- options->output_indicators[OUTPUT_INDICATOR_CONTEXT] = arg[0];
-
/* renames options */
- else if (starts_with(arg, "-B") ||
+ if (starts_with(arg, "-B") ||
skip_to_optional_arg(arg, "--break-rewrites", NULL)) {
if ((options->break_opt = diff_scoreopt_parse(arg)) == -1)
return error("invalid argument to -B: %s", arg+2);
@@ -5242,15 +5285,7 @@ int diff_opt_parse(struct diff_options *options,
else if (opt_arg(arg, '\0', "inter-hunk-context",
&options->interhunkcontext))
;
- else if ((argcount = parse_long_opt("output", av, &optarg))) {
- char *path = prefix_filename(prefix, optarg);
- options->file = xfopen(path, "w");
- options->close_file = 1;
- if (options->use_color != GIT_COLOR_ALWAYS)
- options->use_color = GIT_COLOR_NEVER;
- free(path);
- return argcount;
- } else
+ else
return 0;
return 1;
}
--
2.21.0.rc1.337.gdf7f8d0522
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v4 13/21] diff-parseopt: convert -B|--break-rewrites
2019-02-21 11:16 ` [PATCH v4 00/21] nd/diff-parseopt-2 updates Nguyễn Thái Ngọc Duy
` (11 preceding siblings ...)
2019-02-21 11:16 ` [PATCH v4 12/21] diff-parseopt: convert --output-* Nguyễn Thái Ngọc Duy
@ 2019-02-21 11:16 ` Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 14/21] diff-parseopt: convert -M|--find-renames Nguyễn Thái Ngọc Duy
` (7 subsequent siblings)
20 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-21 11:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, rybak.a.v, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 62 ++++++++++++++++++++++++++++++++++------------------------
1 file changed, 36 insertions(+), 26 deletions(-)
diff --git a/diff.c b/diff.c
index 8df396cb9a..d2139082b7 100644
--- a/diff.c
+++ b/diff.c
@@ -4841,6 +4841,30 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)
return 1;
}
+static int diff_opt_break_rewrites(const struct option *opt,
+ const char *arg, int unset)
+{
+ int *break_opt = opt->value;
+ int opt1, opt2;
+
+ BUG_ON_OPT_NEG(unset);
+ if (!arg)
+ arg = "";
+ opt1 = parse_rename_score(&arg);
+ if (*arg == 0)
+ opt2 = 0;
+ else if (*arg != '/')
+ return error(_("%s expects <n>/<m> form"), opt->long_name);
+ else {
+ arg++;
+ opt2 = parse_rename_score(&arg);
+ }
+ if (*arg != 0)
+ return error(_("%s expects <n>/<m> form"), opt->long_name);
+ *break_opt = opt1 | (opt2 << 16);
+ return 0;
+}
+
static int diff_opt_char(const struct option *opt,
const char *arg, int unset)
{
@@ -5011,6 +5035,12 @@ static void prep_parse_options(struct diff_options *options)
N_("specify the character to indicate a context instead of ' '"),
PARSE_OPT_NONEG, diff_opt_char),
+ OPT_GROUP(N_("Diff rename options")),
+ OPT_CALLBACK_F('B', "break-rewrites", &options->break_opt, N_("<n>[/<m>]"),
+ N_("break complete rewrite changes into pairs of delete and create"),
+ PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
+ diff_opt_break_rewrites),
+
OPT_GROUP(N_("Diff other options")),
{ OPTION_CALLBACK, 0, "output", options, N_("<file>"),
N_("Output to a specific file"),
@@ -5044,12 +5074,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* renames options */
- if (starts_with(arg, "-B") ||
- skip_to_optional_arg(arg, "--break-rewrites", NULL)) {
- if ((options->break_opt = diff_scoreopt_parse(arg)) == -1)
- return error("invalid argument to -B: %s", arg+2);
- }
- else if (starts_with(arg, "-M") ||
+ if (starts_with(arg, "-M") ||
skip_to_optional_arg(arg, "--find-renames", NULL)) {
if ((options->rename_score = diff_scoreopt_parse(arg)) == -1)
return error("invalid argument to -M: %s", arg+2);
@@ -5328,17 +5353,14 @@ int parse_rename_score(const char **cp_p)
static int diff_scoreopt_parse(const char *opt)
{
- int opt1, opt2, cmd;
+ int opt1, cmd;
if (*opt++ != '-')
return -1;
cmd = *opt++;
if (cmd == '-') {
/* convert the long-form arguments into short-form versions */
- if (skip_prefix(opt, "break-rewrites", &opt)) {
- if (*opt == 0 || *opt++ == '=')
- cmd = 'B';
- } else if (skip_prefix(opt, "find-copies", &opt)) {
+ if (skip_prefix(opt, "find-copies", &opt)) {
if (*opt == 0 || *opt++ == '=')
cmd = 'C';
} else if (skip_prefix(opt, "find-renames", &opt)) {
@@ -5346,25 +5368,13 @@ static int diff_scoreopt_parse(const char *opt)
cmd = 'M';
}
}
- if (cmd != 'M' && cmd != 'C' && cmd != 'B')
- return -1; /* that is not a -M, -C, or -B option */
+ if (cmd != 'M' && cmd != 'C')
+ return -1; /* that is not a -M, or -C option */
opt1 = parse_rename_score(&opt);
- if (cmd != 'B')
- opt2 = 0;
- else {
- if (*opt == 0)
- opt2 = 0;
- else if (*opt != '/')
- return -1; /* we expect -B80/99 or -B80 */
- else {
- opt++;
- opt2 = parse_rename_score(&opt);
- }
- }
if (*opt != 0)
return -1;
- return opt1 | (opt2 << 16);
+ return opt1;
}
struct diff_queue_struct diff_queued_diff;
--
2.21.0.rc1.337.gdf7f8d0522
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v4 14/21] diff-parseopt: convert -M|--find-renames
2019-02-21 11:16 ` [PATCH v4 00/21] nd/diff-parseopt-2 updates Nguyễn Thái Ngọc Duy
` (12 preceding siblings ...)
2019-02-21 11:16 ` [PATCH v4 13/21] diff-parseopt: convert -B|--break-rewrites Nguyễn Thái Ngọc Duy
@ 2019-02-21 11:16 ` Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 15/21] diff-parseopt: convert -D|--irreversible-delete Nguyễn Thái Ngọc Duy
` (6 subsequent siblings)
20 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-21 11:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, rybak.a.v, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 35 +++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/diff.c b/diff.c
index d2139082b7..2c904e0526 100644
--- a/diff.c
+++ b/diff.c
@@ -4909,6 +4909,22 @@ static int diff_opt_dirstat(const struct option *opt,
return 0;
}
+static int diff_opt_find_renames(const struct option *opt,
+ const char *arg, int unset)
+{
+ struct diff_options *options = opt->value;
+
+ BUG_ON_OPT_NEG(unset);
+ if (!arg)
+ arg = "";
+ options->rename_score = parse_rename_score(&arg);
+ if (*arg != 0)
+ return error(_("invalid argument to %s"), opt->long_name);
+
+ options->detect_rename = DIFF_DETECT_RENAME;
+ return 0;
+}
+
static enum parse_opt_result diff_opt_output(struct parse_opt_ctx_t *ctx,
const struct option *opt,
const char *arg, int unset)
@@ -5040,6 +5056,10 @@ static void prep_parse_options(struct diff_options *options)
N_("break complete rewrite changes into pairs of delete and create"),
PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
diff_opt_break_rewrites),
+ OPT_CALLBACK_F('M', "find-renames", options, N_("<n>"),
+ N_("detect renames"),
+ PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
+ diff_opt_find_renames),
OPT_GROUP(N_("Diff other options")),
{ OPTION_CALLBACK, 0, "output", options, N_("<file>"),
@@ -5074,13 +5094,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* renames options */
- if (starts_with(arg, "-M") ||
- skip_to_optional_arg(arg, "--find-renames", NULL)) {
- if ((options->rename_score = diff_scoreopt_parse(arg)) == -1)
- return error("invalid argument to -M: %s", arg+2);
- options->detect_rename = DIFF_DETECT_RENAME;
- }
- else if (!strcmp(arg, "-D") || !strcmp(arg, "--irreversible-delete")) {
+ if (!strcmp(arg, "-D") || !strcmp(arg, "--irreversible-delete")) {
options->irreversible_delete = 1;
}
else if (starts_with(arg, "-C") ||
@@ -5363,13 +5377,10 @@ static int diff_scoreopt_parse(const char *opt)
if (skip_prefix(opt, "find-copies", &opt)) {
if (*opt == 0 || *opt++ == '=')
cmd = 'C';
- } else if (skip_prefix(opt, "find-renames", &opt)) {
- if (*opt == 0 || *opt++ == '=')
- cmd = 'M';
}
}
- if (cmd != 'M' && cmd != 'C')
- return -1; /* that is not a -M, or -C option */
+ if (cmd != 'C')
+ return -1; /* that is not a -M option */
opt1 = parse_rename_score(&opt);
if (*opt != 0)
--
2.21.0.rc1.337.gdf7f8d0522
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v4 15/21] diff-parseopt: convert -D|--irreversible-delete
2019-02-21 11:16 ` [PATCH v4 00/21] nd/diff-parseopt-2 updates Nguyễn Thái Ngọc Duy
` (13 preceding siblings ...)
2019-02-21 11:16 ` [PATCH v4 14/21] diff-parseopt: convert -M|--find-renames Nguyễn Thái Ngọc Duy
@ 2019-02-21 11:16 ` Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 16/21] diff-parseopt: convert -C|--find-copies Nguyễn Thái Ngọc Duy
` (5 subsequent siblings)
20 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-21 11:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, rybak.a.v, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/diff.c b/diff.c
index 2c904e0526..e51f6b3005 100644
--- a/diff.c
+++ b/diff.c
@@ -5060,6 +5060,9 @@ static void prep_parse_options(struct diff_options *options)
N_("detect renames"),
PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
diff_opt_find_renames),
+ OPT_SET_INT_F('D', "irreversible-delete", &options->irreversible_delete,
+ N_("omit the preimage for deletes"),
+ 1, PARSE_OPT_NONEG),
OPT_GROUP(N_("Diff other options")),
{ OPTION_CALLBACK, 0, "output", options, N_("<file>"),
@@ -5094,10 +5097,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* renames options */
- if (!strcmp(arg, "-D") || !strcmp(arg, "--irreversible-delete")) {
- options->irreversible_delete = 1;
- }
- else if (starts_with(arg, "-C") ||
+ if (starts_with(arg, "-C") ||
skip_to_optional_arg(arg, "--find-copies", NULL)) {
if (options->detect_rename == DIFF_DETECT_COPY)
options->flags.find_copies_harder = 1;
--
2.21.0.rc1.337.gdf7f8d0522
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v4 16/21] diff-parseopt: convert -C|--find-copies
2019-02-21 11:16 ` [PATCH v4 00/21] nd/diff-parseopt-2 updates Nguyễn Thái Ngọc Duy
` (14 preceding siblings ...)
2019-02-21 11:16 ` [PATCH v4 15/21] diff-parseopt: convert -D|--irreversible-delete Nguyễn Thái Ngọc Duy
@ 2019-02-21 11:16 ` Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 17/21] diff-parseopt: convert --find-copies-harder Nguyễn Thái Ngọc Duy
` (4 subsequent siblings)
20 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-21 11:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, rybak.a.v, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 59 +++++++++++++++++++++++++---------------------------------
1 file changed, 25 insertions(+), 34 deletions(-)
diff --git a/diff.c b/diff.c
index e51f6b3005..35bac115cc 100644
--- a/diff.c
+++ b/diff.c
@@ -4617,8 +4617,6 @@ static int opt_arg(const char *arg, int arg_short, const char *arg_long, int *va
return 1;
}
-static int diff_scoreopt_parse(const char *opt);
-
static inline int short_opt(char opt, const char **argv,
const char **optarg)
{
@@ -4909,6 +4907,26 @@ static int diff_opt_dirstat(const struct option *opt,
return 0;
}
+static int diff_opt_find_copies(const struct option *opt,
+ const char *arg, int unset)
+{
+ struct diff_options *options = opt->value;
+
+ BUG_ON_OPT_NEG(unset);
+ if (!arg)
+ arg = "";
+ options->rename_score = parse_rename_score(&arg);
+ if (*arg != 0)
+ return error(_("invalid argument to %s"), opt->long_name);
+
+ if (options->detect_rename == DIFF_DETECT_COPY)
+ options->flags.find_copies_harder = 1;
+ else
+ options->detect_rename = DIFF_DETECT_COPY;
+
+ return 0;
+}
+
static int diff_opt_find_renames(const struct option *opt,
const char *arg, int unset)
{
@@ -5063,6 +5081,10 @@ static void prep_parse_options(struct diff_options *options)
OPT_SET_INT_F('D', "irreversible-delete", &options->irreversible_delete,
N_("omit the preimage for deletes"),
1, PARSE_OPT_NONEG),
+ OPT_CALLBACK_F('C', "find-copies", options, N_("<n>"),
+ N_("detect copies"),
+ PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
+ diff_opt_find_copies),
OPT_GROUP(N_("Diff other options")),
{ OPTION_CALLBACK, 0, "output", options, N_("<file>"),
@@ -5097,15 +5119,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* renames options */
- if (starts_with(arg, "-C") ||
- skip_to_optional_arg(arg, "--find-copies", NULL)) {
- if (options->detect_rename == DIFF_DETECT_COPY)
- options->flags.find_copies_harder = 1;
- if ((options->rename_score = diff_scoreopt_parse(arg)) == -1)
- return error("invalid argument to -C: %s", arg+2);
- options->detect_rename = DIFF_DETECT_COPY;
- }
- else if (!strcmp(arg, "--no-renames"))
+ if (!strcmp(arg, "--no-renames"))
options->detect_rename = 0;
else if (!strcmp(arg, "--rename-empty"))
options->flags.rename_empty = 1;
@@ -5365,29 +5379,6 @@ int parse_rename_score(const char **cp_p)
return (int)((num >= scale) ? MAX_SCORE : (MAX_SCORE * num / scale));
}
-static int diff_scoreopt_parse(const char *opt)
-{
- int opt1, cmd;
-
- if (*opt++ != '-')
- return -1;
- cmd = *opt++;
- if (cmd == '-') {
- /* convert the long-form arguments into short-form versions */
- if (skip_prefix(opt, "find-copies", &opt)) {
- if (*opt == 0 || *opt++ == '=')
- cmd = 'C';
- }
- }
- if (cmd != 'C')
- return -1; /* that is not a -M option */
-
- opt1 = parse_rename_score(&opt);
- if (*opt != 0)
- return -1;
- return opt1;
-}
-
struct diff_queue_struct diff_queued_diff;
void diff_q(struct diff_queue_struct *queue, struct diff_filepair *dp)
--
2.21.0.rc1.337.gdf7f8d0522
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v4 17/21] diff-parseopt: convert --find-copies-harder
2019-02-21 11:16 ` [PATCH v4 00/21] nd/diff-parseopt-2 updates Nguyễn Thái Ngọc Duy
` (15 preceding siblings ...)
2019-02-21 11:16 ` [PATCH v4 16/21] diff-parseopt: convert -C|--find-copies Nguyễn Thái Ngọc Duy
@ 2019-02-21 11:16 ` Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 18/21] diff-parseopt: convert --no-renames|--[no--rename-empty Nguyễn Thái Ngọc Duy
` (3 subsequent siblings)
20 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-21 11:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, rybak.a.v, Nguyễn Thái Ngọc Duy
--no-find-copies-harder is also added on purpose (because I don't see
why we should not have the --no- version for this)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/diff.c b/diff.c
index 35bac115cc..abb1566f95 100644
--- a/diff.c
+++ b/diff.c
@@ -5085,6 +5085,8 @@ static void prep_parse_options(struct diff_options *options)
N_("detect copies"),
PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
diff_opt_find_copies),
+ OPT_BOOL(0, "find-copies-harder", &options->flags.find_copies_harder,
+ N_("use unmodified files as source to find copies")),
OPT_GROUP(N_("Diff other options")),
{ OPTION_CALLBACK, 0, "output", options, N_("<file>"),
@@ -5191,8 +5193,6 @@ int diff_opt_parse(struct diff_options *options,
options->flags.text = 1;
else if (!strcmp(arg, "-R"))
options->flags.reverse_diff = 1;
- else if (!strcmp(arg, "--find-copies-harder"))
- options->flags.find_copies_harder = 1;
else if (!strcmp(arg, "--follow"))
options->flags.follow_renames = 1;
else if (!strcmp(arg, "--no-follow")) {
--
2.21.0.rc1.337.gdf7f8d0522
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v4 18/21] diff-parseopt: convert --no-renames|--[no--rename-empty
2019-02-21 11:16 ` [PATCH v4 00/21] nd/diff-parseopt-2 updates Nguyễn Thái Ngọc Duy
` (16 preceding siblings ...)
2019-02-21 11:16 ` [PATCH v4 17/21] diff-parseopt: convert --find-copies-harder Nguyễn Thái Ngọc Duy
@ 2019-02-21 11:16 ` Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 19/21] diff-parseopt: convert --relative Nguyễn Thái Ngọc Duy
` (2 subsequent siblings)
20 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-21 11:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, rybak.a.v, Nguyễn Thái Ngọc Duy
For --rename-empty, see 90d43b0768 (teach diffcore-rename to
optionally ignore empty content - 2012-03-22) for more information.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
Documentation/diff-options.txt | 3 +++
diff.c | 13 ++++++-------
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 56b731eae5..915f2fec8b 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -392,6 +392,9 @@ endif::git-format-patch[]
Turn off rename detection, even when the configuration
file gives the default to do so.
+--[no-]rename-empty::
+ Whether to use empty blobs as rename source.
+
ifndef::git-format-patch[]
--check::
Warn if changes introduce conflict markers or whitespace errors.
diff --git a/diff.c b/diff.c
index abb1566f95..d423a06b41 100644
--- a/diff.c
+++ b/diff.c
@@ -5087,6 +5087,11 @@ static void prep_parse_options(struct diff_options *options)
diff_opt_find_copies),
OPT_BOOL(0, "find-copies-harder", &options->flags.find_copies_harder,
N_("use unmodified files as source to find copies")),
+ OPT_SET_INT_F(0, "no-renames", &options->detect_rename,
+ N_("disable rename detection"),
+ 0, PARSE_OPT_NONEG),
+ OPT_BOOL(0, "rename-empty", &options->flags.rename_empty,
+ N_("use empty blobs as rename source")),
OPT_GROUP(N_("Diff other options")),
{ OPTION_CALLBACK, 0, "output", options, N_("<file>"),
@@ -5121,13 +5126,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* renames options */
- if (!strcmp(arg, "--no-renames"))
- options->detect_rename = 0;
- else if (!strcmp(arg, "--rename-empty"))
- options->flags.rename_empty = 1;
- else if (!strcmp(arg, "--no-rename-empty"))
- options->flags.rename_empty = 0;
- else if (skip_to_optional_arg_default(arg, "--relative", &arg, NULL)) {
+ if (skip_to_optional_arg_default(arg, "--relative", &arg, NULL)) {
options->flags.relative_name = 1;
if (arg)
options->prefix = arg;
--
2.21.0.rc1.337.gdf7f8d0522
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v4 19/21] diff-parseopt: convert --relative
2019-02-21 11:16 ` [PATCH v4 00/21] nd/diff-parseopt-2 updates Nguyễn Thái Ngọc Duy
` (17 preceding siblings ...)
2019-02-21 11:16 ` [PATCH v4 18/21] diff-parseopt: convert --no-renames|--[no--rename-empty Nguyễn Thái Ngọc Duy
@ 2019-02-21 11:16 ` Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 20/21] diff-parseopt: convert --[no-]minimal Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 21/21] diff-parseopt: convert --ignore-some-changes Nguyễn Thái Ngọc Duy
20 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-21 11:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, rybak.a.v, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/diff.c b/diff.c
index d423a06b41..b9c267a199 100644
--- a/diff.c
+++ b/diff.c
@@ -4960,6 +4960,18 @@ static enum parse_opt_result diff_opt_output(struct parse_opt_ctx_t *ctx,
return 0;
}
+static int diff_opt_relative(const struct option *opt,
+ const char *arg, int unset)
+{
+ struct diff_options *options = opt->value;
+
+ BUG_ON_OPT_NEG(unset);
+ options->flags.relative_name = 1;
+ if (arg)
+ options->prefix = arg;
+ return 0;
+}
+
static int diff_opt_unified(const struct option *opt,
const char *arg, int unset)
{
@@ -5094,6 +5106,10 @@ static void prep_parse_options(struct diff_options *options)
N_("use empty blobs as rename source")),
OPT_GROUP(N_("Diff other options")),
+ OPT_CALLBACK_F(0, "relative", options, N_("<prefix>"),
+ N_("when run from subdir, exclude changes outside and show relative paths"),
+ PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
+ diff_opt_relative),
{ OPTION_CALLBACK, 0, "output", options, N_("<file>"),
N_("Output to a specific file"),
PARSE_OPT_NONEG, NULL, 0, diff_opt_output },
@@ -5125,15 +5141,8 @@ int diff_opt_parse(struct diff_options *options,
if (ac)
return ac;
- /* renames options */
- if (skip_to_optional_arg_default(arg, "--relative", &arg, NULL)) {
- options->flags.relative_name = 1;
- if (arg)
- options->prefix = arg;
- }
-
/* xdiff options */
- else if (!strcmp(arg, "--minimal"))
+ if (!strcmp(arg, "--minimal"))
DIFF_XDL_SET(options, NEED_MINIMAL);
else if (!strcmp(arg, "--no-minimal"))
DIFF_XDL_CLR(options, NEED_MINIMAL);
--
2.21.0.rc1.337.gdf7f8d0522
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v4 20/21] diff-parseopt: convert --[no-]minimal
2019-02-21 11:16 ` [PATCH v4 00/21] nd/diff-parseopt-2 updates Nguyễn Thái Ngọc Duy
` (18 preceding siblings ...)
2019-02-21 11:16 ` [PATCH v4 19/21] diff-parseopt: convert --relative Nguyễn Thái Ngọc Duy
@ 2019-02-21 11:16 ` Nguyễn Thái Ngọc Duy
2019-02-21 11:16 ` [PATCH v4 21/21] diff-parseopt: convert --ignore-some-changes Nguyễn Thái Ngọc Duy
20 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-21 11:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, rybak.a.v, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/diff.c b/diff.c
index b9c267a199..33492e754f 100644
--- a/diff.c
+++ b/diff.c
@@ -5105,6 +5105,11 @@ static void prep_parse_options(struct diff_options *options)
OPT_BOOL(0, "rename-empty", &options->flags.rename_empty,
N_("use empty blobs as rename source")),
+ OPT_GROUP(N_("Diff algorithm options")),
+ OPT_BIT(0, "minimal", &options->xdl_opts,
+ N_("produce the smallest possible diff"),
+ XDF_NEED_MINIMAL),
+
OPT_GROUP(N_("Diff other options")),
OPT_CALLBACK_F(0, "relative", options, N_("<prefix>"),
N_("when run from subdir, exclude changes outside and show relative paths"),
@@ -5142,11 +5147,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* xdiff options */
- if (!strcmp(arg, "--minimal"))
- DIFF_XDL_SET(options, NEED_MINIMAL);
- else if (!strcmp(arg, "--no-minimal"))
- DIFF_XDL_CLR(options, NEED_MINIMAL);
- else if (!strcmp(arg, "-w") || !strcmp(arg, "--ignore-all-space"))
+ if (!strcmp(arg, "-w") || !strcmp(arg, "--ignore-all-space"))
DIFF_XDL_SET(options, IGNORE_WHITESPACE);
else if (!strcmp(arg, "-b") || !strcmp(arg, "--ignore-space-change"))
DIFF_XDL_SET(options, IGNORE_WHITESPACE_CHANGE);
--
2.21.0.rc1.337.gdf7f8d0522
^ permalink raw reply related [flat|nested] 80+ messages in thread
* [PATCH v4 21/21] diff-parseopt: convert --ignore-some-changes
2019-02-21 11:16 ` [PATCH v4 00/21] nd/diff-parseopt-2 updates Nguyễn Thái Ngọc Duy
` (19 preceding siblings ...)
2019-02-21 11:16 ` [PATCH v4 20/21] diff-parseopt: convert --[no-]minimal Nguyễn Thái Ngọc Duy
@ 2019-02-21 11:16 ` Nguyễn Thái Ngọc Duy
20 siblings, 0 replies; 80+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2019-02-21 11:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, rybak.a.v, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/diff.c b/diff.c
index 33492e754f..a63ee4a44d 100644
--- a/diff.c
+++ b/diff.c
@@ -5109,6 +5109,21 @@ static void prep_parse_options(struct diff_options *options)
OPT_BIT(0, "minimal", &options->xdl_opts,
N_("produce the smallest possible diff"),
XDF_NEED_MINIMAL),
+ OPT_BIT_F('w', "ignore-all-space", &options->xdl_opts,
+ N_("ignore whitespace when comparing lines"),
+ XDF_IGNORE_WHITESPACE, PARSE_OPT_NONEG),
+ OPT_BIT_F('b', "ignore-space-change", &options->xdl_opts,
+ N_("ignore changes in amount of whitespace"),
+ XDF_IGNORE_WHITESPACE_CHANGE, PARSE_OPT_NONEG),
+ OPT_BIT_F(0, "ignore-space-at-eol", &options->xdl_opts,
+ N_("ignore changes in whitespace at EOL"),
+ XDF_IGNORE_WHITESPACE_AT_EOL, PARSE_OPT_NONEG),
+ OPT_BIT_F(0, "ignore-cr-at-eol", &options->xdl_opts,
+ N_("ignore carrier-return at the end of line"),
+ XDF_IGNORE_CR_AT_EOL, PARSE_OPT_NONEG),
+ OPT_BIT_F(0, "ignore-blank-lines", &options->xdl_opts,
+ N_("ignore changes whose lines are all blank"),
+ XDF_IGNORE_BLANK_LINES, PARSE_OPT_NONEG),
OPT_GROUP(N_("Diff other options")),
OPT_CALLBACK_F(0, "relative", options, N_("<prefix>"),
@@ -5147,17 +5162,7 @@ int diff_opt_parse(struct diff_options *options,
return ac;
/* xdiff options */
- if (!strcmp(arg, "-w") || !strcmp(arg, "--ignore-all-space"))
- DIFF_XDL_SET(options, IGNORE_WHITESPACE);
- else if (!strcmp(arg, "-b") || !strcmp(arg, "--ignore-space-change"))
- DIFF_XDL_SET(options, IGNORE_WHITESPACE_CHANGE);
- else if (!strcmp(arg, "--ignore-space-at-eol"))
- DIFF_XDL_SET(options, IGNORE_WHITESPACE_AT_EOL);
- else if (!strcmp(arg, "--ignore-cr-at-eol"))
- DIFF_XDL_SET(options, IGNORE_CR_AT_EOL);
- else if (!strcmp(arg, "--ignore-blank-lines"))
- DIFF_XDL_SET(options, IGNORE_BLANK_LINES);
- else if (!strcmp(arg, "--indent-heuristic"))
+ if (!strcmp(arg, "--indent-heuristic"))
DIFF_XDL_SET(options, INDENT_HEURISTIC);
else if (!strcmp(arg, "--no-indent-heuristic"))
DIFF_XDL_CLR(options, INDENT_HEURISTIC);
--
2.21.0.rc1.337.gdf7f8d0522
^ permalink raw reply related [flat|nested] 80+ messages in thread