]> git.ipfire.org Git - thirdparty/git.git/commit - t/t3206-range-diff.sh
range-diff: allow to diff files regardless of submodule config
authorLucas De Marchi <lucas.demarchi@intel.com>
Wed, 24 Oct 2018 19:46:17 +0000 (12:46 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 25 Oct 2018 05:47:53 +0000 (14:47 +0900)
commit0e573e8fcc395b5249c1c4713c2e385893c98b8c
treef58b15fa4230d818ec1ee0aa1adb6762901ca0a4
parent5a0cc8aca797dbd7d2be3b67458ff880ed45cddf
range-diff: allow to diff files regardless of submodule config

If we have `submodule.diff = log' in the configuration file
or `--submodule=log' is given as argument, range-diff fails
to compare both diffs and we only get the following output:

    Submodule a 0000000...0000000 (new submodule)

Even if the repository doesn't have any submodule.

That's because the mode in diff_filespec is not correct and when
flushing the diff, down in builtin_diff() we will enter the condition:

if (o->submodule_format == DIFF_SUBMODULE_LOG &&
    (!one->mode || S_ISGITLINK(one->mode)) &&
    (!two->mode || S_ISGITLINK(two->mode))) {
show_submodule_summary(o, one->path ? one->path : two->path,
&one->oid, &two->oid,
two->dirty_submodule);
return;

It turns out that S_ISGITLINK will return true (mode == 0160000 here).
Similar thing happens if submodule.diff is "diff".

Do like it's done in grep.c when calling fill_filespec() and force it to
be recognized as a file by adding S_IFREG to the mode.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
range-diff.c
t/t3206-range-diff.sh