# Pushing git patches to a subversion project

2 messages from 2005-12-21 to 2005-12-21. Participants: Martin Langhoff, Junio C Hamano.
Thread: https://gitlist.dev/t/2891

## Martin Langhoff, 2005-12-21 05:37

Subject: Pushing git patches to a subversion project
Message-ID: <46a038f90512202137w772a3fe9p8e9e68345e39654a@mail.gmail.com>
URL: https://gitlist.dev/e/46a038f90512202137w772a3fe9p8e9e68345e39654a%40mail.gmail.com

```
I am starting to work an svn-based upstream. In order to make life
easy for me and for them I am trying to figure out a way for them to
be able to merge my (emailed) patches atomically and preserving my
comments.

Something like git-am for svn.

Ideally, it should keep the patch as free of corruption as possible,
as the results will be echoed back into my branches via git-svnimport
and later "cg-update upstream" and I want git-cherry to have a fair go
at matching them.

There doesn't seem to be much. SVN-based projects ask for unified
diffs mostly, and I can't find indication of patch trading that
includes commit messages.

Any hints?

cheers,


martin

```

## Junio C Hamano, 2005-12-21 07:25

Subject: Re: Pushing git patches to a subversion project
Message-ID: <7vpsnqdi8w.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vpsnqdi8w.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <46a038f90512202137w772a3fe9p8e9e68345e39654a@mail.gmail.com>

```
Martin Langhoff <martin.langhoff@gmail.com> writes:

> I am starting to work an svn-based upstream. In order to make life
> easy for me and for them I am trying to figure out a way for them to
> be able to merge my (emailed) patches atomically and preserving my
> comments.
>
> Something like git-am for svn.

Many building blocks git-am uses should be usable for this.

 * git-mailsplit you already know about due to earlier "non UNIX
   mbox" discussion.

 * git-mailinfo can be used to parse out commit message, title
   and authorship information, and actual patch.

 * git-apply without --index option can be used to apply patch
   to the working tree, but normal "patch -p1" would do the same
   unless it is a git renaming patch.  git-apply would also be
   useful for its --summary option to find out mode changes
   (if it is a git patch) and file creation and deletion.

So probably you could script something like this:

	$ git mailinfo .msg .patch <e-mail-file >.info
        $ (sed -ne 's/^Subject: //p' .info ; echo ; cat .msg) >.final-msg
	$ git apply --summary <.patch |
        while read cd mo de file
        do
        	case "$cd" in
                create)
                	svn add "$file" ;;
		delete)
                	svn rm "$file" ;;
		esac
	done
	$ svn commit -F .final-msg

```
