[TYPO3-core] git/gerrit maintain patches stacked on each other - best practice

Christian Kuhn lolli at schwarzbu.ch
Sun Apr 24 14:17:56 CEST 2011

This is a cross-post for core-internal and core to gain attention of all 
affected people, please follow-up to core-list only.


This is a request for a best practice on how to handle, push and 
maintain a set of patches to and from gerrit that depend each other.

I want to make a bigger set of changes that must be pushed through 
gerrit as single issues. While first issues are pushed, updated and 
reviewed in gerrit, I want to work on further patches that depend on the 
first issues.

I think it would be best, if I maintain one branch (?!):
// update current master
git fetch
git pull

// create a branch
git checkout -b refactor-something-branch

/* hack up a first patch, commit, squash, create forge issue */
// push to gerrit
git push origin HEAD:refs/for/master/<issue-id1>

/* hack up a second patch in same branch that depends on first patch,
    first patch was _not_ yet accepted in gerrit. Mark change with
    'Depends: #<issue-id1>' in commit message */
// push to gerrit (is this correct, or will it push _both_ changes now?
git push origin HEAD:refs/for/master/<issue-id2>

/* do the same for other depending issues */

I end up with a branch having something like the following structure:
patch 3 - Change-id 'id3', git-sha1 'git3', not yet pushed to gerrit
patch 2 - Change-id 'id2', git-sha1 'git2', pushed, issue '2'
patch 1 - Change-id 'id1', git-sha1 'git1', pushed, issue '1'
master - latest git-sha1 'git0' when branch was created

Alternative (is this more easy?):
- Create a branch for first issue, push to gerrit
- Create a second branch, based on first branch, push to gerrit
- ...

- Master changes at unrelated places: Which commands are needed to 
rebase my branch(es) to new latest 'git0' version again?

- Master changes at related places, so for example 'patch 1' must be 
changed to apply to master again: Which commands are needed to rebase my 
branch(es) to new latest 'git0' version, how do I push 'patch 1' (and 
only this one) to gerrit again, so that this issue applies to master 
again for someone to review?

- While hacking 'patch 3' I realize that 'patch 1' missed something. I 
fix this and would like to change my 'patch 1' commit accordingly and 
push this again to gerrit. Which commands are needed to commit/amend(?) 
the 'patch 1' commit and to push only this patch to gerrit again?

- Someone reviewed 'patch 1' in gerrit and pushed a new patch set for 
this issue. Which commands are needed to substitute my current patch set 
in the line of patches with the new one that was submitted to gerrit, 
keeping my 'line-of-patches' intact? (Remove my 'patchSet 1' of 'patch 
1' and insert 'patchSet 2' of 'patch 1' at this position).

- A final 'patch 1' was merged to master. How do I tell my branches, 
that this patch is now in master?

I know that some of these questions will result in the same set of 
commands, but I need fool-proof answers to those scenarios, otherwise 
hacking up patches 'on-top-of-others' that are not merged yet will 
become pita.

Hoping for answers by git gurus ;)

More information about the TYPO3-team-core mailing list