All of lore.kernel.org
 help / color / mirror / Atom feed
* Fwd: Git Directory Diff for submodule
       [not found] ` <CAN-m_UnQ7Yzuq7n6mxmsd3XcfLSVxMdnLiGFDiN1Ph3ZiFqwew@mail.gmail.com>
@ 2014-02-07  9:15   ` Gábor Lipták
  2014-02-07 20:38     ` Jens Lehmann
  0 siblings, 1 reply; 6+ messages in thread
From: Gábor Lipták @ 2014-02-07  9:15 UTC (permalink / raw)
  To: git

Hi,

I think I have found a bug related to submodules and directory diff.
See the details at hXXp://stackoverflow.com/q/21623155/337621.
If you need any further details, just ask.

Regards,

Gábor Lipták

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fwd: Git Directory Diff for submodule
  2014-02-07  9:15   ` Fwd: Git Directory Diff for submodule Gábor Lipták
@ 2014-02-07 20:38     ` Jens Lehmann
  2014-02-10  7:33       ` Gábor Lipták
  0 siblings, 1 reply; 6+ messages in thread
From: Jens Lehmann @ 2014-02-07 20:38 UTC (permalink / raw)
  To: Gábor Lipták, git

Am 07.02.2014 10:15, schrieb Gábor Lipták:
> I think I have found a bug related to submodules and directory diff.
> See the details at hXXp://stackoverflow.com/q/21623155/337621.

Let's inline the recipe one finds after decrypting this link:

~/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


> If you need any further details, just ask.

- Does this only happen when you use difftool? E.g. what does
  "git status" inside the submodule say?

- What does "git config core.worktree" print when run in the
  submodule?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fwd: Git Directory Diff for submodule
  2014-02-07 20:38     ` Jens Lehmann
@ 2014-02-10  7:33       ` Gábor Lipták
  2014-02-20 21:03         ` Jens Lehmann
  0 siblings, 1 reply; 6+ messages in thread
From: Gábor Lipták @ 2014-02-10  7:33 UTC (permalink / raw)
  To: Jens Lehmann, git

Hi Jens,

So "git status" says:

liptak@liptak-kubuntu:~/Projects/MAIN_MODULE/platform/SUBMODULE
[master]$ git status
# On branch master
# Your branch is up-to-date with 'origin/master'.
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working
directory)
#
#       modified:   xxxxxx.java
#       modified:   xxxxxxx.java
# ...
# ...
# ...
# ...
# ...
#
no changes added to commit (use "git add" and/or "git commit -a")

git config core.worktree gives back: "../../../../platform/SUBMODULE"

The submodule was inited simply with "git submodule init" +
"git.submodule update"

MAINMODULE/.gitsubmodules file contains similar entry:
[submodule "platform/SUBMODULE"]
path = platform/SUBMODULE
url = ssh://git@somehost/foo/bar.git

MAINMODULE/.git/config:
[submodule "platform/SUBMODULE"]
url = ssh://git@somehost/foo/bar.git

MAINMODULE/platform/SUBMODULE/.git:
gitdir: ../../.git/modules/platform/SUBMODULE

MAINMODULE/.git/modules/platform/SUBMODULE/config:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
worktree = ../../../../platform/SUBMODULE
[remote "origin"]
url = ssh://git@somehost/foo/bar.git
fetch = +refs/heads/*:refs/remotes/origin/*

So for me it seems that somehow the relative path inside
MAINMODULE/.git/modules/platform/SUBMODULE/config gets configuread
wrong during submodule init+update.

I tried to update the
MAINMODULE/.git/modules/platform/SUBMODULE/config to contain
../../platform/SUBMODULE as worktree path, then meld was correctly
started, but the compare tree was not usable. For file changes it
displayed always: XXXXX.java: Dangling symlink. So this is still not a
complete solution somehow.

Regards,

Gábor Lipták

2014-02-07 Jens Lehmann <Jens.Lehmann@web.de>:
> Am 07.02.2014 10:15, schrieb Gábor Lipták:
>> I think I have found a bug related to submodules and directory diff.
>> See the details at hXXp://stackoverflow.com/q/21623155/337621.
>
> Let's inline the recipe one finds after decrypting this link:
>
> ~/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
>
>
>> If you need any further details, just ask.
>
> - Does this only happen when you use difftool? E.g. what does
>   "git status" inside the submodule say?
>
> - What does "git config core.worktree" print when run in the
>   submodule?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fwd: Git Directory Diff for submodule
  2014-02-10  7:33       ` Gábor Lipták
@ 2014-02-20 21:03         ` Jens Lehmann
  2014-02-20 22:41           ` David Aguilar
  0 siblings, 1 reply; 6+ messages in thread
From: Jens Lehmann @ 2014-02-20 21:03 UTC (permalink / raw)
  To: Gábor Lipták, git; +Cc: David Aguilar

Sorry for the late reply, but here we go ...

Am 10.02.2014 07:33, schrieb Gábor Lipták:
> Hi Jens,
> 
> So "git status" says:
> 
> liptak@liptak-kubuntu:~/Projects/MAIN_MODULE/platform/SUBMODULE
> [master]$ git status
> # On branch master
> # Your branch is up-to-date with 'origin/master'.
> #
> # Changes not staged for commit:
> #   (use "git add <file>..." to update what will be committed)
> #   (use "git checkout -- <file>..." to discard changes in working
> directory)
> #
> #       modified:   xxxxxx.java
> #       modified:   xxxxxxx.java
> # ...
> # ...
> # ...
> # ...
> # ...
> #
> no changes added to commit (use "git add" and/or "git commit -a")
> 
> git config core.worktree gives back: "../../../../platform/SUBMODULE"

Which looks a bit strange but is perfectly ok for a repository
that uses a gitfile, as the core.worktree setting is relative
to the git directory the gitfile references and not the directory
the gitfile lives in. A quick glance at the find_worktree
subroutine in git-difftool.perl makes me think that difftool is
not aware of that fact. David, does that make sense?

> The submodule was inited simply with "git submodule init" +
> "git.submodule update"
> 
> MAINMODULE/.gitsubmodules file contains similar entry:
> [submodule "platform/SUBMODULE"]
> path = platform/SUBMODULE
> url = ssh://git@somehost/foo/bar.git
> 
> MAINMODULE/.git/config:
> [submodule "platform/SUBMODULE"]
> url = ssh://git@somehost/foo/bar.git
> 
> MAINMODULE/platform/SUBMODULE/.git:
> gitdir: ../../.git/modules/platform/SUBMODULE
> 
> MAINMODULE/.git/modules/platform/SUBMODULE/config:
> [core]
> repositoryformatversion = 0
> filemode = true
> bare = false
> logallrefupdates = true
> worktree = ../../../../platform/SUBMODULE
> [remote "origin"]
> url = ssh://git@somehost/foo/bar.git
> fetch = +refs/heads/*:refs/remotes/origin/*
> 
> So for me it seems that somehow the relative path inside
> MAINMODULE/.git/modules/platform/SUBMODULE/config gets configuread
> wrong during submodule init+update.
> 
> I tried to update the
> MAINMODULE/.git/modules/platform/SUBMODULE/config to contain
> ../../platform/SUBMODULE as worktree path, then meld was correctly
> started, but the compare tree was not usable. For file changes it
> displayed always: XXXXX.java: Dangling symlink. So this is still not a
> complete solution somehow.
> 
> Regards,
> 
> Gábor Lipták
> 
> 2014-02-07 Jens Lehmann <Jens.Lehmann@web.de>:
>> Am 07.02.2014 10:15, schrieb Gábor Lipták:
>>> I think I have found a bug related to submodules and directory diff.
>>> See the details at hXXp://stackoverflow.com/q/21623155/337621.
>>
>> Let's inline the recipe one finds after decrypting this link:
>>
>> ~/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
>>
>>
>>> If you need any further details, just ask.
>>
>> - Does this only happen when you use difftool? E.g. what does
>>   "git status" inside the submodule say?
>>
>> - What does "git config core.worktree" print when run in the
>>   submodule?
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fwd: Git Directory Diff for submodule
  2014-02-20 21:03         ` Jens Lehmann
@ 2014-02-20 22:41           ` David Aguilar
  2014-02-21  9:27             ` John Keeping
  0 siblings, 1 reply; 6+ messages in thread
From: David Aguilar @ 2014-02-20 22:41 UTC (permalink / raw)
  To: Jens Lehmann, John Keeping; +Cc: Gábor Lipták, Git Mailing List

On Thu, Feb 20, 2014 at 1:03 PM, Jens Lehmann <Jens.Lehmann@web.de> wrote:
> Sorry for the late reply, but here we go ...
>
> Am 10.02.2014 07:33, schrieb Gábor Lipták:
>> Hi Jens,
>>
>> So "git status" says:
>>
>> liptak@liptak-kubuntu:~/Projects/MAIN_MODULE/platform/SUBMODULE
>> [master]$ git status
>> # On branch master
>> # Your branch is up-to-date with 'origin/master'.
>> #
>> # Changes not staged for commit:
>> #   (use "git add <file>..." to update what will be committed)
>> #   (use "git checkout -- <file>..." to discard changes in working
>> directory)
>> #
>> #       modified:   xxxxxx.java
>> #       modified:   xxxxxxx.java
>> # ...
>> # ...
>> # ...
>> # ...
>> # ...
>> #
>> no changes added to commit (use "git add" and/or "git commit -a")
>>
>> git config core.worktree gives back: "../../../../platform/SUBMODULE"
>
> Which looks a bit strange but is perfectly ok for a repository
> that uses a gitfile, as the core.worktree setting is relative
> to the git directory the gitfile references and not the directory
> the gitfile lives in. A quick glance at the find_worktree
> subroutine in git-difftool.perl makes me think that difftool is
> not aware of that fact. David, does that make sense?

That does make sense. It sounds like that may need to be adjusted.

What does `git rev-parse --show-toplevel` print? It seems like the
find_worktree() logic needs to be extended to handle .git files.

>> The submodule was inited simply with "git submodule init" +
>> "git.submodule update"

Or possibly, as you mention below, it could be that "git submodule
init" ended up writing the wrong core.worktree value. I'm not very
familiar with how they are initialized, but the paths do seem sane, so
I doesn't seem like that's the issue.

If it's a problem in difftool we can probably find a way to do the
right thing. It looks like the core.worktree is relative to the
.git/modules/XXX directory rather than the submodule (and
super-project)'s worktree.

Here's our current logic:

sub find_worktree
{
    my ($repo) = @_;

    # Git->repository->wc_path() does not honor changes to the working
    # tree location made by $ENV{GIT_WORK_TREE} or the 'core.worktree'
    # config variable.
    my $worktree;
    my $env_worktree = $ENV{GIT_WORK_TREE};
    my $core_worktree = Git::config('core.worktree');

    if (defined($env_worktree) and (length($env_worktree) > 0)) {
        $worktree = $env_worktree;
    } elsif (defined($core_worktree) and (length($core_worktree) > 0)) {
        $worktree = $core_worktree;
    } else {
        $worktree = $repo->wc_path();
    }
    return $worktree;
}

John, any thoughts?

>> MAINMODULE/.gitsubmodules file contains similar entry:
>> [submodule "platform/SUBMODULE"]
>> path = platform/SUBMODULE
>> url = ssh://git@somehost/foo/bar.git
>>
>> MAINMODULE/.git/config:
>> [submodule "platform/SUBMODULE"]
>> url = ssh://git@somehost/foo/bar.git
>>
>> MAINMODULE/platform/SUBMODULE/.git:
>> gitdir: ../../.git/modules/platform/SUBMODULE
>>
>> MAINMODULE/.git/modules/platform/SUBMODULE/config:
>> [core]
>> repositoryformatversion = 0
>> filemode = true
>> bare = false
>> logallrefupdates = true
>> worktree = ../../../../platform/SUBMODULE
>> [remote "origin"]
>> url = ssh://git@somehost/foo/bar.git
>> fetch = +refs/heads/*:refs/remotes/origin/*
>>
>> So for me it seems that somehow the relative path inside
>> MAINMODULE/.git/modules/platform/SUBMODULE/config gets configuread
>> wrong during submodule init+update.
>>
>> I tried to update the
>> MAINMODULE/.git/modules/platform/SUBMODULE/config to contain
>> ../../platform/SUBMODULE as worktree path, then meld was correctly
>> started, but the compare tree was not usable. For file changes it
>> displayed always: XXXXX.java: Dangling symlink. So this is still not a
>> complete solution somehow.
>>
>> Regards,
>>
>> Gábor Lipták
>>
>> 2014-02-07 Jens Lehmann <Jens.Lehmann@web.de>:
>>> Am 07.02.2014 10:15, schrieb Gábor Lipták:
>>>> I think I have found a bug related to submodules and directory diff.
>>>> See the details at hXXp://stackoverflow.com/q/21623155/337621.
>>>
>>> Let's inline the recipe one finds after decrypting this link:
>>>
>>> ~/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
>>>
>>>
>>>> If you need any further details, just ask.
>>>
>>> - Does this only happen when you use difftool? E.g. what does
>>>   "git status" inside the submodule say?
>>>
>>> - What does "git config core.worktree" print when run in the
>>>   submodule?
-- 
David

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fwd: Git Directory Diff for submodule
  2014-02-20 22:41           ` David Aguilar
@ 2014-02-21  9:27             ` John Keeping
  0 siblings, 0 replies; 6+ messages in thread
From: John Keeping @ 2014-02-21  9:27 UTC (permalink / raw)
  To: David Aguilar, Petr Baudis
  Cc: Jens Lehmann, Gábor Lipták, Git Mailing List

On Thu, Feb 20, 2014 at 02:41:23PM -0800, David Aguilar wrote:
> On Thu, Feb 20, 2014 at 1:03 PM, Jens Lehmann <Jens.Lehmann@web.de> wrote:
> > Sorry for the late reply, but here we go ...
> >
> > Am 10.02.2014 07:33, schrieb Gábor Lipták:
> >> Hi Jens,
> >>
> >> So "git status" says:
> >>
> >> liptak@liptak-kubuntu:~/Projects/MAIN_MODULE/platform/SUBMODULE
> >> [master]$ git status
> >> # On branch master
> >> # Your branch is up-to-date with 'origin/master'.
> >> #
> >> # Changes not staged for commit:
> >> #   (use "git add <file>..." to update what will be committed)
> >> #   (use "git checkout -- <file>..." to discard changes in working
> >> directory)
> >> #
> >> #       modified:   xxxxxx.java
> >> #       modified:   xxxxxxx.java
> >> # ...
> >> # ...
> >> # ...
> >> # ...
> >> # ...
> >> #
> >> no changes added to commit (use "git add" and/or "git commit -a")
> >>
> >> git config core.worktree gives back: "../../../../platform/SUBMODULE"
> >
> > Which looks a bit strange but is perfectly ok for a repository
> > that uses a gitfile, as the core.worktree setting is relative
> > to the git directory the gitfile references and not the directory
> > the gitfile lives in. A quick glance at the find_worktree
> > subroutine in git-difftool.perl makes me think that difftool is
> > not aware of that fact. David, does that make sense?
> 
> That does make sense. It sounds like that may need to be adjusted.
> 
> What does `git rev-parse --show-toplevel` print? It seems like the
> find_worktree() logic needs to be extended to handle .git files.

Having tried it with a submodule here, it looks like rev-parse gets this
right.

> >> The submodule was inited simply with "git submodule init" +
> >> "git.submodule update"
> 
> Or possibly, as you mention below, it could be that "git submodule
> init" ended up writing the wrong core.worktree value. I'm not very
> familiar with how they are initialized, but the paths do seem sane, so
> I doesn't seem like that's the issue.
> 
> If it's a problem in difftool we can probably find a way to do the
> right thing. It looks like the core.worktree is relative to the
> .git/modules/XXX directory rather than the submodule (and
> super-project)'s worktree.
> 
> Here's our current logic:
> 
> sub find_worktree
> {
>     my ($repo) = @_;
> 
>     # Git->repository->wc_path() does not honor changes to the working
>     # tree location made by $ENV{GIT_WORK_TREE} or the 'core.worktree'
>     # config variable.
>     my $worktree;
>     my $env_worktree = $ENV{GIT_WORK_TREE};
>     my $core_worktree = Git::config('core.worktree');
> 
>     if (defined($env_worktree) and (length($env_worktree) > 0)) {
>         $worktree = $env_worktree;
>     } elsif (defined($core_worktree) and (length($core_worktree) > 0)) {
>         $worktree = $core_worktree;
>     } else {
>         $worktree = $repo->wc_path();
>     }
>     return $worktree;
> }
> 
> John, any thoughts?

I don't really like reimplementing logic from core Git here, so I think
it might be best to just call "git rev-parse --show-toplevel" here; it
would also be sufficient to make sure we resolve $core_worktree against
$GIT_DIR - should we be doing that for $env_worktree as well?  It looks
like git-rev-parse treats a relative GIT_WORK_TREE as relative to the
current working directory, so we're OK there.

Does anyone know why repository->wc_path() does not obey the config
variable or $GIT_WORK_TREE?  It seems like the most correct fix is to
fix it there.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-02-21  9:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAN-m_UmNudmxJnA95h1nYqi7GGxtzKqqpgFHmJZ+MTnxRoEd6g@mail.gmail.com>
     [not found] ` <CAN-m_UnQ7Yzuq7n6mxmsd3XcfLSVxMdnLiGFDiN1Ph3ZiFqwew@mail.gmail.com>
2014-02-07  9:15   ` Fwd: Git Directory Diff for submodule Gábor Lipták
2014-02-07 20:38     ` Jens Lehmann
2014-02-10  7:33       ` Gábor Lipták
2014-02-20 21:03         ` Jens Lehmann
2014-02-20 22:41           ` David Aguilar
2014-02-21  9:27             ` John Keeping

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.