# Warning about conflict markers - undocumented 'diff --check' feature & suggestion

6 messages from 2016-03-28 to 2016-03-29. Participants: Ori Avtalion, Junio C Hamano.
Thread: https://gitlist.dev/t/41851

## Ori Avtalion, 2016-03-28 22:44

Subject: Warning about conflict markers - undocumented 'diff --check' feature & suggestion
Message-ID: <CALgdb5JuoYpHAPxTY2cHdbkcPUjKtsWQ_DY5rBrw-YKCwj2yvw@mail.gmail.com>
URL: https://gitlist.dev/e/CALgdb5JuoYpHAPxTY2cHdbkcPUjKtsWQ_DY5rBrw-YKCwj2yvw%40mail.gmail.com

```
A bug report and a suggestion:

`git diff --check` has been warning about conflict markers since 2008:
https://marc.info/?l=git&m=122398500726634&w=2

This is an undocumented feature. The current documentation for the
flag only mentions "whitespace errors".

This check will also be useful in `git add`, to prevent accidental
staging of conflict markers.
Perhaps it could be included, if not by default, then at least with a
configuration setting.

Thoughts? Is this perhaps an existing feature that I'm missing? :)

-Ori

```

## Junio C Hamano, 2016-03-28 23:01

Subject: Re: Warning about conflict markers - undocumented 'diff --check' feature & suggestion
Message-ID: <xmqqd1qe1a2i.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqd1qe1a2i.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <CALgdb5JuoYpHAPxTY2cHdbkcPUjKtsWQ_DY5rBrw-YKCwj2yvw@mail.gmail.com>

```
Ori Avtalion <ori@avtalion.name> writes:

> A bug report and a suggestion:
>
> `git diff --check` has been warning about conflict markers since 2008:
> https://marc.info/?l=git&m=122398500726634&w=2
>
> This is an undocumented feature. The current documentation for the
> flag only mentions "whitespace errors".

Thanks for digging (even though I do not think the message you
quoted has much to do with this).

04954043 (diff --check: detect leftover conflict markers,
2008-06-26) was the change that added this check to the "check
whitespace breakage" codepath, which forgot to update the
documentation.

And when 4f830390 (Documentation: git diff --check respects
core.whitespace, 2011-06-22) rewrote the paragraph, it again didn't
remember to update it to match the reality.

Care to try a patch?

```

## Ori Avtalion, 2016-03-29 11:19

Subject: Re: Warning about conflict markers - undocumented 'diff --check' feature & suggestion
Message-ID: <CALgdb5+E7_CT2e9WFBd9GhiFuc_B7+bpC9tjDfR+-QiTGeoP+A@mail.gmail.com>
URL: https://gitlist.dev/e/CALgdb5%2BE7_CT2e9WFBd9GhiFuc_B7%2BbpC9tjDfR%2B-QiTGeoP%2BA%40mail.gmail.com
In-Reply-To: <xmqqd1qe1a2i.fsf@gitster.mtv.corp.google.com>

```
On Tue, Mar 29, 2016 at 2:01 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Ori Avtalion <ori@avtalion.name> writes:
>
> Thanks for digging (even though I do not think the message you
> quoted has much to do with this).

Oops, you are correct! I had several tabs open digging through the archives and
picked the wrong one :)

> Care to try a patch?

Yes. Will submit one soon.
If my change introduces a few words that exceed asciidoc's ~72-char line width,
should I reformat the entire paragraph? (thus making it had to identify what
changed exactly)

Any thoughts on adding similar functionality to "git add"?

```

## Junio C Hamano, 2016-03-29 18:23

Subject: Re: Warning about conflict markers - undocumented 'diff --check' feature & suggestion
Message-ID: <xmqqvb45xhw1.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqvb45xhw1.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <CALgdb5+E7_CT2e9WFBd9GhiFuc_B7+bpC9tjDfR+-QiTGeoP+A@mail.gmail.com>

```
Ori Avtalion <ori@avtalion.name> writes:

> If my change introduces a few words that exceed asciidoc's ~72-char line width,
> should I reformat the entire paragraph? (thus making it had to identify what
> changed exactly)

You should try to minimize the damage, but shouldn't go overboard ;-)

> Any thoughts on adding similar functionality to "git add"?

I am not sure what "similar functionality" you are imagining.

"git add" does not show any changes, it just does what it was told
to do.  If the user is unsure, s/he should make it the habit to
check what s/he is doing with "git diff".

```

## Ori Avtalion, 2016-03-29 18:27

Subject: Re: Warning about conflict markers - undocumented 'diff --check' feature & suggestion
Message-ID: <CALgdb5LS9EgqaBsm6vEWfQz-BZE=xH42fFdF5-eg-XyNsRBYkA@mail.gmail.com>
URL: https://gitlist.dev/e/CALgdb5LS9EgqaBsm6vEWfQz-BZE%3DxH42fFdF5-eg-XyNsRBYkA%40mail.gmail.com
In-Reply-To: <xmqqvb45xhw1.fsf@gitster.mtv.corp.google.com>

```
On Tue, Mar 29, 2016 at 9:23 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Ori Avtalion <ori@avtalion.name> writes:
> I am not sure what "similar functionality" you are imagining.
>
> "git add" does not show any changes, it just does what it was told
> to do.  If the user is unsure, s/he should make it the habit to
> check what s/he is doing with "git diff".

I was thinking of an off-by-default setting where git-add outright
refuses to stage changes that do not pass "diff --check".
I understand if that's a big deviation from the spirit of the tool,
and perhaps not a good idea.

```

## Ori Avtalion, 2016-03-29 18:59

Subject: [PATCH] Documentation: git diff --check detects conflict markers
Message-ID: <1459277985-5776-1-git-send-email-ori@avtalion.name>
URL: https://gitlist.dev/e/1459277985-5776-1-git-send-email-ori%40avtalion.name
In-Reply-To: <xmqqd1qe1a2i.fsf@gitster.mtv.corp.google.com>

```
Signed-off-by: Ori Avtalion <ori@avtalion.name>
---
 Documentation/diff-options.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 306b7e3..32f48ed 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -286,8 +286,8 @@ endif::git-format-patch[]
 
 ifndef::git-format-patch[]
 --check::
-	Warn if changes introduce whitespace errors.  What are
-	considered whitespace errors is controlled by `core.whitespace`
+	Warn if changes introduce conflict markers or whitespace errors.
+	What are considered whitespace errors is controlled by `core.whitespace`
 	configuration.  By default, trailing whitespaces (including
 	lines that solely consist of whitespaces) and a space character
 	that is immediately followed by a tab character inside the
-- 
2.5.0

```
