How-to Commit

If you are a committer, feel free to pick any process that works for you - so long as you are planning to commit the work yourself.

Here is how committing and merging typically look for merging and pushing for tickets that follow the convention (if patch-based). A hypothetical CASSANDRA-12345 ticket used in the example is a cassandra-3.0 based bug fix that requires different code for cassandra-3.3, and trunk. Contributor Jackie is supplying a patch for the root branch (12345-3.0.patch), and patches for the remaining branches (12345-3.3.patch, 12345-trunk.patch).

On cassandra-3.0
  1. git am -3 12345-3.0.patch (if we have a problem b/c of CHANGES.txt not merging anymore, we modify it ourselves, in place)

On cassandra-3.3
  1. git merge cassandra-3.0 -s ours

  2. git apply -3 12345-3.3.patch (likely to have an issue with CHANGES.txt here: modify it ourselves, then git add CHANGES.txt)

  3. git commit -amend

On trunk
  1. git merge cassandra-3.3 -s ours

  2. git apply -3 12345-trunk.patch (likely to have an issue with CHANGES.txt here: modify it ourselves, then git add CHANGES.txt)

  3. git commit -amend

On any branch
  1. git push origin cassandra-3.0 cassandra-3.3 trunk -atomic

Same scenario, but a branch-based contribution:

On cassandra-3.0
  1. git cherry-pick <sha-of-3.0-commit> (if we have a problem b/c of CHANGES.txt not merging anymore, we modify it ourselves, in place)

On cassandra-3.3
  1. git merge cassandra-3.0 -s ours

  2. git format-patch -1 <sha-of-3.3-commit>

  3. git apply -3 <sha-of-3.3-commit>.patch (likely to have an issue with CHANGES.txt here: modify it ourselves, then git add CHANGES.txt)

  4. git commit -amend

On trunk
  1. git merge cassandra-3.3 -s ours

  2. git format-patch -1 <sha-of-trunk-commit>

  3. git apply -3 <sha-of-trunk-commit>.patch (likely to have an issue with CHANGES.txt here: modify it ourselves, then git add CHANGES.txt)

  4. git commit -amend

On any branch
  1. git push origin cassandra-3.0 cassandra-3.3 trunk -atomic

Notes on git flags

The -3 flag used with git am or git apply will instruct git to perform a 3-way merge. If a conflict is detected, you can either resolve it manually or invoke git mergetool.

The -atomic flag to git push does the obvious thing: pushes all or nothing. Without the flag, the command is equivalent to running git push once per each branch. This is nifty if a race condition occurs - you won’t push half the branches, blocking other committers’ progress while you are resolving the issue.

Tip

The fastest way to get a patch from someone’s commit in a branch on github if you don’t have their repo in remote, is to append .patch to the commit url: curl -O github.com/apache/cassandra/commit/7374e9b5ab08c1f1e612bf72293ea14c959b0c3c.patch