Subject: Re: Centralized processes in git

From: Jan Hudec <[email-masked]>
Date: Mon, 20 Aug 2007 21:29:47 +0200

On Mon, Aug 20, 2007 at 13:30:47 -0500, Robert Boone wrote:
> Hello,
>     My company is looking at git to replace subversion as our scm. We have 
> a small team of developers which need to publish to a centralized 
> repository. One thing we would like is to have an automated bug fix merge 
> ability. So if I make a bug fix to master we want that fix to be merged 
> into other branches that we set. If there is a conflict we want that person 
>  to be notified by email or some other way. I would like to know if anyone 
> on the list has a good way to implement this?

Normal way of pushing changes to the central repo is over the ssh protocol,
which invokes git (specifically git-receive-pack) on the server and that in
turn invokes pre-receive, update, post-receive and post-update hooks. The
first two can prevent the refs to be updated, the later two are for arbitrary
post-processing.

To do the automatic merging like you describe, you'd probably put up
a script to run from post-receive and start whatever merges you want to do.

That script gets a list of updated refs along with new and old version names
on standard input, so you just look for your mainline name (refs/heads/master
probably) and if you find, run the appropriate merges. You can of course
program whatever notifications you want in that script.

Commit would undo any changes pushed between checking out a branch and
commiting, so you should probably do the merges on a separate repository,
that will only be managed by the scripts. You can use the alternates
mechanism to avoid duplicating the data if that repository will be on the
central server.

I'd recommend the hook script to write the things to just write the
instructions what to merge somewhere (into a named pipe, probably -- or
socket, which could be extended to separate server) and process that with
a continually running "daemon" script, to avoid synchronization issues.

In git distribution is a pair of scripts in contrib/continuous directory,
that use the notifying hook + daemon approach to run tests against each
commit, so you can use that for inspiration. It's in perl and being universal
complicates it quite a bit though; you can get a lot shorter with shell and
everything hardcoded.

-- 
						 Jan 'Bulb' Hudec <[email-masked]>