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

                  "  " (git-escape-file-name (git-fileinfo->name info))
                  (git-rename-as-string info))))

(defun git-insert-info-list (status infolist)
  "Insert a list of file infos in the status buffer, replacing existing ones if any."
  (setq infolist (sort infolist
                       (lambda (info1 info2)
                         (string-lessp (git-fileinfo->name info1)
                                       (git-fileinfo->name info2)))))
  (let ((info (pop infolist))
        (node (ewoc-nth status 0)))
    (while info
      (setf (git-fileinfo->needs-refresh info) t)
      (cond ((not node)
             (ewoc-enter-last status info)
             (setq info (pop infolist)))
            ((string-lessp (git-fileinfo->name (ewoc-data node))
                           (git-fileinfo->name info))
             (setq node (ewoc-next status node)))
            ((string-equal (git-fileinfo->name (ewoc-data node))
                           (git-fileinfo->name info))
              ;; preserve the marked flag
              (setf (git-fileinfo->marked info) (git-fileinfo->marked (ewoc-data node)))
              (setf (ewoc-data node) info)
              (setq info (pop infolist)))
            (t
             (ewoc-enter-before status node info)
             (setq info (pop infolist)))))))

(defun git-run-diff-index (status files)
  "Run git-diff-index on FILES and parse the results into STATUS.
Return the list of files that haven't been handled."
  (let (infolist)
    (with-temp-buffer
      (apply #'git-run-command t nil "diff-index" "-z" "-M" "HEAD" "--" files)
      (goto-char (point-min))

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

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