Git development
 help / color / mirror / Atom feed
* More help needed on merging unrelated repos
@ 2008-11-04 13:14 Christian MICHON
  2008-11-04 20:12 ` Andreas Ericsson
  0 siblings, 1 reply; 8+ messages in thread
From: Christian MICHON @ 2008-11-04 13:14 UTC (permalink / raw)
  To: Git Mailing List

Hi,

I previously posted here a question on how to merge unrelated repos,
and I was quite happy with the answer.
git pull repo_name repo_branch

Yet, when I merge these repos (they're unrelated), I'd like to merge
all of them at once.

How do I pull for example 2 repos in 1 command ? I cannot figure out
the exact syntax to use.

I tried:
git pull ../i1 0.5 ../i2 master
git pull ../i1 0.5 -- ../i2 master

I also tried to play with --no-commit and -s to no avail.

Does anyone of you already use this and knows the trick ? Thanks in advance!

-- 
Christian
--
http://detaolb.sourceforge.net/, a linux distribution for Qemu with Git inside !

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

* Re: More help needed on merging unrelated repos
  2008-11-04 13:14 More help needed on merging unrelated repos Christian MICHON
@ 2008-11-04 20:12 ` Andreas Ericsson
  2008-11-04 21:08   ` Christian MICHON
  0 siblings, 1 reply; 8+ messages in thread
From: Andreas Ericsson @ 2008-11-04 20:12 UTC (permalink / raw)
  To: Christian MICHON; +Cc: Git Mailing List

Christian MICHON wrote:
> Hi,
> 
> I previously posted here a question on how to merge unrelated repos,
> and I was quite happy with the answer.
> git pull repo_name repo_branch
> 
> Yet, when I merge these repos (they're unrelated), I'd like to merge
> all of them at once.
> 
> How do I pull for example 2 repos in 1 command ? I cannot figure out
> the exact syntax to use.
> 
> I tried:
> git pull ../i1 0.5 ../i2 master
> git pull ../i1 0.5 -- ../i2 master
> 
> I also tried to play with --no-commit and -s to no avail.
> 
> Does anyone of you already use this and knows the trick ? Thanks in advance!
> 

You can only pull from a single repository at a time. The first way of doing
what you want that comes to mind is:

  git remote add lib1 lib1url
  git remote add lib2 lib2url
  git fetch lib1 && git fetch lib2 && git merge lib1/master lib2/master

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

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

* Re: More help needed on merging unrelated repos
  2008-11-04 20:12 ` Andreas Ericsson
@ 2008-11-04 21:08   ` Christian MICHON
  2008-11-04 22:04     ` Andreas Ericsson
  0 siblings, 1 reply; 8+ messages in thread
From: Christian MICHON @ 2008-11-04 21:08 UTC (permalink / raw)
  To: Andreas Ericsson; +Cc: Git Mailing List

Andreas Ericsson wrote:
> Christian MICHON wrote:
>>
>> Hi,
>>
>> I previously posted here a question on how to merge unrelated repos,
>> and I was quite happy with the answer.
>> git pull repo_name repo_branch
>>
>> Yet, when I merge these repos (they're unrelated), I'd like to merge
>> all of them at once.
>>
>> How do I pull for example 2 repos in 1 command ? I cannot figure out
>> the exact syntax to use.
>>
>> I tried:
>> git pull ../i1 0.5 ../i2 master
>> git pull ../i1 0.5 -- ../i2 master
>>
>> I also tried to play with --no-commit and -s to no avail.
>>
>> Does anyone of you already use this and knows the trick ? Thanks in
>> advance!
>>
>
> You can only pull from a single repository at a time. The first way of doing
> what you want that comes to mind is:
>
>  git remote add lib1 lib1url
>  git remote add lib2 lib2url
>  git fetch lib1 && git fetch lib2 && git merge lib1/master lib2/master
>
> --
> Andreas Ericsson                   andreas.ericsson@op5.se
> OP5 AB                             www.op5.se
> Tel: +46 8-230225                  Fax: +46 8-230231
>

and apparently this strategy (which I tried before too :( ) fails when merging.

example:
repo i1 contains file 'a'
repo i2 contains file 'b'
new repo z contains file 'readme' and I want to pull repo i1 and i2 at
the same time inside repo z.

typically, I've to pull 1 repo at a time, if I use pull. If I fetch
both without merge, and then I try a merge, it fails.
maybe I'm on a wild goose chase after all.

thanks
-- 
Christian
--
http://detaolb.sourceforge.net/, a linux distribution for Qemu with Git inside !

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

* Re: More help needed on merging unrelated repos
  2008-11-04 21:08   ` Christian MICHON
@ 2008-11-04 22:04     ` Andreas Ericsson
  2008-11-04 22:30       ` Christian MICHON
  0 siblings, 1 reply; 8+ messages in thread
From: Andreas Ericsson @ 2008-11-04 22:04 UTC (permalink / raw)
  To: Christian MICHON; +Cc: Git Mailing List

Christian MICHON wrote:
> Andreas Ericsson wrote:
>> Christian MICHON wrote:
>>> Hi,
>>>
>>> I previously posted here a question on how to merge unrelated repos,
>>> and I was quite happy with the answer.
>>> git pull repo_name repo_branch
>>>
>>> Yet, when I merge these repos (they're unrelated), I'd like to merge
>>> all of them at once.
>>>
>>> How do I pull for example 2 repos in 1 command ? I cannot figure out
>>> the exact syntax to use.
>>>
>>> I tried:
>>> git pull ../i1 0.5 ../i2 master
>>> git pull ../i1 0.5 -- ../i2 master
>>>
>>> I also tried to play with --no-commit and -s to no avail.
>>>
>>> Does anyone of you already use this and knows the trick ? Thanks in
>>> advance!
>>>
>> You can only pull from a single repository at a time. The first way of doing
>> what you want that comes to mind is:
>>
>>  git remote add lib1 lib1url
>>  git remote add lib2 lib2url
>>  git fetch lib1 && git fetch lib2 && git merge lib1/master lib2/master
>>
>> --
>> Andreas Ericsson                   andreas.ericsson@op5.se
>> OP5 AB                             www.op5.se
>> Tel: +46 8-230225                  Fax: +46 8-230231
>>
> 
> and apparently this strategy (which I tried before too :( ) fails when merging.
> 
> example:
> repo i1 contains file 'a'
> repo i2 contains file 'b'
> new repo z contains file 'readme' and I want to pull repo i1 and i2 at
> the same time inside repo z.
> 
> typically, I've to pull 1 repo at a time, if I use pull. If I fetch
> both without merge, and then I try a merge, it fails.
> maybe I'm on a wild goose chase after all.
> 

Ah, right. Octopus merge always does merge head reduction, but to do
that it needs to find a common ancestor. When no such ancestor exists,
it will fail (with a message like "shouldn't be doing octopus merge"?).

If there's no "--no-reduce-heads" option to "git merge", I think you're
screwed with getting that to happen in a single commit.

Oh wait.

git merge i1 && git merge --no-commit i2 && git commit --amend

might work. I'm still shooting from the hip though, and now it's far too
late for me to think more. gl though.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

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

* Re: More help needed on merging unrelated repos
  2008-11-04 22:04     ` Andreas Ericsson
@ 2008-11-04 22:30       ` Christian MICHON
  2008-11-06  8:37         ` Karl Hasselström
  0 siblings, 1 reply; 8+ messages in thread
From: Christian MICHON @ 2008-11-04 22:30 UTC (permalink / raw)
  To: Andreas Ericsson; +Cc: Git Mailing List

On Tue, Nov 4, 2008 at 11:04 PM, Andreas Ericsson <ae@op5.se> wrote:
> Ah, right. Octopus merge always does merge head reduction, but to do
> that it needs to find a common ancestor. When no such ancestor exists,
> it will fail (with a message like "shouldn't be doing octopus merge"?).
>
> If there's no "--no-reduce-heads" option to "git merge", I think you're
> screwed with getting that to happen in a single commit.

:(

>
> Oh wait.
>
> git merge i1 && git merge --no-commit i2 && git commit --amend
>
> might work. I'm still shooting from the hip though, and now it's far too
> late for me to think more. gl though.
>

it's late for me too!

$ git merge i1/master
Merge made by recursive.
 a |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 a

$ git merge --no-commit i2/master
Automatic merge went well; stopped before committing as requested

$ git commit --amend
fatal: You are in the middle of a merge -- cannot amend.

note the merge can work, but it's still done in 2 steps. :(
thanks for suggesting this.

-- 
Christian
--
http://detaolb.sourceforge.net/, a linux distribution for Qemu with Git inside !

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

* Re: More help needed on merging unrelated repos
  2008-11-04 22:30       ` Christian MICHON
@ 2008-11-06  8:37         ` Karl Hasselström
  2008-11-06 12:13           ` Christian MICHON
  0 siblings, 1 reply; 8+ messages in thread
From: Karl Hasselström @ 2008-11-06  8:37 UTC (permalink / raw)
  To: Christian MICHON; +Cc: Andreas Ericsson, Git Mailing List

On 2008-11-04 23:30:56 +0100, Christian MICHON wrote:

> note the merge can work, but it's still done in 2 steps. :(
> thanks for suggesting this.

If it had worked, you'd have gotten just one merge commit. What you
want to do is entirely possible, but it seems the high-level commands
were not designed with your use-case in mind.

Another thing you could try is to merge the two branches separately,
getting a history like this:

  p1----\
         \
  p2---A--B
      /
  p3--

And then use grafts to convince git that B has parents p1, p2, and p3
(instead of its actual parents p1 and A). (Grep for "graft" in the
Documentation directory.)

And then use git-filter-branch to rewrite history so that the grafted
history becomes the real history.

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

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

* Re: More help needed on merging unrelated repos
  2008-11-06  8:37         ` Karl Hasselström
@ 2008-11-06 12:13           ` Christian MICHON
  2008-11-06 15:28             ` Karl Hasselström
  0 siblings, 1 reply; 8+ messages in thread
From: Christian MICHON @ 2008-11-06 12:13 UTC (permalink / raw)
  To: Karl Hasselström; +Cc: Andreas Ericsson, Git Mailing List

On Thu, Nov 6, 2008 at 9:37 AM, Karl Hasselström <kha@treskal.com> wrote:
> On 2008-11-04 23:30:56 +0100, Christian MICHON wrote:
>
>> note the merge can work, but it's still done in 2 steps. :(
>> thanks for suggesting this.
>
> If it had worked, you'd have gotten just one merge commit. What you
> want to do is entirely possible, but it seems the high-level commands
> were not designed with your use-case in mind.
>
> Another thing you could try is to merge the two branches separately,
> getting a history like this:
>
>  p1----\
>         \
>  p2---A--B
>      /
>  p3--
>
> And then use grafts to convince git that B has parents p1, p2, and p3
> (instead of its actual parents p1 and A). (Grep for "graft" in the
> Documentation directory.)
>
> And then use git-filter-branch to rewrite history so that the grafted
> history becomes the real history.
>
> --
> Karl Hasselström, kha@treskal.com
>      www.treskal.com/kalle
>

nice suggestion Karl! it took a while to understand all the
consequences and workflow.
On top of your suggestion, I had to remove the
refs/original/refs/heads/master and the grafts file.

It worked well: quite a spell, but an efficient one. Kudo++

-- 
Christian
--
http://detaolb.sourceforge.net/, a linux distribution for Qemu with Git inside !

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

* Re: More help needed on merging unrelated repos
  2008-11-06 12:13           ` Christian MICHON
@ 2008-11-06 15:28             ` Karl Hasselström
  0 siblings, 0 replies; 8+ messages in thread
From: Karl Hasselström @ 2008-11-06 15:28 UTC (permalink / raw)
  To: Christian MICHON; +Cc: Andreas Ericsson, Git Mailing List

On 2008-11-06 13:13:42 +0100, Christian MICHON wrote:

> nice suggestion Karl! it took a while to understand all the
> consequences and workflow. On top of your suggestion, I had to
> remove the refs/original/refs/heads/master and the grafts file.

I've never tried to use git-filter-branch, so I was deliberately
vague. I was hoping you would be the enterprising type who would
figure out the details anyway ... ;-)

> It worked well: quite a spell, but an efficient one. Kudo++

Well, that's Git for you. Once you get the (really simple) underlying
data model you know what _can_ be done, even if it's not always
obvious _how_ to do it.

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

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

end of thread, other threads:[~2008-11-06 15:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-04 13:14 More help needed on merging unrelated repos Christian MICHON
2008-11-04 20:12 ` Andreas Ericsson
2008-11-04 21:08   ` Christian MICHON
2008-11-04 22:04     ` Andreas Ericsson
2008-11-04 22:30       ` Christian MICHON
2008-11-06  8:37         ` Karl Hasselström
2008-11-06 12:13           ` Christian MICHON
2008-11-06 15:28             ` Karl Hasselström

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox