From: Jens Lehmann <Jens.Lehmann@web.de>
To: Jehan Bing <jehan@orb.com>
Cc: git@vger.kernel.org
Subject: Re: [BUG] Fail to add a module in a subdirectory if module is already cloned
Date: Tue, 24 Jan 2012 22:10:55 +0100 [thread overview]
Message-ID: <4F1F1E5F.2030509@web.de> (raw)
In-Reply-To: <jfmvpp$4v7$1@dough.gmane.org>
Am 24.01.2012 20:11, schrieb Jehan Bing:
> I'm getting an error if I try to add a module in a subdirectory and that module is already cloned.
> Here are the steps to reproduce (git 1.7.8.3):
>
> git init module
> cd module
> echo foo > foo
> git add foo
> git commit -m "init"
> cd ..
> git init super
> cd super
> echo foo > foo
> git add foo
> git commit -m "init"
> git branch b1
> git branch b2
> git checkout b1
> git submodule add ../module lib/module
> git commit -m "module"
> git checkout b2
> rm -rf lib
> git submodule add ../module lib/module
>
> The last command returns:
> fatal: Not a git repository: ../.git/modules/lib/module
> Unable to checkout submodule 'lib/module'
>
> The file lib/modules/.git contains:
> gitdir: ../.git/modules/lib/module
> (missing an additional "../")
>
> In branch b1, after adding the module, the file contained the full path:
> gitdir: /[...]/super/.git/modules/lib/module
> Or contains the correct relative path after checking out b1 later:
> gitdir: ../../.git/modules/lib/module
Thanks for your detailed report, I can reproduce that on current master.
The reason for this bug seems to be that in module_clonse() the name is
not properly initialized for added submodules (it gets set to the path
later), so the correct amount of leading "../"s for the git directory
is not computed properly. The attached diff fixes that for me, I will
send a patch as soon as I have extended a test case for this breakage.
diff --git a/git-submodule.sh b/git-submodule.sh
index 3adab93..9bb2e13 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -131,6 +131,7 @@ module_clone()
gitdir=
gitdir_base=
name=$(module_name "$path" 2>/dev/null)
+ test -n "$name" || name="$path"
base_path=$(dirname "$path")
gitdir=$(git rev-parse --git-dir)
next prev parent reply other threads:[~2012-01-24 21:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-24 19:11 [BUG] Fail to add a module in a subdirectory if module is already cloned Jehan Bing
2012-01-24 21:10 ` Jens Lehmann [this message]
2012-01-24 21:13 ` Jens Lehmann
2012-01-24 21:24 ` Junio C Hamano
2012-01-24 21:44 ` Jens Lehmann
2012-01-24 22:14 ` Jens Lehmann
2012-01-24 22:38 ` Junio C Hamano
2012-01-24 21:49 ` [PATCH] submodule add: fix breakage when re-adding a deep submodule Jens Lehmann
2012-01-25 1:48 ` Jehan Bing
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F1F1E5F.2030509@web.de \
--to=jens.lehmann@web.de \
--cc=git@vger.kernel.org \
--cc=jehan@orb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).