git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to change a submodue as a subdirectory?
@ 2007-11-14 14:37 Ping Yin
  2007-11-14 20:26 ` Alex Riesen
  0 siblings, 1 reply; 7+ messages in thread
From: Ping Yin @ 2007-11-14 14:37 UTC (permalink / raw)
  To: Git Mailing List

I have a super project superA, and a submodue subB. Now i decide to
switch subB from submodule to sub directory. Any good way to do that
and not losing any history?

-- 
Ping Yin

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

* Re: How to change a submodue as a subdirectory?
  2007-11-14 14:37 How to change a submodue as a subdirectory? Ping Yin
@ 2007-11-14 20:26 ` Alex Riesen
  2007-11-15  5:36   ` Ping Yin
  0 siblings, 1 reply; 7+ messages in thread
From: Alex Riesen @ 2007-11-14 20:26 UTC (permalink / raw)
  To: Ping Yin; +Cc: Git Mailing List

Ping Yin, Wed, Nov 14, 2007 15:37:57 +0100:
> I have a super project superA, and a submodue subB. Now i decide to
> switch subB from submodule to sub directory. Any good way to do that
> and not losing any history?

$ mv subB sub
$ git add sub
$ git update-index --force-remove subB
$ git commit

Which history were you afraid of losing?

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

* Re: How to change a submodue as a subdirectory?
  2007-11-14 20:26 ` Alex Riesen
@ 2007-11-15  5:36   ` Ping Yin
  2007-11-15  6:16     ` Johannes Schindelin
  0 siblings, 1 reply; 7+ messages in thread
From: Ping Yin @ 2007-11-15  5:36 UTC (permalink / raw)
  To: Alex Riesen; +Cc: Git Mailing List

On Nov 15, 2007 4:26 AM, Alex Riesen <raa.lkml@gmail.com> wrote:
> Ping Yin, Wed, Nov 14, 2007 15:37:57 +0100:
> > I have a super project superA, and a submodue subB. Now i decide to
> > switch subB from submodule to sub directory. Any good way to do that
> > and not losing any history?
>
> $ mv subB sub
> $ git add sub
> $ git update-index --force-remove subB
> $ git commit
>
> Which history were you afraid of losing?
>
I want to keep the history of the submodule



-- 
Ping Yin

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

* Re: How to change a submodue as a subdirectory?
  2007-11-15  5:36   ` Ping Yin
@ 2007-11-15  6:16     ` Johannes Schindelin
  2007-11-15  8:14       ` Ping Yin
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Schindelin @ 2007-11-15  6:16 UTC (permalink / raw)
  To: Ping Yin; +Cc: Alex Riesen, Git Mailing List

Hi,

On Thu, 15 Nov 2007, Ping Yin wrote:

> On Nov 15, 2007 4:26 AM, Alex Riesen <raa.lkml@gmail.com> wrote:
> > Ping Yin, Wed, Nov 14, 2007 15:37:57 +0100:
> > > I have a super project superA, and a submodue subB. Now i decide to
> > > switch subB from submodule to sub directory. Any good way to do that
> > > and not losing any history?
> >
> > $ mv subB sub
> > $ git add sub
> > $ git update-index --force-remove subB
> > $ git commit
> >
> > Which history were you afraid of losing?
> >
> I want to keep the history of the submodule

Provided you do not kill the repository of the submodule (you have some 
public repo for that, right?) you will not lose anything, since the 
history of the superproject has pointers to the submodule.

But I guess that you want something different... You probably want to 
rewrite history as if the submodule had not been a submodule at all, 
right?

Ciao,
Dscho

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

* Re: How to change a submodue as a subdirectory?
  2007-11-15  6:16     ` Johannes Schindelin
@ 2007-11-15  8:14       ` Ping Yin
  2007-11-15 12:28         ` Johannes Schindelin
  0 siblings, 1 reply; 7+ messages in thread
From: Ping Yin @ 2007-11-15  8:14 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Alex Riesen, Git Mailing List

On Nov 15, 2007 2:16 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> Provided you do not kill the repository of the submodule (you have some
> public repo for that, right?) you will not lose anything, since the
> history of the superproject has pointers to the submodule.
>
> But I guess that you want something different... You probably want to
> rewrite history as if the submodule had not been a submodule at all,
> right?
Yeah, this actually what i want. Now i find a way:
1. move submodule subB outside
    mv subB /newpath/to/subB
    git-commit subB
2. git-filter-branch to rename all files in subA repository to subB
directory (say subB/subB).

       cd newpath/to/subB &&
       git filter-branch --index-filter \
               'git ls-files -s | sed "s-\t-&subB/-" |
                       GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
                               git update-index --index-info &&
                mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD
3. in directory of super project superA, git-fetch repository subB to
branch subB
   cd path/to/superA && git-fetch /newpath/to/subB master:subB
4. git-cherry-pick each commit  (except the root commit) of branch
subB to the super project superA
    git-cherry HEAD subB | awk '{print $2}' | sed -n '2,$ p' | while
read name; do git cherry-pick $name; done
>
> Ciao,
> Dscho
>
>



-- 
Ping Yin

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

* Re: How to change a submodue as a subdirectory?
  2007-11-15  8:14       ` Ping Yin
@ 2007-11-15 12:28         ` Johannes Schindelin
  2007-11-15 16:41           ` Ping Yin
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Schindelin @ 2007-11-15 12:28 UTC (permalink / raw)
  To: Ping Yin; +Cc: Alex Riesen, Git Mailing List

Hi,

On Thu, 15 Nov 2007, Ping Yin wrote:

> On Nov 15, 2007 2:16 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > Provided you do not kill the repository of the submodule (you have some
> > public repo for that, right?) you will not lose anything, since the
> > history of the superproject has pointers to the submodule.
> >
> > But I guess that you want something different... You probably want to
> > rewrite history as if the submodule had not been a submodule at all,
> > right?
>
> Yeah, this actually what i want. Now i find a way:

If this works for you, I am all the more happy for you.  I thought that 
you wanted to be able to go to a certain revision and get the same working 
directory/directories.  (But that is not what you get...)

> 1. move submodule subB outside
>     mv subB /newpath/to/subB
>     git-commit subB

Strictly speaking, you do not have to move it outside.

> 2. git-filter-branch to rename all files in subA repository to subB
> directory (say subB/subB).
> 
>        cd newpath/to/subB &&
>        git filter-branch --index-filter \
>                'git ls-files -s | sed "s-\t-&subB/-" |
>                        GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
>                                git update-index --index-info &&
>                 mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD

No need to play games with GIT_INDEX_FILE, as far as I can tell.

> 3. in directory of super project superA, git-fetch repository subB to
> branch subB
>    cd path/to/superA && git-fetch /newpath/to/subB master:subB

If you plan to do away with subB, you do not need to specify it... Just 
use FETCH_HEAD, directly after the fetch.

> 4. git-cherry-pick each commit  (except the root commit) of branch
> subB to the super project superA
>     git-cherry HEAD subB | awk '{print $2}' | sed -n '2,$ p' | while
> read name; do git cherry-pick $name; done

The git-cherry call is not really necessary, right?  The two repos have no 
common history (not even common patches).

Besides, I think that what you did is just a complicated way of doing a 
rebase.

But be aware that checking out older versions of the superproject will 
still have the submodule!

Ciao,
Dscho

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

* Re: How to change a submodue as a subdirectory?
  2007-11-15 12:28         ` Johannes Schindelin
@ 2007-11-15 16:41           ` Ping Yin
  0 siblings, 0 replies; 7+ messages in thread
From: Ping Yin @ 2007-11-15 16:41 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Alex Riesen, Git Mailing List

On Nov 15, 2007 8:28 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

>
> > 1. move submodule subB outside
> >     mv subB /newpath/to/subB
> >     git-commit subB
>
> Strictly speaking, you do not have to move it outside.
Hmm, you're right. I can just just remove it after fetch subB as a
branch of superA.
>
> > 2. git-filter-branch to rename all files in subA repository to subB
> > directory (say subB/subB).
> >
> >        cd newpath/to/subB &&
> >        git filter-branch --index-filter \
> >                'git ls-files -s | sed "s-\t-&subB/-" |
> >                        GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
> >                                git update-index --index-info &&
> >                 mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD
>
> No need to play games with GIT_INDEX_FILE, as far as I can tell.
I just follow the example of git-filter-branch manual page. If not
using GIT_INDEX_FILE.new, the GIT_INDEX_FILE will be read and wirtten
at the same time since it is read and writtern at the same in a pipe.
Will this be ok?
>
> > 3. in directory of super project superA, git-fetch repository subB to
> > branch subB
> >    cd path/to/superA && git-fetch /newpath/to/subB master:subB
>
> If you plan to do away with subB, you do not need to specify it... Just
> use FETCH_HEAD, directly after the fetch.
Hmm, using FETCH_HEAD is really better.

> The git-cherry call is not really necessary, right?  The two repos have no
> common history (not even common patches).
>
> Besides, I think that what you did is just a complicated way of doing a
> rebase.
I tried rebase, wonderful!

>
> Ciao,
> Dscho
>
>



-- 
Ping Yin

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

end of thread, other threads:[~2007-11-15 16:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-14 14:37 How to change a submodue as a subdirectory? Ping Yin
2007-11-14 20:26 ` Alex Riesen
2007-11-15  5:36   ` Ping Yin
2007-11-15  6:16     ` Johannes Schindelin
2007-11-15  8:14       ` Ping Yin
2007-11-15 12:28         ` Johannes Schindelin
2007-11-15 16:41           ` Ping Yin

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).