4

I am using Git 1.8.4 and Linux (Kubuntu 13.10).

I have a Git repository with submodules. If I ask for directory diff in the main Git module, it works fine. If I do the same in one of the submodules, I get an error:

~/Projects/MAINMODULE/platform/SUBMODULE [master]$ git difftool -tool=meld --dir-diff --cached
  fatal: Could not switch to '../../../../platform/': No such file or directory
  diff --raw --no-abbrev -z --cached: command returned error: 128
~/Projects/MAINMODULE/platform/SUBMODULE [master]$ cd ..
~/Projects/MAINMODULE/platform [master]$ cd ..
~/Projects/MAINMODULE [master]$ git difftool -tool=meld --dir-diff --cached
  // NO PROBLEM, works.
~/Projects/MAINMODULE [master]$ git version
  git version 1.8.4

Do you have any idea? May it be a Git Bug?

UPDATE: 1.8.5.3 produces the same output

Gábor Lipták
  • 9,646
  • 2
  • 59
  • 113
  • "1.8.5.3 produces the same output": Then it looks like a bug. The last fix for that difftool feature is https://github.com/git/git/commit/32eaf1de7f79c4ba09f3de3261c84e52e0a67af5 (git 1.8.3.2) – VonC Feb 07 '14 at 09:04
  • I have sent a bug report with this SO link to the git@vger.kernel.org mentioned in your answer at http://stackoverflow.com/a/10733251/337621 . Thanks. – Gábor Lipták Feb 07 '14 at 09:12
  • Ok. I will look forward to their answer. – VonC Feb 07 '14 at 09:16
  • http://git.661346.n2.nabble.com/Fwd-Git-Directory-Diff-for-submodule-td7603302.html – Gábor Lipták Feb 10 '14 at 07:34

1 Answers1

5

This workaround works for me:

GIT_WORK_TREE="$(git rev-parse --show-toplevel)" GIT_DIR="$(git rev-parse --git-dir)" git difftool --tool=meld --dir-diff

You can of course put in --cached as per your example.

That's quite a lot to type so you can add the following alias to your ~/.gitconfig:

[alias]
    submeld = !git --work-tree "$(git rev-parse --show-toplevel)" --git-dir "$(git rev-parse --git-dir)" difftool --tool=meld --dir-diff
cdyson37
  • 7,828
  • 3
  • 24
  • 16