diff mbox series

[1/2] combine-diff: abort if --ignore-matching-lines is given

Message ID 49bcadd1-7dc2-d5ee-36a5-59456450aeca@web.de (mailing list archive)
State New, archived
Headers show
Series [1/2] combine-diff: abort if --ignore-matching-lines is given | expand

Commit Message

René Scharfe June 18, 2022, 11:12 a.m. UTC
The code for combined diffs doesn't currently support ignoring changes
that match a regex.  Abort and report that fact instead of running into
a segfault.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 combine-diff.c | 4 ++++
 1 file changed, 4 insertions(+)

--
2.36.1

Comments

Junio C Hamano June 21, 2022, 3:35 p.m. UTC | #1
René Scharfe <l.s.r@web.de> writes:

> The code for combined diffs doesn't currently support ignoring changes
> that match a regex.  Abort and report that fact instead of running into
> a segfault.
>
> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
>  combine-diff.c | 4 ++++
>  1 file changed, 4 insertions(+)

Makes sense.

> diff --git a/combine-diff.c b/combine-diff.c
> index b724f02123..11df1d7f39 100644
> --- a/combine-diff.c
> +++ b/combine-diff.c
> @@ -1498,6 +1498,10 @@ void diff_tree_combined(const struct object_id *oid,
>  	int i, num_paths, needsep, show_log_first, num_parent = parents->nr;
>  	int need_generic_pathscan;
>
> +	if (opt->ignore_regex_nr)
> +		die("combined diff and '%s' cannot be used together",
> +		    "--ignore-matching-lines");

"X cannot be used together _with_ Y" perhaps?

>  	/* nothing to do, if no parents */
>  	if (!num_parent)
>  		return;
> --
> 2.36.1
René Scharfe June 21, 2022, 3:58 p.m. UTC | #2
Am 21.06.22 um 17:35 schrieb Junio C Hamano:
> René Scharfe <l.s.r@web.de> writes:
>
>> The code for combined diffs doesn't currently support ignoring changes
>> that match a regex.  Abort and report that fact instead of running into
>> a segfault.
>>
>> Signed-off-by: René Scharfe <l.s.r@web.de>
>> ---
>>  combine-diff.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>
> Makes sense.
>
>> diff --git a/combine-diff.c b/combine-diff.c
>> index b724f02123..11df1d7f39 100644
>> --- a/combine-diff.c
>> +++ b/combine-diff.c
>> @@ -1498,6 +1498,10 @@ void diff_tree_combined(const struct object_id *oid,
>>  	int i, num_paths, needsep, show_log_first, num_parent = parents->nr;
>>  	int need_generic_pathscan;
>>
>> +	if (opt->ignore_regex_nr)
>> +		die("combined diff and '%s' cannot be used together",
>> +		    "--ignore-matching-lines");
>
> "X cannot be used together _with_ Y" perhaps?

Not sure, but that type of message was recently unified (most common
case: "options '%s' and '%s' cannot be used together") and "with" is
only used in an untranslated BUG:

$ git grep -e "cannot be used together" --and --not -e options '*.c'
builtin/add.c:                  die(_("'%s' and pathspec arguments cannot be used together"), "--pathspec-from-file");
builtin/am.c:                                      "cannot be used together"),
builtin/checkout.c:                     die(_("'%s' and pathspec arguments cannot be used together"), "--pathspec-from-file");
builtin/clean.c:                die(_("-x and -X cannot be used together"));
builtin/commit.c:                       die(_("'%s' and pathspec arguments cannot be used together"), "--pathspec-from-file");
builtin/commit.c:               die(_("reword option of '%s' and path '%s' cannot be used together"), "--fixup", *argv);
builtin/commit.c:               die(_("reword option of '%s' and '%s' cannot be used together"),
builtin/describe.c:             die(_("option '%s' and commit-ishes cannot be used together"), "--dirty");
builtin/describe.c:             die(_("option '%s' and commit-ishes cannot be used together"), "--broken");
builtin/rebase.c:                                         "cannot be used together"));
builtin/reset.c:                        die(_("'%s' and pathspec arguments cannot be used together"), "--pathspec-from-file");
builtin/rev-list.c:             die(_("marked counting and '%s' cannot be used together"), "--objects");
builtin/rm.c:                   die(_("'%s' and pathspec arguments cannot be used together"), "--pathspec-from-file");
builtin/stash.c:                        die(_("'%s' and pathspec arguments cannot be used together"), "--pathspec-from-file");
revision.c:                     BUG("--single-worktree cannot be used together with submodule");
upload-pack.c:          die("git upload-pack: deepen and deepen-since (or deepen-not) cannot be used together");

So there doesn't seem to be a fully consistent style amongst these
special cases.  How about this?

		die(_("option '%s' and combined diffs cannot be used together"),

>
>>  	/* nothing to do, if no parents */
>>  	if (!num_parent)
>>  		return;
>> --
>> 2.36.1
Junio C Hamano June 21, 2022, 4:55 p.m. UTC | #3
René Scharfe <l.s.r@web.de> writes:

>>> +	if (opt->ignore_regex_nr)
>>> +		die("combined diff and '%s' cannot be used together",
>>> +		    "--ignore-matching-lines");
>>
>> "X cannot be used together _with_ Y" perhaps?
>
> Not sure, but that type of message was recently unified (most common
> case: "options '%s' and '%s' cannot be used together") and "with" is
> only used in an untranslated BUG:

Ah, sorry, I completely misread the original as "combined diff
cannot be used together with ignore-matching-lines".

Sorry for the noise.
diff mbox series

Patch

diff --git a/combine-diff.c b/combine-diff.c
index b724f02123..11df1d7f39 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -1498,6 +1498,10 @@  void diff_tree_combined(const struct object_id *oid,
 	int i, num_paths, needsep, show_log_first, num_parent = parents->nr;
 	int need_generic_pathscan;

+	if (opt->ignore_regex_nr)
+		die("combined diff and '%s' cannot be used together",
+		    "--ignore-matching-lines");
+
 	/* nothing to do, if no parents */
 	if (!num_parent)
 		return;