                 (format "Revert %d file%s? " (length files) (if (> (length files) 1) "s" ""))))
       (dolist (info files)
         (case (git-fileinfo->state info)
-          ('added (push info added))
-          ('deleted (push info modified))
-          ('unmerged (push info modified))
-          ('modified (push info modified))))
+          ('added (push (git-fileinfo->name info) added))
+          ('deleted (push (git-fileinfo->name info) modified))
+          ('unmerged (push (git-fileinfo->name info) modified))
+          ('modified (push (git-fileinfo->name info) modified))))
       (when added
-          (apply #'git-run-command nil nil "update-index" "--force-remove" "--" (git-get-filenames added))
-          (git-set-files-state added 'unknown))
+        (apply #'git-run-command nil nil "update-index" "--force-remove" "--" added))
       (when modified
-          (apply #'git-run-command nil nil "checkout" "HEAD" (git-get-filenames modified))
-          (git-set-files-state modified 'uptodate))
-      (git-refresh-files))))
+        (apply #'git-run-command nil nil "checkout" "HEAD" modified))
+      (git-update-status-files (append added modified) 'uptodate))))
 
 (defun git-resolve-file ()
   "Resolve conflicts in marked file(s)."
   (interactive)
-  (let ((files (git-marked-files-state 'unmerged)))
+  (let ((files (git-get-filenames (git-marked-files-state 'unmerged))))
     (when files
-      (apply #'git-run-command nil nil "update-index" "--" (git-get-filenames files))
-      (git-set-files-state files 'modified)
-      (git-refresh-files))))
+      (apply #'git-run-command nil nil "update-index" "--" files)
+      (git-update-status-files files 'uptodate))))
 
 (defun git-remove-handled ()
   "Remove handled files from the status list."

(defun git-add-file ()
  "Add marked file(s) to the index cache."
  (interactive)
  (let ((files (git-marked-files-state 'unknown)))
    (unless files
      (push (ewoc-data
             (git-add-status-file 'added (file-relative-name
                                          (read-file-name "File to add: " nil nil t))))
            files))
    (apply #'git-run-command nil nil "update-index" "--info-only" "--add" "--" (git-get-filenames files))
    (git-set-files-state files 'added)
    (git-refresh-files)))

(defun git-ignore-file ()
  "Add marked file(s) to the ignore list."
  (interactive)
  (let ((files (git-marked-files-state 'unknown)))
    (unless files
      (push (ewoc-data
             (git-add-status-file 'unknown (file-relative-name
                                            (read-file-name "File to ignore: " nil nil t))))
            files))
    (dolist (info files) (git-append-to-ignore (git-fileinfo->name info)))
    (git-set-files-state files 'ignored)
    (git-refresh-files)))

(defun git-remove-file ()
  "Remove the marked file(s)."
  (interactive)
  (let ((files (git-marked-files-state 'added 'modified 'unknown 'uptodate)))
    (unless files
      (push (ewoc-data
             (git-add-status-file 'unknown (file-relative-name
                                            (read-file-name "File to remove: " nil nil t))))
            files))
    (if (yes-or-no-p
         (format "Remove %d file%s? " (length files) (if (> (length files) 1) "s" "")))
        (progn
          (dolist (info files)
            (let ((name (git-fileinfo->name info)))
              (when (file-exists-p name) (delete-file name))))
          (apply #'git-run-command nil nil "update-index" "--info-only" "--remove" "--" (git-get-filenames files))
          ; remove unknown files from the list, set the others to deleted
          (ewoc-filter git-status
                       (lambda (info files)
                         (not (and (memq info files) (eq (git-fileinfo->state info) 'unknown))))
                       files)
          (git-set-files-state files 'deleted)
          (git-refresh-files)
          (unless (ewoc-nth git-status 0)  ; refresh header if list is empty
            (git-refresh-ewoc-hf git-status)))
      (message "Aborting"))))

(defun git-revert-file ()

         (pos (ewoc-locate status))
         (cur-name (and pos (git-fileinfo->name (ewoc-data pos)))))
    (unless status (error "Not in git-status buffer."))
    (git-run-command nil nil "update-index" "--refresh")
    (git-clear-status status)
    (git-update-status-files nil)
    ; move point to the current file name if any
    (let ((node (and cur-name (git-find-status-file status cur-name))))
      (when node (ewoc-goto-node status node)))))
