• Lucas De Marchi's avatar
    range-diff: allow to diff files regardless of submodule config · 0e573e8f
    Lucas De Marchi authored
    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: default avatarLucas De Marchi <lucas.demarchi@intel.com>
    Acked-by: Johannes Schindelin's avatarJohannes Schindelin <johannes.schindelin@gmx.de>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    0e573e8f
range-diff.c 12.1 KB