All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* git submodule ignores --git-dir
@ 2015-09-10 20:06 Filip Gospodinov
  2015-09-11 15:15 ` Jens Lehmann
  0 siblings, 1 reply; 5+ messages in thread
From: Filip Gospodinov @ 2015-09-10 20:06 UTC (permalink / raw)
  To: git

Hi!

I use the `--git-dir` flag in some scripts such that I don't need to `cd` back
and forth. Recently, I've discovered that `--git-dir` does not seem to work
correctly for `git submodule`. Here is a short snippet to reproduce that behavior:

mkdir repo1 subm
(cd subm; git init; git commit -m 1 --allow-empty)
(cd repo1; git init; git submodule add ../subm subm; git commit -m "add subm")
git clone repo1 repo2
git --git-dir=$PWD/repo2/.git submodule update --init


which errors with the following output:

No submodule mapping found in .gitmodules for path 'subm'

But this works:
cd repo2; git --git-dir=$PWD/.git submodule update --init


I know that for this particular use case I can just use `git clone --recursive`
and that other use cases can be worked around by using `cd`. Still, I wonder if
the behavior I discovered is a bug or if it's expected.

git --version
git version 2.5.1

Thanks you!
Filip

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

* git submodule ignores --git-dir
@ 2015-09-10 20:06 Filip Gospodinov
  0 siblings, 0 replies; 5+ messages in thread
From: Filip Gospodinov @ 2015-09-10 20:06 UTC (permalink / raw)
  To: git

Hi!

I use the `--git-dir` flag in some scripts such that I don't need to `cd` back
and forth. Recently, I've discovered that `--git-dir` does not seem to work
correctly for `git submodule`. Here is a short snippet to reproduce that behavior:

mkdir repo1 subm
(cd subm; git init; git commit -m 1 --allow-empty)
(cd repo1; git init; git submodule add ../subm subm; git commit -m "add subm")
git clone repo1 repo2
git --git-dir=$PWD/repo2/.git submodule update --init


which errors with the following output:

No submodule mapping found in .gitmodules for path 'subm'

But this works:
cd repo2; git --git-dir=$PWD/.git submodule update --init


I know that for this particular use case I can just use `git clone --recursive`
and that other use cases can be worked around by using `cd`. Still, I wonder if
the behavior I discovered is a bug or if it's expected.

git --version
git version 2.5.1

Thanks you!
Filip

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

* Re: git submodule ignores --git-dir
  2015-09-10 20:06 git submodule ignores --git-dir Filip Gospodinov
@ 2015-09-11 15:15 ` Jens Lehmann
  2015-09-11 15:28   ` John Keeping
  0 siblings, 1 reply; 5+ messages in thread
From: Jens Lehmann @ 2015-09-11 15:15 UTC (permalink / raw)
  To: Filip Gospodinov, git

Am 10.09.2015 um 22:06 schrieb Filip Gospodinov:
> Hi!
>
> I use the `--git-dir` flag in some scripts such that I don't need to `cd` back
> and forth. Recently, I've discovered that `--git-dir` does not seem to work
> correctly for `git submodule`. Here is a short snippet to reproduce that behavior:
>
> mkdir repo1 subm
> (cd subm; git init; git commit -m 1 --allow-empty)
> (cd repo1; git init; git submodule add ../subm subm; git commit -m "add subm")
> git clone repo1 repo2
> git --git-dir=$PWD/repo2/.git submodule update --init
>
>
> which errors with the following output:
>
> No submodule mapping found in .gitmodules for path 'subm'
>
> But this works:
> cd repo2; git --git-dir=$PWD/.git submodule update --init

Thanks for your report containing a nice recipe to reproduce your issue!

> I know that for this particular use case I can just use `git clone --recursive`
> and that other use cases can be worked around by using `cd`. Still, I wonder if
> the behavior I discovered is a bug or if it's expected.

I don't think this is a bug. The git submodule command needs a work tree
to read the .gitmodules file from, that's while it fails when using
--git-dir from outside the work tree. But I admit that the error message
"No submodule mapping found in .gitmodules for path ..." could be improved
to clearly state that the .gitmodules file wasn't found.

Unfortunately trying to show git the right work tree:

$ git --git-dir=$PWD/repo2/.git --work-tree=$PWD/repo2 submodule update --init

Didn't work as I expected it to either:

fatal: /home/Sledge/libexec/git-core/git-submodule cannot be used without a working tree.

So you'll have to cd into the repo for now.

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

* Re: git submodule ignores --git-dir
  2015-09-11 15:15 ` Jens Lehmann
@ 2015-09-11 15:28   ` John Keeping
  2015-09-14 13:25     ` Filip Gospodinov
  0 siblings, 1 reply; 5+ messages in thread
From: John Keeping @ 2015-09-11 15:28 UTC (permalink / raw)
  To: Jens Lehmann; +Cc: Filip Gospodinov, git

On Fri, Sep 11, 2015 at 05:15:52PM +0200, Jens Lehmann wrote:
> Am 10.09.2015 um 22:06 schrieb Filip Gospodinov:
> > I know that for this particular use case I can just use `git clone --recursive`
> > and that other use cases can be worked around by using `cd`. Still, I wonder if
> > the behavior I discovered is a bug or if it's expected.
> 
> I don't think this is a bug. The git submodule command needs a work tree
> to read the .gitmodules file from, that's while it fails when using
> --git-dir from outside the work tree. But I admit that the error message
> "No submodule mapping found in .gitmodules for path ..." could be improved
> to clearly state that the .gitmodules file wasn't found.
> 
> Unfortunately trying to show git the right work tree:
> 
> $ git --git-dir=$PWD/repo2/.git --work-tree=$PWD/repo2 submodule update --init
> 
> Didn't work as I expected it to either:
> 
> fatal: /home/Sledge/libexec/git-core/git-submodule cannot be used without a working tree.
> 
> So you'll have to cd into the repo for now.

There's also "git -C /path/to/repo" which avoids the need for a separate
"cd".

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

* Re: git submodule ignores --git-dir
  2015-09-11 15:28   ` John Keeping
@ 2015-09-14 13:25     ` Filip Gospodinov
  0 siblings, 0 replies; 5+ messages in thread
From: Filip Gospodinov @ 2015-09-14 13:25 UTC (permalink / raw)
  To: John Keeping, Jens Lehmann; +Cc: Filip Gospodinov, git

On 11.09.2015 17:15, Jens Lehmann wrote:
> Unfortunately trying to show git the right work tree:
>
> $ git --git-dir=$PWD/repo2/.git --work-tree=$PWD/repo2 submodule update --init
>
> Didn't work as I expected it to either:
>
> fatal: /home/Sledge/libexec/git-core/git-submodule cannot be used without a
> working tree.

Yes, that's confusing. I'm not sure how other commands use the --work-tree flag
and if having the git-submodule script `cd` into the work tree would be
acceptable. What do you think?

On 11.09.2015 17:28, John Keeping wrote:
> There's also "git -C /path/to/repo" which avoids the need for a separate
> "cd".
> 

Thank you, that works!

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

end of thread, other threads:[~2015-09-14 13:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-10 20:06 git submodule ignores --git-dir Filip Gospodinov
2015-09-11 15:15 ` Jens Lehmann
2015-09-11 15:28   ` John Keeping
2015-09-14 13:25     ` Filip Gospodinov
  -- strict thread matches above, loose matches on Subject: below --
2015-09-10 20:06 Filip Gospodinov

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.