git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [BUG] Fail to add a module in a subdirectory if module is already cloned

From
Jens Lehmann <jens.lehmann@web.de>
Date
Jan 24, 2012, 21:44 UTC
Message-ID
<4F1F2642.1070707@web.de>
In-Reply-To
<7vhazk3ibk.fsf@alter.siamese.dyndns.org>
Am 24.01.2012 22:24, schrieb Junio C Hamano:
Show 25 quoted lines
> Jens Lehmann <Jens.Lehmann@web.de> writes:
> 
>> 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"
> 
> This somehow smells like sweeping a problem under the rug. Why doesn't
> module_name find the already registered path in the first place?
> 
> I see "module_name" calls "git config -f .gitmodules" and I do not see any
> cd_to_toplevel in git-submodule.sh that would ensure this call to access
> the gitmodules file at the top-level of the superproject. Is that the real
> reason why it is not finding what it should be finding?
Nope, it's the fact that the .gitmodules file doesn't contain this name
because the branch was rewound. Please see my post where I proposed the
same change for a slightly different problem:
  http://permalink.gmane.org/gmane.comp.version-control.git/187823
(just fast forward to the first hunk of my diff at the end)

I just didn't realize back then that this is needed even without the other changes to work properly. The possibly missing cd_to_toplevel is another problem, the OP started the submodule add in the top level directory anyways.

Previous: Junio C HamanoNext: Jens Lehmann
Message 5 of 9 in “[BUG] Fail to add a module in a subdirectory if module is already cloned”
  1. Jehan BingJan 24, 2012
  2. Jens LehmannJan 24, 2012
  3. Jens LehmannJan 24, 2012
  4. Junio C HamanoJan 24, 2012
  5. Jens LehmannJan 24, 2012
  6. Jens LehmannJan 24, 2012
  7. Junio C HamanoJan 24, 2012
  8. submodule add: fix breakage when re-adding a deep submoduleJens Lehmann, Jan 24, 2012
  9. Jehan BingJan 25, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.