diff -B -M: fix output for "copy and then rewrite" case

Starting from a single file, A, if you create B as a copy of A (and
possibly make some edit) and then make extensive change to A, you
will see:

    $ git diff -C --name-status
    C89    A    B
    M      A

which is expected.  However, if you ask the same question in a
different way, you see this:

    $ git diff -B -M --name-status
    R89    A    B
    M100   A

telling us that A was rename-edited into B (as if "A will no longer
exist as the result") and at the same time A itself was extensively
edited.

In this case, because the resulting tree still does have file A
(even if it has contents vastly different from the original), we
should use "C"opy, not "R"ename, to avoid hinting that A somehow
goes away.

Two existing tests were depending on the wrong behaviour, and fixed.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
difftool--helper: exit when reading a prompt answer fails

An attempt to quit difftool by hitting Ctrl-D (EOF) at its prompt does
not quit it, but is treated as if 'yes' was answered to the prompt and
all following prompts, which is contrary to the user's intent. Fix the
error check.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-compat-util.h: support variadic macros with the XL C compiler

When the XL C compiler is run with an appropriate language level or
suboption, it defines a feature test macro to indicate support for
variadic macros by defining __C99_MACRO_WITH_VA_ARGS C preprocessor
macro.

This was tested on z/OS, but it should also work on AIX according
to IBM documentation.

Signed-off-by: David Michael <fedora.dm0@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile: reorder linker flags in the git executable rule

The XL C compiler can fail due to mixing library path and object
file arguments, for example when linking git while building with
"gmake LDFLAGS=-L$prefix/lib".

Move the ALL_LDFLAGS variable expansion in the git executable rule
to be consistent with all the other linking rules, namely to have
LDFLAGS such as -L$where before the object files *.o being linked
together.

Signed-off-by: David Michael <fedora.dm0@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/bswap.h: detect endianness from XL C compiler macros

There is no /usr/include/endian.h equivalent on z/OS, but the
compiler will define macros to indicate endianness on host and
target hardware.  This adds a test for these macros as a last
resort for determining byte order.

Signed-off-by: David Michael <fedora.dm0@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation: refactor common operations into variables

The Makefile performs several very similar tasks to convert AsciiDoc
files into either HTML or DocBook.  Move these items into variables to
reduce the duplication.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation: remove Asciidoctor linkgit macro

Asciidoctor provides an extension implementing a backend-independent
macro for dealing with manpage links just like the linkgit macro.  As
this is more likely to be up-to-date with future changes in Asciidoctor,
prefer using it over reimplementing in Git.

This reverts commit 773ee47c2b9c691d9758b2bea6cac10e3f0c4e12.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/lib-gpg: make gpghome files writable

t/lib-gpg.sh copies the test environment's gpg home to the trash
directory and makes sure the directoty is writable.

Make sure the copied files are writable, too.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Revert "grep: fix match highlighting for combined patterns with context lines"

This reverts commit d5a7410d22075ecf9f2597d2516bb9914cd55049.

It turns out that showing partial matches on the lines that are not
matching ones is a feature, not a bug, modelling after ms/mc
specifiers in GNU grep's environment variables GREP_COLORS.
config.txt: pack.windowmemory limit applies per-thread

It took me a long time to notice the rider on the pack.threads
configuration option that it would multiple the memory consumption
by the number of CPUs in the machine.  Clarify that the limit
applies per-thread.

Signed-off-by: Robert de Bath <rdebath@tvisiontech.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
grep: add color.grep.matchcontext and color.grep.matchselected

The config option color.grep.match can be used to specify the highlighting
color for matching strings.  Add the options matchContext and matchSelected
to allow different colors to be specified for matching strings in the
context vs. in selected lines.  This is similar to the ms and mc specifiers
in GNU grep's environment variable GREP_COLORS.

Tests are from Zoltan Klinger's earlier attempt to solve the same
issue in a different way.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
difftool: add support for --trust-exit-code

Teach difftool to exit when a diff tool returns a non-zero exit
code when either --trust-exit-code is specified or
difftool.trustExitCode is true.

Forward exit codes from invoked diff tools to the caller when
--trust-exit-code is used.

Suggested-by: Adri Farr <14farresa@gmail.com>
Helped-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'bc/asciidoctor' into next

Add machinery to alternatively use AsciiDoctor to format our
documentation.

* bc/asciidoctor:
  Documentation: remove Asciidoctor linkgit macro
  Documentation: refactor common operations into variables
Merge branch 'zk/grep-color-words' into next

"git grep --color" highlighted matching tokens on non-matching
context lines and function name headers, which was sometimes
unwanted.  rs/grep-color-words is a competing proposal that does not
break existing users, so we will use that instead, and revert this
series in preparation for that.

* zk/grep-color-words:
  Revert "grep: fix match highlighting for combined patterns with context lines"
Merge branch 'rs/grep-color-words' into next

Allow painting or not painting (partial) matches in context lines
when showing "grep -C<num>" output in color.

* rs/grep-color-words:
  grep: add color.grep.matchcontext and color.grep.matchselected
Merge branch 'mg/lib-gpg-ro-safety' into next

In a tarball extract whose files are all read-only, running GPG
tests would have failed due to unwritable files.

* mg/lib-gpg-ro-safety:
  t/lib-gpg: make gpghome files writable
Merge branch 'jc/diff-b-m' into next

Fix long-standing bug in "diff -B -M" output.

* jc/diff-b-m:
  diff -B -M: fix output for "copy and then rewrite" case
Merge branch 'dm/port2zos' into next

z/OS port

* dm/port2zos:
  compat/bswap.h: detect endianness from XL C compiler macros
  Makefile: reorder linker flags in the git executable rule
  git-compat-util.h: support variadic macros with the XL C compiler
Merge branch 'da/difftool' into next

Allow diff tool backend to stop early by exiting with a non-zero
status.

* da/difftool:
  difftool: add support for --trust-exit-code
  difftool--helper: exit when reading a prompt answer fails
Merge branch 'rb/pack-window-memory-config-doc' into next

* rb/pack-window-memory-config-doc:
  config.txt: pack.windowmemory limit applies per-thread