All of lore.kernel.org
 help / color / mirror / Atom feed
From: Clemens Buchacher <drizzd@aon.at>
To: Geoffrey Lee <geoffreyj.lee@gmail.com>
Cc: Jeff King <peff@peff.net>, git@vger.kernel.org
Subject: Re: How to create patches for a merge?
Date: Sat, 20 Feb 2010 18:39:10 +0100	[thread overview]
Message-ID: <20100220173910.GA4095@localhost> (raw)
In-Reply-To: <83d7aaa41002190225o3255248re1581a86e1346f28@mail.gmail.com>

On Fri, Feb 19, 2010 at 02:25:14AM -0800, Geoffrey Lee wrote:
> On Thu, Feb 18, 2010 at 12:37 PM, Jeff King <peff@peff.net> wrote:
> > On Thu, Feb 18, 2010 at 03:40:07AM -0800, Geoffrey Lee wrote:
> >
> >> When I use "git format-patch", it doesn't seem to include merges. How
> >> can I perform a merge and then e-mail it to someone as a set of
> >> patches?
> >
> > Is it important that it be patches, or simply that it go over email? In
> > the latter case, you can use "git bundle" to create a set of commits,
> > including merges, and send them to the remote.
> 
> I was not aware of "git bundle". That does exactly what I need. Thanks!

Below is git-send-bdl, a small wrapper I use for git bundle. It creates
bundles only for the commits which are not already known to the origin and
mails them to a configured address. It requires mutt for sending emails (the
-m option is just for show).  It should probably use sendmail. But maybe
this is still useful as a reference.

Have fun,
Clemens
---

#!/bin/bash

usage ()
{
	echo "`basename $0`: [-t <address>] [-m <mailer>] [-r <remote>] [<repo>...]" >&2
	exit 1
}

if ! test -x `which getopt`
then
	echo "fatal: getopt required but not found" >&2
	exit 2
fi

OPT=`getopt -o et:m:r: -- "$@"`
code=$?
if test $code -gt 0
then
	usage
	exit 1
fi
eval set -- "$OPT"

mailer=${GIT_SEND_BDL_MAILER:-mutt}
remote=origin
addr=
edit=
while test "$1" != "--"
do
	case "$1" in
		-r) remote="$2"; shift;;
		-m) mailer="$2"; shift;;
		-t) addr="$addr $2"; shift;;
		-e) edit=YesPlease;;
		-h) usage;;
		*) echo "unkown option: $1" >&2; exit 2;;
	esac
	shift
done
shift

if test -z $addr
then
	addr="$GIT_SEND_BDL_TO"
fi

if test $# -eq 0
then
	cdup=`git rev-parse --show-cdup 2>/dev/null`
	if test $? -gt 0
	then
		echo "fatal: no repositories specified and none found" >&2
		usage
	fi
	set -- "$PWD/${cdup}"
fi

if test -z "$addr"
then
	echo "fatal: no recipients specified" >&2
	usage
fi

if ! test -x `which $mailer`
then
	echo "fatal: mailer not found: $mailer" >&2
	usage
fi

bundle=()
while test $# -gt 0
do
	path=$1
	shift
	cd $path
	name=`basename "$PWD"`
	echo " * $name"
	target=/tmp/${name}.git
	if ! git remote | grep -q "^$remote\$"
	then
		echo error: unknown remote: $remote >&2
		continue
	fi
	refs="--branches"
	remote_refs=`git show-ref | cut -f2 -d' ' | \
			grep ^refs/remotes/$remote/`
	if test -n "$remote_refs"
	then
		refs="$refs --not $remote_refs"
	fi
	refs="$refs --tags"
	git bundle create $target $refs
	cd - >/dev/null
	bundle[${#bundle[@]}]=$target
done

attachments=
for i in ${bundle[@]}
do
	if test -f $i
	then
		attachments="$attachments $i"
	fi
done

exec 3</dev/null
if test -n "$edit"
then
	exec 3<&0
fi
$mailer -s 'git bundles' -a $attachments -- $addr <&3
ret=$?
exec 3<&-
if test $ret -gt 0
then
	echo "fatal: mailer exited with status $ret" >&2
	exit 1
fi

rm -f ${bundle[@]}

      reply	other threads:[~2010-02-20 17:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-18 11:40 How to create patches for a merge? Geoffrey Lee
2010-02-18 18:10 ` Junio C Hamano
2010-02-18 20:37 ` Jeff King
2010-02-19 10:25   ` Geoffrey Lee
2010-02-20 17:39     ` Clemens Buchacher [this message]

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=20100220173910.GA4095@localhost \
    --to=drizzd@aon.at \
    --cc=geoffreyj.lee@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /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.