     (goto-char (point-min))
     (let (unmerged-files)
       (while (re-search-forward "[0-7]\\{6\\} [0-9a-f]\\{40\\} [123]\t\\([^\0]+\\)\0" nil t)
-        (let ((node (git-find-status-file status (match-string 1))))
-          (when node (push (ewoc-data node) unmerged-files))))
-      (git-set-files-state unmerged-files 'unmerged))))
+        (push (match-string 1) unmerged-files))
+      (git-set-filenames-state status unmerged-files 'unmerged))))
 
 (defun git-get-exclude-files ()
   "Get the list of exclude files to pass to git-ls-files."

              (new-name (match-string 8)))
          (if new-name  ; copy or rename
              (if (eq ?C (string-to-char state))
                  (git-insert-fileinfo status (git-create-fileinfo 'added new-name old-perm new-perm 'copy name) refresh)
                (git-insert-fileinfo status (git-create-fileinfo 'deleted name 0 0 'rename new-name) refresh)
                (git-insert-fileinfo status (git-create-fileinfo 'added new-name old-perm new-perm 'rename name)) refresh)
            (git-insert-fileinfo status (git-create-fileinfo (git-state-code state) name old-perm new-perm) refresh))
          (setq files (delete name files))
          (when new-name (setq files (delete new-name files)))))))
  files)

(defun git-find-status-file (status file)
  "Find a given file in the status ewoc and return its node."

      (setf (git-fileinfo->orig-name info) nil)
      (setf (git-fileinfo->needs-refresh info) t))))

(defun git-set-filenames-state (status files state)
  "Set the state of a list of named files."
  (when files
    (setq files (sort files #'string-lessp))
    (let ((file (pop files))
          (node (ewoc-nth status 0)))
      (while (and file node)
        (let ((info (ewoc-data node)))
          (cond ((string-lessp (git-fileinfo->name info) file)
                 (setq node (ewoc-next status node)))
                ((string-equal (git-fileinfo->name info) file)
                 (unless (eq (git-fileinfo->state info) state)
                   (setf (git-fileinfo->state info) state)
                   (setf (git-fileinfo->rename-state info) nil)
                   (setf (git-fileinfo->orig-name info) nil)
                   (setf (git-fileinfo->needs-refresh info) t))
                 (setq file (pop files)))
                (t (setq file (pop files)))))))
    (unless state  ;; delete files whose state has been set to nil
      (ewoc-filter status (lambda (info) (git-fileinfo->state info))))))

(defun git-state-code (code)
  "Convert from a string to a added/deleted/modified state."
  (case (string-to-char code)
