git/Documentation/config
René Scharfe d7b97b7185 diff: let external diffs report that changes are uninteresting
The options --exit-code and --quiet instruct git diff to indicate
whether it found any significant changes by exiting with code 1 if it
did and 0 if there were none.  Currently this doesn't work if external
diff programs are involved, as we have no way to learn what they found.

Add that ability in the form of the new configuration options
diff.trustExitCode and diff.<driver>.trustExitCode and the environment
variable GIT_EXTERNAL_DIFF_TRUST_EXIT_CODE.  They pair with the config
options diff.external and diff.<driver>.command and the environment
variable GIT_EXTERNAL_DIFF, respectively.

The new options are off by default, keeping the old behavior.  Enabling
them indicates that the external diff returns exit code 1 if it finds
significant changes and 0 if it doesn't, like diff(1).

The name of the new options is taken from the git difftool and mergetool
options of similar purpose.  (There they enable passing on the exit code
of a diff tool and to infer whether a merge done by a merge tool is
successful.)

The new feature sets the diff flag diff_from_contents in
diff_setup_done() if we need the exit code and are allowed to call
external diffs.  This disables the optimization that avoids calling the
program with --quiet.  Add it back by skipping the call if the external
diff is not able to report empty diffs.  We can only do that check after
evaluating the file-specific attributes in run_external_diff().

If we do run the external diff with --quiet, send its output to
/dev/null.

I considered checking the output of the external diff to check whether
its empty.  It was added as 11be65cfa4 (diff: fix --exit-code with
external diff, 2024-05-05) and quickly reverted, as it does not work
with external diffs that do not write to stdout.  There's no reason why
a graphical diff tool would even need to write anything there at all.

I also considered using a non-zero exit code for empty diffs, which
could be done without adding new configuration options.  We'd need to
disable the optimization that allows git diff --quiet to skip calling
external diffs, though -- that might be quite surprising if graphical
diff programs are involved.  And assigning the opposite meaning of the
exit codes compared to diff(1) and git diff --exit-code to the external
diff can cause unnecessary confusion.

Suggested-by: Phillip Wood <phillip.wood123@gmail.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-06-10 09:20:46 -07:00
..
add.txt add: remove "add.interactive.useBuiltin" & Perl "git add--interactive" 2023-02-06 15:03:34 -08:00
advice.txt sequencer: allow disabling conflict advice 2024-03-18 09:28:40 -07:00
alias.txt documentation: fix subject/verb agreement 2023-10-09 12:06:29 -07:00
am.txt
apply.txt documentation: whitespace is already generally plural 2023-10-09 12:06:29 -07:00
attr.txt attr: add attr.tree for setting the treeish to read attributes from 2023-10-13 11:43:29 -07:00
blame.txt blame: correct name of config option in docs 2021-06-28 10:05:13 -07:00
branch.txt documentation: use clearer prepositions 2023-10-09 12:06:29 -07:00
browser.txt
bundle.txt bundle-uri: parse bundle.heuristic=creationToken 2023-01-31 08:57:48 -08:00
checkout.txt documentation: fix capitalization 2023-10-09 12:06:29 -07:00
clean.txt clean: further clean-up of implementation around "--force" 2024-03-04 14:05:13 -08:00
clone.txt doc: git-clone: do not autoreference the manpage in itself 2024-03-29 10:57:41 -07:00
color.txt documentation: add some commas where they are helpful 2023-10-09 12:06:44 -07:00
column.txt documentation: fix singular vs. plural 2023-10-09 12:06:29 -07:00
commit.txt documentation: add missing article 2023-10-09 12:06:29 -07:00
commitgraph.txt commit-graph: use config to specify generation type 2021-02-25 15:10:41 -08:00
completion.txt
core.txt Merge branch 'ds/typofix-core-config-doc' 2024-04-10 10:00:08 -07:00
credential.txt documentation: add some commas where they are helpful 2023-10-09 12:06:44 -07:00
diff.txt diff: let external diffs report that changes are uninteresting 2024-06-10 09:20:46 -07:00
difftool.txt mergetool: new config guiDefault supports auto-toggling gui by DISPLAY 2023-04-05 21:03:29 -07:00
extensions.txt Merge branch 'eb/hash-transition' 2024-03-28 14:13:50 -07:00
fastimport.txt documentation: add some commas where they are helpful 2023-10-09 12:06:44 -07:00
feature.txt pack-objects: enable multi-pack reuse via `feature.experimental` 2024-02-05 15:27:01 -08:00
fetch.txt fetch: add new config option fetch.all 2024-01-08 13:36:23 -08:00
filter.txt
fmt-merge-msg.txt config/fmt-merge-msg.txt: drop space in quote 2020-09-27 14:22:41 -07:00
format.txt Merge branch 'jc/doc-misspelt-refs-fix' 2023-12-27 14:52:26 -08:00
fsck.txt documentation: add some commas where they are helpful 2023-10-09 12:06:44 -07:00
fsmonitor--daemon.txt documentation: wording improvements 2023-10-09 12:04:21 -07:00
gc.txt Merge branch 'en/docfixes' 2023-10-23 13:56:37 -07:00
gitcvs.txt
gitweb.txt
gpg.txt documentation: fix subject/verb agreement 2023-10-09 12:06:29 -07:00
grep.txt grep docs: describe --recurse-submodules further and improve formatting a bit 2024-03-25 14:00:03 -07:00
gui.txt documentation: add missing article 2023-10-09 12:06:29 -07:00
guitool.txt
help.txt help.c: help.autocorrect=prompt waits for user action 2021-08-14 11:20:49 -07:00
http.txt documentation: add missing words 2023-10-09 12:06:29 -07:00
i18n.txt documentation: use clearer prepositions 2023-10-09 12:06:29 -07:00
imap.txt documentation: fix verb vs. noun 2023-10-09 12:06:29 -07:00
includeif.txt config.txt: document include, includeIf 2022-07-17 14:23:42 -07:00
index.txt documentation: fix apostrophe usage 2023-10-09 12:06:29 -07:00
init.txt doc: git-init: apply new documentation formatting guidelines 2024-03-29 10:57:40 -07:00
instaweb.txt
interactive.txt doc: remove outdated information about interactive.singleKey 2024-02-19 15:12:41 -08:00
log.txt documentation: add some commas where they are helpful 2023-10-09 12:06:44 -07:00
lsrefs.txt docs: move protocol-related docs to man section 5 2022-08-04 14:12:23 -07:00
mailinfo.txt documentation: fix singular vs. plural 2023-10-09 12:06:29 -07:00
mailmap.txt
maintenance.txt documentation: fix subject/verb agreement 2023-10-09 12:06:29 -07:00
man.txt documentation: add missing article 2023-10-09 12:06:29 -07:00
merge.txt documentation: add some commas where they are helpful 2023-10-09 12:06:44 -07:00
mergetool.txt mergetools: vimdiff: use correct tool's name when reading mergetool config 2024-02-19 08:45:14 -08:00
notes.txt documentation: add missing article 2023-10-09 12:06:29 -07:00
pack.txt Documentation/config/pack.txt: fix broken AsciiDoc mark-up 2024-02-23 13:47:16 -08:00
pager.txt
pretty.txt
promisor.txt promisor-remote: add promisor.quiet configuration option 2024-05-26 09:17:08 -07:00
protocol.txt Sync with 2.37.4 2022-10-06 20:00:04 -04:00
pull.txt pull: remove support for `--rebase=preserve` 2021-09-07 21:45:32 -07:00
push.txt documentation: add some commas where they are helpful 2023-10-09 12:06:44 -07:00
rebase.txt Merge branch 'ms/rebase-insnformat-doc-fix' 2024-01-12 16:09:57 -08:00
receive.txt builtin/receive-pack: convert to use git-maintenance(1) 2024-04-17 08:42:26 -07:00
reftable.txt refs/reftable: allow configuring geometric factor 2024-05-13 17:02:39 -07:00
remote.txt docs: mention --refetch fetch option 2022-03-28 10:25:53 -07:00
remotes.txt
repack.txt builtin/repack.c: allow configuring cruft pack generation 2022-05-26 15:48:26 -07:00
rerere.txt documentation: fix singular vs. plural 2023-10-09 12:06:29 -07:00
revert.txt revert: config documentation fixes 2022-06-27 08:37:36 -07:00
safe.txt documentation: wording improvements 2023-10-09 12:04:21 -07:00
sendemail.txt documentation: send-email: use camel case consistently 2024-02-20 14:37:44 -08:00
sequencer.txt documentation: add some commas where they are helpful 2023-10-09 12:06:44 -07:00
showbranch.txt
sparse.txt repo_read_index: add config to expect files outside sparse patterns 2022-03-01 23:37:48 -08:00
splitindex.txt documentation: add some commas where they are helpful 2023-10-09 12:06:44 -07:00
ssh.txt
stash.txt documentation: add missing article 2023-10-09 12:06:29 -07:00
status.txt status: allow --untracked=false and friends 2024-03-13 10:43:32 -07:00
submodule.txt documentation: fix apostrophe usage 2023-10-09 12:06:29 -07:00
tag.txt separate tar.* config to its own source file 2020-03-18 12:42:09 -07:00
tar.txt separate tar.* config to its own source file 2020-03-18 12:42:09 -07:00
trace2.txt documentation: wording improvements 2023-10-09 12:04:21 -07:00
transfer.txt upload-pack: disallow object-info capability by default 2024-02-28 14:42:01 -08:00
uploadarchive.txt
uploadpack.txt Documentation: define protected configuration 2022-07-14 15:08:29 -07:00
url.txt
user.txt documentation: add some commas where they are helpful 2023-10-09 12:06:44 -07:00
versionsort.txt documentation: add some commas where they are helpful 2023-10-09 12:06:44 -07:00
web.txt
worktree.txt