git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* git-svn and local only topic branch
@ 2007-05-01 16:40 Guilhem Bonnefille
  2007-05-01 16:45 ` Adam Roben
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Guilhem Bonnefille @ 2007-05-01 16:40 UTC (permalink / raw
  To: git

Hi,

I'm using Git as a SVN frontend (via git-svn). Recently, I made a
topic branch, I did some job on it and wish to "upload" my work (on
the SVN). But, I do not want "pushing" all commits, I only want to
create a single commit on the SVN, while keeping full commits on my
Git repo. But I did not find how to do this.

Here my story.
Let's call "upstream" the local branch connected to the SVN, the raw
SVN mirror branch is remotes/upstream. Now, I create a branch "topic"
from "upstream" and I do job:

o--o--o (upstream, remotes/upstream)
         \
          o--o--o--o (topic)

I want the following result:

o--o--o-------------- o (upstream, remotes/upstream)
         \             /
          o--o--o--o (topic)

So I did "git-merge "Merge" upstream topic". But, the merge action
decided to do a fast-forward. It's not correct because I really don't
want to "pollute" the SVN with all my commits.

So I rewinded and I did "git-merge --squash "Merge" upstream topic".
This time, it seems to work as I obtained a single commit on upstream
branch. But this commit does not have ancestry link with the topic
branch. Here is it:

o--o--o--o (upstream, remotes/upstream)
         \
          o--o--o--o (topic)

Is there a way to do what I want?

-- 
Guilhem BONNEFILLE
-=- #UIN: 15146515 JID: guyou@im.apinc.org MSN: guilhem_bonnefille@hotmail.com
-=- mailto:guilhem.bonnefille@gmail.com
-=- http://nathguil.free.fr/

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

* Re: git-svn and local only topic branch
  2007-05-01 16:40 git-svn and local only topic branch Guilhem Bonnefille
@ 2007-05-01 16:45 ` Adam Roben
  2007-05-01 17:30   ` Guilhem Bonnefille
  2007-05-01 18:29 ` Andy Parkins
  2007-05-02 19:06 ` Steven Grimm
  2 siblings, 1 reply; 6+ messages in thread
From: Adam Roben @ 2007-05-01 16:45 UTC (permalink / raw
  To: Guilhem Bonnefille; +Cc: git

On May 1, 2007, at 9:40 AM, Guilhem Bonnefille wrote:

> Hi,
>
> I'm using Git as a SVN frontend (via git-svn). Recently, I made a
> topic branch, I did some job on it and wish to "upload" my work (on
> the SVN). But, I do not want "pushing" all commits, I only want to
> create a single commit on the SVN, while keeping full commits on my
> Git repo. But I did not find how to do this.

    If you just want to make a commit to Subversion containing all the  
changes on your branch, then you should be able to do this:

git svn commit-diff upstream topic

    That will take the entire diff between upstream and your topic  
branch and make one commit to Subversion containing that diff.

-Adam

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

* Re: git-svn and local only topic branch
  2007-05-01 16:45 ` Adam Roben
@ 2007-05-01 17:30   ` Guilhem Bonnefille
  0 siblings, 0 replies; 6+ messages in thread
From: Guilhem Bonnefille @ 2007-05-01 17:30 UTC (permalink / raw
  To: Adam Roben; +Cc: git

On 5/1/07, Adam Roben <aroben@apple.com> wrote:
> On May 1, 2007, at 9:40 AM, Guilhem Bonnefille wrote:
> > I'm using Git as a SVN frontend (via git-svn). Recently, I made a
> > topic branch, I did some job on it and wish to "upload" my work (on
> > the SVN). But, I do not want "pushing" all commits, I only want to
> > create a single commit on the SVN, while keeping full commits on my
> > Git repo. But I did not find how to do this.
>
>     If you just want to make a commit to Subversion containing all the
> changes on your branch, then you should be able to do this:
>
> git svn commit-diff upstream topic
>
>     That will take the entire diff between upstream and your topic
> branch and make one commit to Subversion containing that diff.

Yes, I want to make a single commit on Subversion containing all the
changes of my topic branch. But I also want to keep track of this
"merge" in my local Git repo. So I want that the new commit on my
upstream branch store an ancestry with both upstream and topic
branches.

I fear that "commit-diff" will only produce a commit on SVN, that will
be stored as a single and normal commit on my (local) upstream branch.

-- 
Guilhem BONNEFILLE
-=- #UIN: 15146515 JID: guyou@im.apinc.org MSN: guilhem_bonnefille@hotmail.com
-=- mailto:guilhem.bonnefille@gmail.com
-=- http://nathguil.free.fr/

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

* Re: git-svn and local only topic branch
  2007-05-01 16:40 git-svn and local only topic branch Guilhem Bonnefille
  2007-05-01 16:45 ` Adam Roben
@ 2007-05-01 18:29 ` Andy Parkins
  2007-05-02 19:06 ` Steven Grimm
  2 siblings, 0 replies; 6+ messages in thread
From: Andy Parkins @ 2007-05-01 18:29 UTC (permalink / raw
  To: git; +Cc: Guilhem Bonnefille

On Tuesday 2007, May 01, Guilhem Bonnefille wrote:

> o--o--o--o (upstream, remotes/upstream)
>          \
>           o--o--o--o (topic)
>
> Is there a way to do what I want?

No.  Subversion doesn't do merge tracking.  What you're asking for would 
require that.  While git-svn is good, it cannot give subversion 
abilities it doesn't have.

It's an easy trap to fall into because git makes it so easy that you can 
forget that not everyone else can do it.



Andy
-- 
Dr Andy Parkins, M Eng (hons), MIET
andyparkins@gmail.com

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

* Re: git-svn and local only topic branch
  2007-05-01 16:40 git-svn and local only topic branch Guilhem Bonnefille
  2007-05-01 16:45 ` Adam Roben
  2007-05-01 18:29 ` Andy Parkins
@ 2007-05-02 19:06 ` Steven Grimm
  2007-05-03 11:24   ` Guilhem Bonnefille
  2 siblings, 1 reply; 6+ messages in thread
From: Steven Grimm @ 2007-05-02 19:06 UTC (permalink / raw
  To: Guilhem Bonnefille; +Cc: git

Guilhem Bonnefille wrote:
> I want the following result:
>
> o--o--o-------------- o (upstream, remotes/upstream)
>         \             /
>          o--o--o--o (topic)

I did something similar recently:

http://www.spinics.net/lists/git/msg29119.html

The secret is to do a squash merge (git merge --squash) and commit that 
as a single revision onto the branch you commit into svn.

1--2--3------------4 (upstream)
       \
        A--B--C--D   (topic)

As far as git's history is concerned, at this point you have a topic 
branch with a bunch of commits ABCD, and an upstream branch with a bunch 
of commits 1234. Revision 4 has the contents of ABCD but is not marked 
as a merge in git's revision history, which means git-svn won't be 
confused since it doesn't know how to follow merges.

Now you do git svn dcommit to commit revision 4, which shows up as one 
commit on the svn side. git-svn will delete your revision 4 and create a 
new one whose comment includes the svn revision ID, so you'll have:

1--2--3------------4' (upstream)
       \
        A--B--C--D    (topic)

Since git-svn will never look earlier than revision 4' to figure out 
which svn revision it should use as a basis for future svn commits, you 
can do whatever you want with the history up to revision 4'. In 
particular, you can use git's "grafts" feature to fake git into thinking 
that a merge actually took place.

Open .git/info/grafts in your favorite editor and add a line with three 
SHA-1 hashes:

hash-of-4' hash-of-3 hash-of-D

Now as far as git is concerned you have the history you want:

1--2--3------------4' (upstream)
       \          /
        A--B--C--D    (topic)

Subsequent merges on the git side, whether they're squashed or not, will 
know about the merge you've just done.

In his reply to my script, Junio correctly pointed out that all this 
fiddling really ought to be happening in git-svn itself; it ought to 
know that you've done a merge and should record that fact directly in 
the metadata for 4' rather than treating it as a single-parent commit. 
If you do the above a zillion times you'll end up with a huge grafts 
file which is not so clean. But as a stopgap measure, this does work 
adequately.

-Steve

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

* Re: git-svn and local only topic branch
  2007-05-02 19:06 ` Steven Grimm
@ 2007-05-03 11:24   ` Guilhem Bonnefille
  0 siblings, 0 replies; 6+ messages in thread
From: Guilhem Bonnefille @ 2007-05-03 11:24 UTC (permalink / raw
  To: Steven Grimm; +Cc: git

On 5/2/07, Steven Grimm <koreth@midwinter.com> wrote:
> In his reply to my script, Junio correctly pointed out that all this
> fiddling really ought to be happening in git-svn itself; it ought to
> know that you've done a merge and should record that fact directly in
> the metadata for 4' rather than treating it as a single-parent commit.
> If you do the above a zillion times you'll end up with a huge grafts
> file which is not so clean. But as a stopgap measure, this does work
> adequately.

Yes, it's seems just fine. Thanks for the tips.

I'm not aware with the internal Git's features. As grafts seems to be
a quick hack, is it posible to imagine that, after git-svn rewrited 4
in 4', an other tool rewrites (completly) the commit to produce a 4"
with 2 parents?

-- 
Guilhem BONNEFILLE
-=- #UIN: 15146515 JID: guyou@im.apinc.org MSN: guilhem_bonnefille@hotmail.com
-=- mailto:guilhem.bonnefille@gmail.com
-=- http://nathguil.free.fr/

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

end of thread, other threads:[~2007-05-03 11:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-01 16:40 git-svn and local only topic branch Guilhem Bonnefille
2007-05-01 16:45 ` Adam Roben
2007-05-01 17:30   ` Guilhem Bonnefille
2007-05-01 18:29 ` Andy Parkins
2007-05-02 19:06 ` Steven Grimm
2007-05-03 11:24   ` Guilhem Bonnefille

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