anchor.diff:          final newCommitSha = pr.stdout.trim();
           ctx.info('Create new commit: $newCommitSha');
   
  +        final branchNameRef = 'refs/heads/$targetBranch';
  +
           return gitDir.runCommand(['update-ref', branchNameRef, newCommitSha]);
         })
         .then((ProcessResult pr) {
  
positive.code: Future<bool> _withExistingBranch(TaskContext ctx, BranchReference targetBranchRef, String dirSha,
      String sourceDir, List<String> gitArgs, String sourceBranch, String targetBranch, GitDir gitDir) {
  
    final lastCommitSha = targetBranchRef.sha;
  
    return gitDir.getCommit(lastCommitSha)
        .then((Commit commitObj) =>
            _continueWithExistingBranch(ctx, lastCommitSha, commitObj.treeSha, dirSha, sourceDir,
                gitArgs, sourceBranch, targetBranch, gitDir));
  }
  
  Future<bool> _continueWithExistingBranch(TaskContext ctx,
      String parent, String parentTree, String dirSha, String sourceDir,
      List<String> gitArgs, String sourceBranch, String targetBranch, GitDir gitDir) {
    if(parentTree == dirSha) {
      ctx.fine('There have been no changes to "$sourceDir" since the last commit');
      return new Future.immediate(true);
    } else {
      gitArgs.addAll(['-p', parent]);
      return _goCommit(ctx, 'updated', gitArgs, sourceBranch, sourceDir,
          targetBranch, gitDir);
    }
  }
  
  Future<bool> _goCommit(TaskContext ctx, String verb, List<String> gitArgs,
      String sourceBranch, String sourceDir, String targetBranch, GitDir gitDir) {
  
    final branchNameRef = 'refs/heads/$targetBranch';
  
    return gitDir.getBranchReference(sourceBranch)
        .then((BranchReference branchRef) {
  
negative.code: 
    final gitDir = new GitDir(workingDir);
  
    List<String> gitArgs;
    String sourceDirTreeSha;
  
    return gitDir.lsTree(sourceBranch, subTreesOnly: true, path: sourceDir)
        .then((List<TreeEntry> entries) {
          assert(entries.length <= 1);
          if(entries.isEmpty) {
            throw 'Could not find a matching dir on the provided branch';
          }
  
          final tree = entries.single;
  
          sourceDirTreeSha = tree.sha;
  
          gitArgs = ['commit-tree', sourceDirTreeSha];
  
          return gitDir.getBranchReference(targetBranch);
        })
        .then((BranchReference branchRef) {
  
          if(branchRef == null) {
            // branch does not exist. New branch!
            return _doCommit(ctx, 'created', gitArgs, sourceBranch, sourceDir,
                targetBranch, gitDir);
          } else {
            // existing branch, need to find the tree info so we can create
            // a valid commit w/ the right parent
            return _withExistingBranch(ctx, branchRef, sourceDirTreeSha, sourceDir,
                gitArgs, sourceBranch, targetBranch, gitDir);
          }
        });
  }
  