All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrey Smirnov <allter@gmail.com>
To: git@vger.kernel.org
Subject: Re: [PATCH/RFC 1/2] Add 'git subtree' command for tracking history of 	subtrees separately.
Date: Thu, 16 Jul 2009 18:04:26 +0000 (UTC)	[thread overview]
Message-ID: <loom.20090716T160021-218@post.gmane.org> (raw)
In-Reply-To: 32541b130904300732i691800f5kecc2f845584071c1@mail.gmail.com

Hello!

Avery Pennarun <apenwarr> writes:

> d) Merge upstream changes of shared module:
>       git subtree pull --prefix=shared-dir shared-remote master
>     or
>       git fetch shared-remote master
>       git subtree merge --prefix=shared-dir FETCH_HEAD

I found the git-subtree aproach of handling sub-repositories very interesting 
and useful to me. This is the previous-to-last feature I've awaited from DVCS
world since I went into it. <remark> The remaining feature I wish that's not 
already there is the ability to automatically track the tree of repos I work
with and manage this tree as simple as filemanager-style clients 
like Tortoise SVN allow. This is a feature like submodules, but with tracking
refs, remotes and remote URIs in a repo itself rather than in .git dirs
and with different commands for propagation and display of changesets). 
Hope someone has time to try this approach (or at least patience to discuss).
</remark>

I've just used git-subtree (latest github version) and it worked for me. 
However I've encountered some difficulty using it for my purpose and wish
to shere the solution I've come to and ask if it is ok:

My goal was to rebase changes to shared library of two similar projects from one
project to another. The commits in the more recent project were touching both
lib/ directory with shared library and the rest of the project.

When I did 
   git subtree split --prefix=lib NewProj -b test-split
 and
   git subtree split --prefix=lib OldProj -b test-split-old
I got the following two trees without a common root:

...X ----- Y ----- OldProj ----...---- Z ---- NewProj

X' ----- Y'==test-split-old ----- Z'==test-split

Problem:

When I did
   git subtree merge test-split --prefix=lib
it printed:
 Auto-merged lib/x.cgi
 CONFLICT (add/add): Merge conflict in lib/x.cgi
 Auto-merged lib/y.cgi
 CONFLICT (add/add): Merge conflict in lib/y.cgi
 Automatic merge failed; fix conflicts and then commit the result.

It's obvious that it should be that way because logically both trees don't have
the same root at the time of merge. But I've expected subtree merge --prefix
will understand that X' is identical to changes to 'lib/*' in X, Y' to Y and Z'
to Z.

Solution: 

    git rebase --onto OldProj test-split-old test-split
it printed:
 First, rewinding head to replay your work on top of it...
 Applying ZZZZZ
 error: x.cgi: does not exist in index
 error: y.cgi: does not exist in index
 Using index info to reconstruct a base tree...
 Falling back to patching base and 3-way merge...

I don't know what magic it used but it did rebase right. Furthermore "-s
subtree" didn't work at all:
    git rebase --onto OldProj test-split-old test-split -s subtree
 First, rewinding head to replay your work on top of it...
 Fast-forwarded OldProj to OldProj.

And so I ask if this behavior is the way git-subtree was meant to work.
It probably has sense to add 'rebase' command to git-subtree script to let
perform such tasks simplier.

My best regards, Andrey Smirnov.

  reply	other threads:[~2009-07-16 18:10 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-26 22:29 [PATCH/RFC 1/2] Add 'git subtree' command for tracking history of subtrees separately Avery Pennarun
2009-04-26 22:29 ` [PATCH/RFC 2/2] Automated test script for 'git subtree' Avery Pennarun
2009-04-30  2:27 ` [PATCH/RFC 1/2] Add 'git subtree' command for tracking history of subtrees separately Avery Pennarun
2009-04-30  3:44   ` Ping Yin
2009-04-30  8:58   ` Finn Arne Gangstad
2009-04-30 14:32     ` Avery Pennarun
2009-07-16 18:04       ` Andrey Smirnov [this message]
2009-07-16 18:34         ` Avery Pennarun
2009-07-16 22:09           ` Andrey Smirnov
2009-07-16 22:27             ` Avery Pennarun
2009-07-17  7:16               ` Andrey Smirnov
2009-07-17 15:47                 ` Avery Pennarun
2009-07-17 17:46                   ` Andrey Smirnov

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=loom.20090716T160021-218@post.gmane.org \
    --to=allter@gmail.com \
    --cc=git@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.