{"thread":{"id":"35821","subject":"Fwd: Git Directory Diff for submodule","startedAt":"2014-02-07T09:15:05Z","lastAt":"2014-02-21T09:27:25Z","messageCount":6,"participants":["Gábor Lipták","Jens Lehmann","David Aguilar","John Keeping"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"234435","messageId":"CAN-m_U=eYSEXfVBcD1Rfx-YvGx5Wu+hB2uAc=6xX_HO7bS0FUg@mail.gmail.com","threadId":"35821","inReplyTo":"CAN-m_UnQ7Yzuq7n6mxmsd3XcfLSVxMdnLiGFDiN1Ph3ZiFqwew@mail.gmail.com","subject":"Fwd: Git Directory Diff for submodule","fromName":"Gábor Lipták","fromEmail":"gabor.liptak@gmail.com","sentAt":"2014-02-07T09:15:05Z","receivedAt":"2014-02-07T09:15:05Z","isPatch":false,"sender":{"key":"gabor.liptak@gmail.com","avatar":null},"body":"Hi,\n\nI think I have found a bug related to submodules and directory diff.\nSee the details at hXXp://stackoverflow.com/q/21623155/337621.\nIf you need any further details, just ask.\n\nRegards,\n\nGábor Lipták\n"},{"id":"234464","messageId":"52F54441.6090209@web.de","threadId":"35821","inReplyTo":"CAN-m_U=eYSEXfVBcD1Rfx-YvGx5Wu+hB2uAc=6xX_HO7bS0FUg@mail.gmail.com","subject":"Re: Fwd: Git Directory Diff for submodule","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2014-02-07T20:38:25Z","receivedAt":"2014-02-07T20:38:25Z","isPatch":false,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 07.02.2014 10:15, schrieb Gábor Lipták:\n> I think I have found a bug related to submodules and directory diff.\n> See the details at hXXp://stackoverflow.com/q/21623155/337621.\n\nLet's inline the recipe one finds after decrypting this link:\n\n~/Projects/MAINMODULE/platform/SUBMODULE [master]$ git difftool -tool=meld --dir-diff --cached\n  fatal: Could not switch to '../../../../platform/': No such file or directory\n  diff --raw --no-abbrev -z --cached: command returned error: 128\n~/Projects/MAINMODULE/platform/SUBMODULE [master]$ cd ..\n~/Projects/MAINMODULE/platform [master]$ cd ..\n~/Projects/MAINMODULE [master]$ git difftool -tool=meld --dir-diff --cached\n  // NO PROBLEM, works.\n~/Projects/MAINMODULE [master]$ git version\n  git version 1.8.4\n\n\n> If you need any further details, just ask.\n\n- Does this only happen when you use difftool? E.g. what does\n  \"git status\" inside the submodule say?\n\n- What does \"git config core.worktree\" print when run in the\n  submodule?\n"},{"id":"234573","messageId":"CAN-m_UnSqTnLydyVF2TLxOia9vzmQr9e4+xWh8aVNBosfCq5nA@mail.gmail.com","threadId":"35821","inReplyTo":"52F54441.6090209@web.de","subject":"Re: Fwd: Git Directory Diff for submodule","fromName":"Gábor Lipták","fromEmail":"gabor.liptak@gmail.com","sentAt":"2014-02-10T07:33:27Z","receivedAt":"2014-02-10T07:33:27Z","isPatch":false,"sender":{"key":"gabor.liptak@gmail.com","avatar":null},"body":"Hi Jens,\n\nSo \"git status\" says:\n\nliptak@liptak-kubuntu:~/Projects/MAIN_MODULE/platform/SUBMODULE\n[master]$ git status\n# On branch master\n# Your branch is up-to-date with 'origin/master'.\n#\n# Changes not staged for commit:\n#   (use \"git add <file>...\" to update what will be committed)\n#   (use \"git checkout -- <file>...\" to discard changes in working\ndirectory)\n#\n#       modified:   xxxxxx.java\n#       modified:   xxxxxxx.java\n# ...\n# ...\n# ...\n# ...\n# ...\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\ngit config core.worktree gives back: \"../../../../platform/SUBMODULE\"\n\nThe submodule was inited simply with \"git submodule init\" +\n\"git.submodule update\"\n\nMAINMODULE/.gitsubmodules file contains similar entry:\n[submodule \"platform/SUBMODULE\"]\npath = platform/SUBMODULE\nurl = ssh://git@somehost/foo/bar.git\n\nMAINMODULE/.git/config:\n[submodule \"platform/SUBMODULE\"]\nurl = ssh://git@somehost/foo/bar.git\n\nMAINMODULE/platform/SUBMODULE/.git:\ngitdir: ../../.git/modules/platform/SUBMODULE\n\nMAINMODULE/.git/modules/platform/SUBMODULE/config:\n[core]\nrepositoryformatversion = 0\nfilemode = true\nbare = false\nlogallrefupdates = true\nworktree = ../../../../platform/SUBMODULE\n[remote \"origin\"]\nurl = ssh://git@somehost/foo/bar.git\nfetch = +refs/heads/*:refs/remotes/origin/*\n\nSo for me it seems that somehow the relative path inside\nMAINMODULE/.git/modules/platform/SUBMODULE/config gets configuread\nwrong during submodule init+update.\n\nI tried to update the\nMAINMODULE/.git/modules/platform/SUBMODULE/config to contain\n../../platform/SUBMODULE as worktree path, then meld was correctly\nstarted, but the compare tree was not usable. For file changes it\ndisplayed always: XXXXX.java: Dangling symlink. So this is still not a\ncomplete solution somehow.\n\nRegards,\n\nGábor Lipták\n\n2014-02-07 Jens Lehmann <Jens.Lehmann@web.de>:\n> Am 07.02.2014 10:15, schrieb Gábor Lipták:\n>> I think I have found a bug related to submodules and directory diff.\n>> See the details at hXXp://stackoverflow.com/q/21623155/337621.\n>\n> Let's inline the recipe one finds after decrypting this link:\n>\n> ~/Projects/MAINMODULE/platform/SUBMODULE [master]$ git difftool -tool=meld --dir-diff --cached\n>   fatal: Could not switch to '../../../../platform/': No such file or directory\n>   diff --raw --no-abbrev -z --cached: command returned error: 128\n> ~/Projects/MAINMODULE/platform/SUBMODULE [master]$ cd ..\n> ~/Projects/MAINMODULE/platform [master]$ cd ..\n> ~/Projects/MAINMODULE [master]$ git difftool -tool=meld --dir-diff --cached\n>   // NO PROBLEM, works.\n> ~/Projects/MAINMODULE [master]$ git version\n>   git version 1.8.4\n>\n>\n>> If you need any further details, just ask.\n>\n> - Does this only happen when you use difftool? E.g. what does\n>   \"git status\" inside the submodule say?\n>\n> - What does \"git config core.worktree\" print when run in the\n>   submodule?\n"},{"id":"235110","messageId":"53066D8A.6070909@web.de","threadId":"35821","inReplyTo":"CAN-m_UnSqTnLydyVF2TLxOia9vzmQr9e4+xWh8aVNBosfCq5nA@mail.gmail.com","subject":"Re: Fwd: Git Directory Diff for submodule","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2014-02-20T21:03:06Z","receivedAt":"2014-02-20T21:03:06Z","isPatch":false,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Sorry for the late reply, but here we go ...\n\nAm 10.02.2014 07:33, schrieb Gábor Lipták:\n> Hi Jens,\n> \n> So \"git status\" says:\n> \n> liptak@liptak-kubuntu:~/Projects/MAIN_MODULE/platform/SUBMODULE\n> [master]$ git status\n> # On branch master\n> # Your branch is up-to-date with 'origin/master'.\n> #\n> # Changes not staged for commit:\n> #   (use \"git add <file>...\" to update what will be committed)\n> #   (use \"git checkout -- <file>...\" to discard changes in working\n> directory)\n> #\n> #       modified:   xxxxxx.java\n> #       modified:   xxxxxxx.java\n> # ...\n> # ...\n> # ...\n> # ...\n> # ...\n> #\n> no changes added to commit (use \"git add\" and/or \"git commit -a\")\n> \n> git config core.worktree gives back: \"../../../../platform/SUBMODULE\"\n\nWhich looks a bit strange but is perfectly ok for a repository\nthat uses a gitfile, as the core.worktree setting is relative\nto the git directory the gitfile references and not the directory\nthe gitfile lives in. A quick glance at the find_worktree\nsubroutine in git-difftool.perl makes me think that difftool is\nnot aware of that fact. David, does that make sense?\n\n> The submodule was inited simply with \"git submodule init\" +\n> \"git.submodule update\"\n> \n> MAINMODULE/.gitsubmodules file contains similar entry:\n> [submodule \"platform/SUBMODULE\"]\n> path = platform/SUBMODULE\n> url = ssh://git@somehost/foo/bar.git\n> \n> MAINMODULE/.git/config:\n> [submodule \"platform/SUBMODULE\"]\n> url = ssh://git@somehost/foo/bar.git\n> \n> MAINMODULE/platform/SUBMODULE/.git:\n> gitdir: ../../.git/modules/platform/SUBMODULE\n> \n> MAINMODULE/.git/modules/platform/SUBMODULE/config:\n> [core]\n> repositoryformatversion = 0\n> filemode = true\n> bare = false\n> logallrefupdates = true\n> worktree = ../../../../platform/SUBMODULE\n> [remote \"origin\"]\n> url = ssh://git@somehost/foo/bar.git\n> fetch = +refs/heads/*:refs/remotes/origin/*\n> \n> So for me it seems that somehow the relative path inside\n> MAINMODULE/.git/modules/platform/SUBMODULE/config gets configuread\n> wrong during submodule init+update.\n> \n> I tried to update the\n> MAINMODULE/.git/modules/platform/SUBMODULE/config to contain\n> ../../platform/SUBMODULE as worktree path, then meld was correctly\n> started, but the compare tree was not usable. For file changes it\n> displayed always: XXXXX.java: Dangling symlink. So this is still not a\n> complete solution somehow.\n> \n> Regards,\n> \n> Gábor Lipták\n> \n> 2014-02-07 Jens Lehmann <Jens.Lehmann@web.de>:\n>> Am 07.02.2014 10:15, schrieb Gábor Lipták:\n>>> I think I have found a bug related to submodules and directory diff.\n>>> See the details at hXXp://stackoverflow.com/q/21623155/337621.\n>>\n>> Let's inline the recipe one finds after decrypting this link:\n>>\n>> ~/Projects/MAINMODULE/platform/SUBMODULE [master]$ git difftool -tool=meld --dir-diff --cached\n>>   fatal: Could not switch to '../../../../platform/': No such file or directory\n>>   diff --raw --no-abbrev -z --cached: command returned error: 128\n>> ~/Projects/MAINMODULE/platform/SUBMODULE [master]$ cd ..\n>> ~/Projects/MAINMODULE/platform [master]$ cd ..\n>> ~/Projects/MAINMODULE [master]$ git difftool -tool=meld --dir-diff --cached\n>>   // NO PROBLEM, works.\n>> ~/Projects/MAINMODULE [master]$ git version\n>>   git version 1.8.4\n>>\n>>\n>>> If you need any further details, just ask.\n>>\n>> - Does this only happen when you use difftool? E.g. what does\n>>   \"git status\" inside the submodule say?\n>>\n>> - What does \"git config core.worktree\" print when run in the\n>>   submodule?\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n> \n"},{"id":"235112","messageId":"CAJDDKr5czZezBZC1HtS9EjKvpPn-sxQTJOWLABRBVw2ei2BFVg@mail.gmail.com","threadId":"35821","inReplyTo":"53066D8A.6070909@web.de","subject":"Re: Fwd: Git Directory Diff for submodule","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2014-02-20T22:41:23Z","receivedAt":"2014-02-20T22:41:23Z","isPatch":false,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Thu, Feb 20, 2014 at 1:03 PM, Jens Lehmann <Jens.Lehmann@web.de> wrote:\n> Sorry for the late reply, but here we go ...\n>\n> Am 10.02.2014 07:33, schrieb Gábor Lipták:\n>> Hi Jens,\n>>\n>> So \"git status\" says:\n>>\n>> liptak@liptak-kubuntu:~/Projects/MAIN_MODULE/platform/SUBMODULE\n>> [master]$ git status\n>> # On branch master\n>> # Your branch is up-to-date with 'origin/master'.\n>> #\n>> # Changes not staged for commit:\n>> #   (use \"git add <file>...\" to update what will be committed)\n>> #   (use \"git checkout -- <file>...\" to discard changes in working\n>> directory)\n>> #\n>> #       modified:   xxxxxx.java\n>> #       modified:   xxxxxxx.java\n>> # ...\n>> # ...\n>> # ...\n>> # ...\n>> # ...\n>> #\n>> no changes added to commit (use \"git add\" and/or \"git commit -a\")\n>>\n>> git config core.worktree gives back: \"../../../../platform/SUBMODULE\"\n>\n> Which looks a bit strange but is perfectly ok for a repository\n> that uses a gitfile, as the core.worktree setting is relative\n> to the git directory the gitfile references and not the directory\n> the gitfile lives in. A quick glance at the find_worktree\n> subroutine in git-difftool.perl makes me think that difftool is\n> not aware of that fact. David, does that make sense?\n\nThat does make sense. It sounds like that may need to be adjusted.\n\nWhat does `git rev-parse --show-toplevel` print? It seems like the\nfind_worktree() logic needs to be extended to handle .git files.\n\n>> The submodule was inited simply with \"git submodule init\" +\n>> \"git.submodule update\"\n\nOr possibly, as you mention below, it could be that \"git submodule\ninit\" ended up writing the wrong core.worktree value. I'm not very\nfamiliar with how they are initialized, but the paths do seem sane, so\nI doesn't seem like that's the issue.\n\nIf it's a problem in difftool we can probably find a way to do the\nright thing. It looks like the core.worktree is relative to the\n.git/modules/XXX directory rather than the submodule (and\nsuper-project)'s worktree.\n\nHere's our current logic:\n\nsub find_worktree\n{\n    my ($repo) = @_;\n\n    # Git->repository->wc_path() does not honor changes to the working\n    # tree location made by $ENV{GIT_WORK_TREE} or the 'core.worktree'\n    # config variable.\n    my $worktree;\n    my $env_worktree = $ENV{GIT_WORK_TREE};\n    my $core_worktree = Git::config('core.worktree');\n\n    if (defined($env_worktree) and (length($env_worktree) > 0)) {\n        $worktree = $env_worktree;\n    } elsif (defined($core_worktree) and (length($core_worktree) > 0)) {\n        $worktree = $core_worktree;\n    } else {\n        $worktree = $repo->wc_path();\n    }\n    return $worktree;\n}\n\nJohn, any thoughts?\n\n>> MAINMODULE/.gitsubmodules file contains similar entry:\n>> [submodule \"platform/SUBMODULE\"]\n>> path = platform/SUBMODULE\n>> url = ssh://git@somehost/foo/bar.git\n>>\n>> MAINMODULE/.git/config:\n>> [submodule \"platform/SUBMODULE\"]\n>> url = ssh://git@somehost/foo/bar.git\n>>\n>> MAINMODULE/platform/SUBMODULE/.git:\n>> gitdir: ../../.git/modules/platform/SUBMODULE\n>>\n>> MAINMODULE/.git/modules/platform/SUBMODULE/config:\n>> [core]\n>> repositoryformatversion = 0\n>> filemode = true\n>> bare = false\n>> logallrefupdates = true\n>> worktree = ../../../../platform/SUBMODULE\n>> [remote \"origin\"]\n>> url = ssh://git@somehost/foo/bar.git\n>> fetch = +refs/heads/*:refs/remotes/origin/*\n>>\n>> So for me it seems that somehow the relative path inside\n>> MAINMODULE/.git/modules/platform/SUBMODULE/config gets configuread\n>> wrong during submodule init+update.\n>>\n>> I tried to update the\n>> MAINMODULE/.git/modules/platform/SUBMODULE/config to contain\n>> ../../platform/SUBMODULE as worktree path, then meld was correctly\n>> started, but the compare tree was not usable. For file changes it\n>> displayed always: XXXXX.java: Dangling symlink. So this is still not a\n>> complete solution somehow.\n>>\n>> Regards,\n>>\n>> Gábor Lipták\n>>\n>> 2014-02-07 Jens Lehmann <Jens.Lehmann@web.de>:\n>>> Am 07.02.2014 10:15, schrieb Gábor Lipták:\n>>>> I think I have found a bug related to submodules and directory diff.\n>>>> See the details at hXXp://stackoverflow.com/q/21623155/337621.\n>>>\n>>> Let's inline the recipe one finds after decrypting this link:\n>>>\n>>> ~/Projects/MAINMODULE/platform/SUBMODULE [master]$ git difftool -tool=meld --dir-diff --cached\n>>>   fatal: Could not switch to '../../../../platform/': No such file or directory\n>>>   diff --raw --no-abbrev -z --cached: command returned error: 128\n>>> ~/Projects/MAINMODULE/platform/SUBMODULE [master]$ cd ..\n>>> ~/Projects/MAINMODULE/platform [master]$ cd ..\n>>> ~/Projects/MAINMODULE [master]$ git difftool -tool=meld --dir-diff --cached\n>>>   // NO PROBLEM, works.\n>>> ~/Projects/MAINMODULE [master]$ git version\n>>>   git version 1.8.4\n>>>\n>>>\n>>>> If you need any further details, just ask.\n>>>\n>>> - Does this only happen when you use difftool? E.g. what does\n>>>   \"git status\" inside the submodule say?\n>>>\n>>> - What does \"git config core.worktree\" print when run in the\n>>>   submodule?\n-- \nDavid\n"},{"id":"235122","messageId":"20140221092725.GE1048@serenity.lan","threadId":"35821","inReplyTo":"CAJDDKr5czZezBZC1HtS9EjKvpPn-sxQTJOWLABRBVw2ei2BFVg@mail.gmail.com","subject":"Re: Fwd: Git Directory Diff for submodule","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2014-02-21T09:27:25Z","receivedAt":"2014-02-21T09:27:25Z","isPatch":false,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"On Thu, Feb 20, 2014 at 02:41:23PM -0800, David Aguilar wrote:\n> On Thu, Feb 20, 2014 at 1:03 PM, Jens Lehmann <Jens.Lehmann@web.de> wrote:\n> > Sorry for the late reply, but here we go ...\n> >\n> > Am 10.02.2014 07:33, schrieb Gábor Lipták:\n> >> Hi Jens,\n> >>\n> >> So \"git status\" says:\n> >>\n> >> liptak@liptak-kubuntu:~/Projects/MAIN_MODULE/platform/SUBMODULE\n> >> [master]$ git status\n> >> # On branch master\n> >> # Your branch is up-to-date with 'origin/master'.\n> >> #\n> >> # Changes not staged for commit:\n> >> #   (use \"git add <file>...\" to update what will be committed)\n> >> #   (use \"git checkout -- <file>...\" to discard changes in working\n> >> directory)\n> >> #\n> >> #       modified:   xxxxxx.java\n> >> #       modified:   xxxxxxx.java\n> >> # ...\n> >> # ...\n> >> # ...\n> >> # ...\n> >> # ...\n> >> #\n> >> no changes added to commit (use \"git add\" and/or \"git commit -a\")\n> >>\n> >> git config core.worktree gives back: \"../../../../platform/SUBMODULE\"\n> >\n> > Which looks a bit strange but is perfectly ok for a repository\n> > that uses a gitfile, as the core.worktree setting is relative\n> > to the git directory the gitfile references and not the directory\n> > the gitfile lives in. A quick glance at the find_worktree\n> > subroutine in git-difftool.perl makes me think that difftool is\n> > not aware of that fact. David, does that make sense?\n> \n> That does make sense. It sounds like that may need to be adjusted.\n> \n> What does `git rev-parse --show-toplevel` print? It seems like the\n> find_worktree() logic needs to be extended to handle .git files.\n\nHaving tried it with a submodule here, it looks like rev-parse gets this\nright.\n\n> >> The submodule was inited simply with \"git submodule init\" +\n> >> \"git.submodule update\"\n> \n> Or possibly, as you mention below, it could be that \"git submodule\n> init\" ended up writing the wrong core.worktree value. I'm not very\n> familiar with how they are initialized, but the paths do seem sane, so\n> I doesn't seem like that's the issue.\n> \n> If it's a problem in difftool we can probably find a way to do the\n> right thing. It looks like the core.worktree is relative to the\n> .git/modules/XXX directory rather than the submodule (and\n> super-project)'s worktree.\n> \n> Here's our current logic:\n> \n> sub find_worktree\n> {\n>     my ($repo) = @_;\n> \n>     # Git->repository->wc_path() does not honor changes to the working\n>     # tree location made by $ENV{GIT_WORK_TREE} or the 'core.worktree'\n>     # config variable.\n>     my $worktree;\n>     my $env_worktree = $ENV{GIT_WORK_TREE};\n>     my $core_worktree = Git::config('core.worktree');\n> \n>     if (defined($env_worktree) and (length($env_worktree) > 0)) {\n>         $worktree = $env_worktree;\n>     } elsif (defined($core_worktree) and (length($core_worktree) > 0)) {\n>         $worktree = $core_worktree;\n>     } else {\n>         $worktree = $repo->wc_path();\n>     }\n>     return $worktree;\n> }\n> \n> John, any thoughts?\n\nI don't really like reimplementing logic from core Git here, so I think\nit might be best to just call \"git rev-parse --show-toplevel\" here; it\nwould also be sufficient to make sure we resolve $core_worktree against\n$GIT_DIR - should we be doing that for $env_worktree as well?  It looks\nlike git-rev-parse treats a relative GIT_WORK_TREE as relative to the\ncurrent working directory, so we're OK there.\n\nDoes anyone know why repository->wc_path() does not obey the config\nvariable or $GIT_WORK_TREE?  It seems like the most correct fix is to\nfix it there.\n"}]}