Factored out commit behavior from branch to support external undo/redo
support.

Signed-off-by: Jakob Brandsborg Ehmsen <jakobehmsen.github@gmail.com>