git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jens Lehmann <Jens.Lehmann@web.de>
To: "W. Trevor King" <wking@tremily.us>
Cc: Jonathan Nieder <jrnieder@gmail.com>, Git <git@vger.kernel.org>,
	Peter Collingbourne <peter@pcc.me.uk>
Subject: Re: Moving (renaming) submodules, recipe/script
Date: Tue, 08 Jan 2013 18:12:13 +0100	[thread overview]
Message-ID: <50EC536D.8050606@web.de> (raw)
In-Reply-To: <20130108143214.GA3755@odin.tremily.us>

Am 08.01.2013 15:32, schrieb W. Trevor King:
> On Mon, Jan 07, 2013 at 07:59:53AM +0100, Jens Lehmann wrote:
>> Am 07.01.2013 02:39, schrieb Jonathan Nieder:
>>> (just cc-ing Jens and Peter, who might be interested)
>>
>> I´m currently working on teaching mv to move submodules and intend
>> to send those patches to the list after finishing submodule deinit.
>> Please see
>>   https://github.com/jlehmann/git-submod-enhancements/commits/mv-submodules
>> for the current state of this series.
> 
> Thinking about this a bit more, I'm not clear on how out-of-tree
> updates (i.e. worktree in .git/modules/*/config) propogated during
> branch checkouts (merges, rebases, etc.).  I just got a broken rebase
> trying to move a trivial patch back before the submodule move, and Git
> was confused about what had happened to the submodules.  Here's a
> simple script that illustrates the problem:
> 
>   #!/bin/sh
>   rm -rf a b c
>   mkdir a
>   (cd a
>    git init
>    echo a > README
>    git add README
>    git commit -am 'a'
>   )
>   git clone a b
>   (cd b
>    git submodule add ../a submod-1
>    git commit -am 'add submodule at submod-1'
>   )
>   git clone b c
>   (cd c
>    git submodule update --init
>   )
>   (cd b
>    git-submodule-mv.sh submod-1 submod-2
>    git commit -am 'move submodule from submod-1 to submod-2'
>   )
>   (cd c
>    git pull
>    ls -d .git/modules/*
>    cat .git/modules/submod-1/config
>    ls -a submod*
>   )
> 
> The end result is that `c` gets the `.gitmodules` path updates and new
> gitlinked directory from the submodule move in `b` (using my
> git-submodule-mv.sh posted earlier in this thread), but `submod-1` is
> left lying around (because Git doesn't know that it can remove
> submod-1/.git and submod-1/README).

That's just what current git does with removed submodules (but my
recursive submodule update series will handle that just fine).

>  The Git directory for the
> submodule stays in .git/modules/submod-1/ (good), but the worktree in
> .git/modules/submod-1/config still points to ../../../submod-1 (bad).

You'll not only have to update the gitfile but also the core.worktree
setting in the repo. Sorry I missed that when you posted your script.

> This means that submodule moves are possible, but anyone trying to
> share them between several repositories (or trying to rebase across
> the move within their own repository) is in for a world of suffering
> ;).  I'm not sure how this should be addressed, but I didn't see
> anything handling it in Jens' new series.

If you adjust core.worktree properly you'll just have the old
submodule work tree lying around (just like you do after you rm'd
it) and everything apart from that should just work.

As I mentioned that will be fixed by recursive submodule checkout.
I'll see if I can polish my preliminary branch so that interested
people can play around with it if anyone is interested.

  reply	other threads:[~2013-01-08 17:12 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-07  0:36 Moving (renaming) submodules, recipe/script W. Trevor King
2013-01-07  1:39 ` Jonathan Nieder
2013-01-07  6:59   ` Jens Lehmann
2013-01-07  7:44     ` Junio C Hamano
2013-01-07  8:18       ` Jens Lehmann
2013-01-07 16:08         ` Junio C Hamano
2013-01-07 12:08     ` W. Trevor King
2013-01-08 14:32     ` W. Trevor King
2013-01-08 17:12       ` Jens Lehmann [this message]
2013-01-08 17:48         ` W. Trevor King
2013-02-09 12:32     ` [BUG] can't switch branches with submodules W. Trevor King
2013-02-03 23:38 ` Moving (renaming) submodules, recipe/script W. Trevor King
  -- strict thread matches above, loose matches on Subject: below --
2013-02-09 12:25 [BUG] can't switch branches with submodules Ramkumar Ramachandra
2013-02-03 22:36 [New Feature] git-submodule-move - Easily move submodules TJ
2013-02-04 20:14 ` Jens Lehmann
2012-10-22 12:37 Git submodule for a local branch? W. Trevor King
2012-10-23 13:21 ` W. Trevor King
2012-10-23 20:57 ` Jens Lehmann
2012-10-23 22:09   ` W. Trevor King
2013-01-08 15:59     ` Moving (renaming) submodules, recipe/script W. Trevor King

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50EC536D.8050606@web.de \
    --to=jens.lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    --cc=peter@pcc.me.uk \
    --cc=wking@tremily.us \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).