diff: test precedence of external diff drivers
commitc12f82ae631eb07d0ee6a61003754d103025a0b3
authorJeff King <peff@peff.net>
Thu, 19 Jul 2012 11:49:38 +0000 (19 07:49 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 19 Jul 2012 17:17:05 +0000 (19 10:17 -0700)
treea65261b2b1219a64e59482e5c265f74a8839b33c
parentbd8c1a9b49933c766587c65de70a0b8ff518801f
diff: test precedence of external diff drivers

There are three ways to specify an external diff command:
GIT_EXTERNAL_DIFF in the environment, diff.external in the
config, or a "diff" gitattribute. The current order of
precedence is:

  1. gitattribute

  2. GIT_EXTERNAL_DIFF

  3. diff.external

Usually our rule is that environment variables should take
precedence over on-disk config (i.e., option 2 should come
before option 1). However, this situation is trickier than
some, because option 1 is more specific to the individual
file than option 2 (which affects all files), so it might be
preferable. So the current behavior can be seen as
implementing "do the specific thing if we can, but fall back
to this general thing".

This is probably not what we would do if we were writing git
from scratch, but it has been this way for several years,
and is not worth changing. So let's at least document that
this is the way it's supposed to work with a test.

While we're there, let's also make sure that diff.external
(which was not previously tested at all) works by running it
through the same tests as GIT_EXTERNAL_DIFF.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t4020-diff-external.sh