git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Paul Watson <pwatson2@wellmed.net>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: git bug report
Date: Tue, 08 Aug 2023 10:07:32 -0700	[thread overview]
Message-ID: <xmqqbkfh8nu3.fsf@gitster.g> (raw)
In-Reply-To: <MW2PR12MB25558D1886C4AA2A95A5FC618709A@MW2PR12MB2555.namprd12.prod.outlook.com> (Paul Watson's message of "Fri, 4 Aug 2023 16:46:23 +0000")

Paul Watson <pwatson2@wellmed.net> writes:

> 9:43:55.45 2023-08-04  C:\src\t\scripts>TYPE .\t1.txt
> this is t1.txt

> 9:43:57.92 2023-08-04  C:\src\t\scripts>TYPE .\t2.txt
> this is t2.txt
>
> 9:43:58.04 2023-08-04  C:\src\t\scripts>"C:\Program Files\Git\cmd\git.exe" diff --exit-code --no-index  --ignore-all-space  --shortstat  .\t1.txt .\t2.txt
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> 9:43:58.14 2023-08-04  C:\src\t\scripts>ECHO %ERRORLEVEL%
> 0

This is not specific to Windows port and it can be reproduced on a
random Linux box.

    $ echo one >1
    $ echo two >2
    $ git diff --no-index --shortstat 1 2; echo "<<$?>>"
     1 file changed, 1 insertion(+), 1 deletion(-)
    <<1>>
    $ git diff --no-index --shortstat -w 1 2; echo "<<$?>>"
     1 file changed, 1 insertion(+), 1 deletion(-)
    <<0>>

Note that I omitted "--exit-code" in the above reproduction, as it
is always used in the no-index mode.  There seems to be interaction
with "-w" and not using "-p", as this is not limited to "--shortstat".

    $ git diff --no-index -w --stat 1 2; echo "<<$?>>"
     1 => 2 | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    <<0>>

    $ git diff --no-index -w --numstat 1 2; echo "<<$?>>"
    1	1	1 => 2
    <<0>>

All of the above that exits with 0 status will exit with 1 when -p
is added to the command line.

Also, this is not limited to the no-index mode.

    $ echo one >1
    $ git add 1
    $ echo two >1
    $ git diff --exit-code --numstat 1; echo "<<$?>>"
    1	1	1
    <<1>>
    $ git diff --exit-code --numstat -w 1; echo "<<$?>>"
    1	1	1
    <<0>>

So the minimum reproduction seems to be

  * the diff machinery is asked to do --exit-code (no-index
    implicitly does it)
  * -w is used
  * -p is *not* used
  * to compare two different files.

Thanks for a bug report.

Patches welcome ;-)

  parent reply	other threads:[~2023-08-08 18:53 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-04 16:46 git bug report Paul Watson
2023-08-04 17:28 ` rsbecker
2023-08-04 17:48   ` [EXTERNAL] " Paul Watson
2023-08-04 18:12     ` rsbecker
2023-08-07 15:46       ` Paul Watson
2023-08-08 13:07         ` Paul Watson
2023-08-08 13:28           ` rsbecker
2023-08-08 17:07 ` Junio C Hamano [this message]
2023-08-16 23:45   ` [PATCH] diff: tighten interaction between -w and --exit-code Junio C Hamano
2023-08-17  5:10     ` Jeff King
2023-08-17 16:12       ` Junio C Hamano
2023-08-17 19:49         ` Jeff King
2023-08-17 19:56           ` Junio C Hamano
2023-08-17 22:29             ` [PATCH v2 0/5] fix interactions with "-w" and "--exit-code" Junio C Hamano
2023-08-17 22:29               ` [PATCH v2 1/5] diff: --dirstat leakfix Junio C Hamano
2023-08-17 22:29               ` [PATCH v2 2/5] diff: move the fallback "--exit-code" code down Junio C Hamano
2023-08-17 22:29               ` [PATCH v2 3/5] diff: mode-only change should be noticed by "--patch -w --exit-code" Junio C Hamano
2023-08-18 21:15                 ` Junio C Hamano
2023-08-17 22:29               ` [PATCH v2 4/5] diff: teach "--stat -w --exit-code" to notice differences Junio C Hamano
2023-08-17 22:29               ` [PATCH v2 5/5] diff: teach "--name-status" and friends to honor "--exit-code -w" Junio C Hamano
2023-08-17 22:37               ` [PATCH v2 0/5] fix interactions with "-w" and "--exit-code" Junio C Hamano
2023-08-18 23:59               ` [PATCH v3 " Junio C Hamano
2023-08-18 23:59                 ` [PATCH v3 1/5] diff: move the fallback "--exit-code" code down Junio C Hamano
2023-08-21 20:41                   ` Jeff King
2023-08-18 23:59                 ` [PATCH v3 2/5] diff: mode-only change should be noticed by "--patch -w --exit-code" Junio C Hamano
2023-08-18 23:59                 ` [PATCH v3 3/5] diff: teach "--stat -w --exit-code" to notice differences Junio C Hamano
2023-08-21 20:45                   ` Jeff King
2023-08-18 23:59                 ` [PATCH v3 4/5] t4040: remove test that succeeded for a wrong reason Junio C Hamano
2023-08-18 23:59                 ` [PATCH v3 5/5] diff: the -w option breaks --exit-code for --raw and other output modes Junio C Hamano
2023-08-21 21:00                   ` Jeff King
2023-08-21 21:08                     ` Jeff King
2023-08-21 22:23                       ` Jeff King
2023-08-21 22:16                     ` Junio C Hamano
2023-08-21 22:26                     ` Junio C Hamano
2023-08-22  1:30                       ` Jeff King
2023-08-21 21:02                 ` [PATCH v3 0/5] fix interactions with "-w" and "--exit-code" Jeff King
  -- strict thread matches above, loose matches on Subject: below --
2022-10-10 23:09 Git bug report Camden Narzt
2022-04-14  7:22 Git Bug Report Randall Alfaro
2011-10-04 21:24 Git Bug report Federico Lucifredi
2011-10-05  6:11 ` Johannes Sixt
2011-10-05 18:32   ` Federico Lucifredi
2011-10-05  7:22 ` Fredrik Gustafsson
2011-10-05 16:49   ` Junio C Hamano
2011-10-05 21:56     ` Nguyen Thai Ngoc Duy
2011-10-06  0:33     ` SZEDER Gábor
2011-10-06  0:44       ` Junio C Hamano
2011-10-06  1:09         ` SZEDER Gábor
     [not found]           ` <CABURp0qCsKG2oOxLw4BfU8UM=9V+pigd69ZK=TZVwetBPqjuiA@mail.gmail.com>
2011-10-06 16:22             ` Junio C Hamano
2011-10-06 16:26               ` Matthieu Moy
2011-10-06 16:54               ` Phil Hord
2011-10-06 22:57               ` Aaron Schrab
2011-10-06 16:48           ` Phil Hord

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqbkfh8nu3.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=pwatson2@wellmed.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).