           oid: oid
           path: newPath
           fileSize: buffer.length
-          mode: patch.newFile().mode()
+          mode: fileDiff.getMode()
 
       data.index.removeByPath(oldPath) if oldPath != newPath
       data.index.add(entry)

          blob?.toString()
    .then (content) =>
      newContent = JsDiff.applyPatch(content or '', patchText)
      if !newContent and patch.isAdded()
        @unstagePath(newPath)
      else
        buffer = new Buffer(newContent)

    patchText = "#{header}#{lines.join("\n")}\n"
    Promise.resolve(patchText)

  stagePatch: (fileDiff, patchText) =>
    data = {}
    oldPath = fileDiff.getOldPathName()
    newPath = fileDiff.getNewPathName()
    Git.Repository.open(@repoPath)
    .then (repo) ->
      data.repo = repo
      repo.openIndex()
    .then (index) =>
      data.index = index
      @indexBlob(oldPath) unless fileDiff.isUntracked()
    .then (content) =>
      newContent = JsDiff.applyPatch(content ? '', patchText)
      console.log patchText, newContent
      buffer = new Buffer(newContent)
      oid    = data.repo.createBlobFromBuffer(buffer)

      if fileDiff.isDeleted()
        entry = data.index.getByPath(oldPath)
        entry.id = oid
        entry.fileSize = buffer.length
