From: Michael J Gruber <git@drmicha•warpmail.net>
To: Georg Pichler <georg.pichler@gmail•com>, git@vger•kernel.org
Subject: Re: git diff --exit-code does not honour textconv setting
Date: Tue, 5 Apr 2016 16:22:05 +0200 [thread overview]
Message-ID: <5703CA0D.2090808@drmicha.warpmail.net> (raw)
In-Reply-To: <56EE9B09.6040700@gmail.com>
Georg Pichler venit, vidit, dixit 20.03.2016 13:43:
> Hi,
>
> I realized that "git diff --exit-code" does not honour textconv settings.
> Maybe this behaviour is desired. It can be partially circumvented by using the "-b" flag if one does not care about whitespace changes.
> To reproduce this, create an empty repository and run the following commands:
>
> (I was using git version 2.7.3)
>
> $ git config --add diff.void.textconv test
> $ echo "foo diff=void" >.gitattributes
> $ echo foo >foo
> $ git add . && git commit -m "Init"
> [master (root-commit) 70c39d9] Init
> 2 files changed, 2 insertions(+)
> create mode 100644 .gitattributes
> create mode 100644 foo
> $ echo bar >foo
> $ git status
> On branch master
> Changes not staged for commit:
> (use "git add <file>..." to update what will be committed)
> (use "git checkout -- <file>..." to discard changes in working directory)
>
> modified: foo
>
> no changes added to commit (use "git add" and/or "git commit -a")
> $ git diff
> $ git diff --exit-code
> [exits with 1, no output]
> $ git diff --exit-code -b
> [exits with 0, no output]
>
> The "test" command is used as it does not generate any output on stdout.
"test" is a bit of a red herring here since it will receive commands.
But your example works even with "true" which ignores its commands and
produces no output.
> I would expect "git diff --exit-code" to return with exit code 0. If this is not desired, it should be clearly stated in the man page,
> that "--exit-code" does not honour the textconv setting, except if "-b" is given. Currently this is not clear:
>
> --exit-code
> Make the program exit with codes similar to diff(1). That is, it exits
> with 1 if there were differences and 0 means no differences.
>
> Best,
> Georg Pichler
The description doesn't make it clear whether exit-code refers to the
actual diff (foo vs. bar) or to the diff after textconv (empty vs.
empty). In any case, "-b" should not make a difference for your example.
diff_flush() in diff.c has this piece of code:
/*
* Report the content-level differences with HAS_CHANGES;
* diff_addremove/diff_change does not set the bit when
* DIFF_FROM_CONTENTS is in effect (e.g. with -w).
*/
if (DIFF_OPT_TST(options, DIFF_FROM_CONTENTS)) {
if (options->found_changes)
DIFF_OPT_SET(options, HAS_CHANGES);
else
DIFF_OPT_CLR(options, HAS_CHANGES);
}
So it's clear that depending on "-b" (or "-w") or not, it's taking
shortcuts or looking at the textconved diff but I'm not sure where's the
proper place to fix that.
Michael
next prev parent reply other threads:[~2016-04-05 14:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-20 12:43 git diff --exit-code does not honour textconv setting Georg Pichler
2016-04-05 14:22 ` Michael J Gruber [this message]
2016-04-05 23:16 ` Junio C Hamano
2016-04-06 6:44 ` Michael J Gruber
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=5703CA0D.2090808@drmicha.warpmail.net \
--to=git@drmicha$(echo .)warpmail.net \
--cc=georg.pichler@gmail$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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