git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Björn Steinbrink" <B.Steinbrink@gmx.de>
To: Sam Granieri Jr <sjgdev@gmail.com>
Cc: Git Users List <git@vger.kernel.org>
Subject: Re: [Feature Request] Better Subversion integration
Date: Sun, 10 Feb 2008 04:56:11 +0100	[thread overview]
Message-ID: <20080210035611.GA2454@atjola.homenet> (raw)
In-Reply-To: <FC5B6F22-27A9-4F0F-85EE-0B72B94C69E2@gmail.com>

On 2008.02.09 20:44:59 -0600, Sam Granieri Jr wrote:
> Right now, git-svn import (or clone) will convert tags and branches as  
> remote branches.
> I would like it if git could pick up subversion tags and translate them 
> as git tags upon importing

SVN tags aren't like git tags. A "tag" in SVN is just another directory,
which you can modify at will. Yeah, I know, you _should_ not commit any
changes to SVN "tags", but shit happens. And once you modify the "tag"
in SVN, you would have to invalidate the git tag, and finding a commit
that matches the SVN state of things is probably way too expensive to be
practical. Maybe some --we-never-mess-up-svn-tag-alike-branches could
be added to allow git-svn to create teal git tags though? Dunno, I don't
care much. Shouldn't be too hard to find some shell magic to create
tags, if one wants them.

> I also have some concerns with git-svn dcommit
>
> Would it be possible for git-svn dcommit to convert locally created git 
> tags to subversion tags? How about branches?

Didn't need to convert tags yet, but I have a small shell script that
does branching for me (see below). What it does, is to simply look at
the history and figure out the first commit that exists in SVN. Then it
invokes the svn program and creates a branch in SVN, starting at that
commit. Then you can just fetch that branch, rebase your work and commit
away. Writing a similar hack for tags shouldn't be too hard.

For example (assuming that you saved the script as git-svn-branch):
git checkout -b my_branch remotes/trunk
// work work work
.oO( Hm, maybe I should put that into a SVN branch for foobar reason )
git-svn-branch my_branch
git svn fetch
git rebase --onto remotes/my_branch remotes/trunk my_branch
git svn dcommit -n # This should now (pretend to) dcommit to my_branch

One thing it gets wrong (probably, never tried) is that it will take the
wrong starting point when you cherry-picked a commit from another SVN
branch and didn't remove the git-svn-id line. That is because it doesn't
make use of the .rev_map files and thus cannot figure out if the
git-svn-id line is actually valid.

IIRC git-svn should handle such cherry-picks gracefully, so
integrating that thing with git-svn would have some benefits, but I
don't speak any perl. Maybe someone else wants to take the job?

HTH
Björn


#!/bin/sh
if test "$1" = ''
then
	echo "Usage: git-svn-branch <branch_name>"
	exit 127
fi

CURRENT=$(git rev-list --first-parent --pretty=format:%b HEAD | grep -m1 -o 'git-svn-id: [^ ]*' | sed -e 's/git-svn-id: //')

SRC=${CURRENT%@*}
REV=${CURRENT#*@}
URL=$(git config --get svn-remote.svn.url)

URL=$(echo -n "$URL" | sed -e 's!//.*@!//!')
DST="$URL/$(git config --get svn-remote.svn.branches | grep -o '^[^:]*' | sed -e "s/\*/$1/")"

svn cp -r "$REV" "$SRC" "$DST" -m "Create branch $1"

  reply	other threads:[~2008-02-10  3:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-10  2:44 [Feature Request] Better Subversion integration Sam Granieri Jr
2008-02-10  3:56 ` Björn Steinbrink [this message]
2008-02-10 16:52   ` Michael Haggerty
2008-02-10 17:53     ` Björn Steinbrink
2008-02-10 19:36       ` Michael Haggerty
2008-02-10 22:18         ` Björn Steinbrink
2008-02-11  8:47   ` Sebastian Harl
2008-02-11 16:55     ` Sam Granieri Jr
2008-02-11 22:11       ` Sebastian Harl
2008-02-15 22:38     ` Jan Hudec

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=20080210035611.GA2454@atjola.homenet \
    --to=b.steinbrink@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=sjgdev@gmail.com \
    /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 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).