0

I have a top repository which contains some git submodules. I can do a git diff on it with:

git diff d1e92 ade34

That only shows that there are some hashes changed in the submodule, but not the changes in the submodule itself.

I found that:

git diff --submodule=diff d1e92 ade34

which works as expected and shows also the real diff inside the submodules.

Now I want to do the same with git difftool but I don't find any syntax which gives me the expected result.

If I simply use

git difftool -d --submodule=diff d1e92 ade34

I only see the changed hashes but not the changed content of the submodules.

I want to see all changes from the main repo with all submodules. The other question asks only for diffing in a submodule. My questiion is not a duplicate of Git Directory Diff does not work in my submodule because it is exactly the opposite action I want to do!

Klaus
  • 24,205
  • 7
  • 58
  • 113
  • @phd: It is exactly the oposite of my question. I want to see the changes from the main repo includingthe subrepos. Your linked question is about diffing inside the subrepos. So it is *not* a duplicate of that one. – Klaus Jul 03 '18 at 13:11
  • I wonder if you could get what you want using a shell script that calls `git diff` on the main repo and then `git submodule foreach ...` to call `git diff` on all your submodules? – larsks Jul 03 '18 at 13:20
  • @larsks: foreach on submodules will not help because it will open a new instance of meld for every subdirectory and most important: It can not diff between the given hash values as they are not part of the submodules but of the main one. – Klaus Jul 03 '18 at 13:23

1 Answers1

0

I came across your topic while searching for similar issue.

I found a way to get the info by scripting and calling the difftool with appropriate commit # for each submodule (kind of similar to the foreach approach). You will still get a new instance for each submodule though.

Here are the aliases created to get the results ; I used several aliases to better debug my scripting. Just call git dtz2 commit1 commit2 in git bash to use it.

dt = difftool --dir-diff
dtverbose = "!sh -c 'echo parent:diff $1-$2 && git dt $1 $2 '" -

dta2 = "!f() { git diff-tree -r "$1" "$2" | grep :160000 | cut  -d' ' -f3,4,5 ; }; f"

dty2 = "!sh -c 'echo $4:diff $1-$2 && cd $4 && git dt $1 $2 '" - 

dtz2 = "!f() { (git dta2 "$1" "$2" | tr -s ' \t' ' ' | xargs -o -n4 git dty2) && git dtverbose "$1" "$2" ; }; f"

The interesting part is the git diff-tree command to compare commit1 vs commit2; the rest is output massaging to feed it to the difftool. You can create a similar command with git ls-tree instead but it will only work from HEAD vs commit1. While git ls-tree already identifies commits for submodule, the git diff-tree only uses objectId ('160000' for submodules).

SJacquart
  • 1
  • 2