Jens Lehmann <> writes:

> Am 18.09.2012 05:12, schrieb Kenny Simpson:
>>   Is there any nice way to get a diff and/or diffstat of both a project and 
>> its submodules between two revisions of the main project?
>> Something like 'git diff --stat tag_a tag_b' but also including the diffstat 
>> on the submodule from the revision tied to in tag_a to the revision tied to 
>> tag_b.  A few shell backflips will do it, but this seems like I'm missing 
>> something.
> Unfortunately that isn't possible yet, "git diff" still has to learn the
> --recurse-submodules option. And as far as I know, nobody is currently
> working on that.

I do not think it is _that_ unfortunate, at least for two reasons.

When I made something a submodule, not a plain vanilla directory, I
did want it to be treated differently from a collection of files in
random states (which is what a directory is), but as a logical unit.
If I bind another project 'frotz' at my path 'lib/frotz' and ask for
diff of two versions of my superproject, e.g.

    $ git diff v1.0 v1.1

I am more interested in finding out that we used to use v2.5 of
'frotz' back when we were at v1.0 but in our v1.1 we downgraded it
to v2.4, perhaps because we found a regression in the 'frotz'
library, rather than the whole reverse differences between v2.4 and
v2.5 of the frotz project.  That difference, when I want to, I can
get by going to that submodule and grab it myself with

    $ cd lib/frotz &7 git diff v2.4 v2.5

I also suspect that you do not have to change "git diff" at all to
show the patch recursively by using the attribute mechanism (look in
Documentation/gitattributes.text for a string GIT_EXTERNAL_DIFF).
It might be just as simple as doing this:

        echo >.gitattributes "/lib/frotz diff=subrecurse" 
        git config diff.subrecurse.command $HOME/bin/diff-subrecurse
        cat >$HOME/bin/diff-subrecurse <<\-EOF
        path=$1 old_hex=$3 new_hex=$6
        unset GIT_DIR
        cd "$path" || exit 1
        git diff "$old_hex" "$new_hex"        
        chmod +x $HOME/bin/diff-subrecurse

The corner cases like "new submodule", "removed submodule" are left
as an exercise to the reader ;-)
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to