// Make commit and rollback functions for a specific repo where we will
// be messing with the branches.
func branchCheckpointer(r *git.Repo) (commit, rollback func(chan<- bool)) {
	// We only care about branch refernces, and we only want to save
	// the SHA references to the branches.
	refs := make(map[string]string)
	for _, ref := range r.Branches() {
		refs[ref.Name()] = ref.SHA
	}
	// There is no commit action.
	commit = noopCommit
	// On rollback, force all the branches back to where we were.
	rollback = func(c chan<- bool) {
		res := true
		for name, sha := range refs {
			cmd, _, _ := r.Git("branch", "-f", name, sha)
			res = res && (cmd.Run() == nil)
		}
		c <- res

	}
	return
}