          (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-run-command nil nil "update-index" "--info-only" "--refresh")
-    (if (git-empty-db-p)
-        ; we need some special handling for an empty db
-        (with-temp-buffer
-          (git-run-command t nil "ls-files" "-z" "-t" "-c")
-          (git-parse-ls-files status 'added))
-      (with-temp-buffer
-        (git-run-command t nil "diff-index" "-z" "-M" "HEAD")
-        (git-parse-status status)))
-      (with-temp-buffer
-        (git-run-command t nil "ls-files" "-z" "-u")
-        (git-parse-ls-unmerged status))
-      (when (file-readable-p ".git/info/exclude")
-        (with-temp-buffer
-          (git-run-command t nil "ls-files" "-z" "-t" "-o"
-                           "--exclude-from=.git/info/exclude"
-                           (concat "--exclude-per-directory=" git-per-dir-ignore-file))
-          (git-parse-ls-files status 'unknown)))
-    (git-refresh-files)
-    (git-refresh-ewoc-hf 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)))))

      (setq node (ewoc-next status node)))
    node))

(defun git-parse-ls-files (status default-state &optional skip-existing)
  "Parse the output of git-ls-files in the current buffer."
  (goto-char (point-min))
  (let (infolist)
    (while (re-search-forward "\\([HMRCK?]\\) \\([^\0]*\\)\0" nil t 1)
      (let ((state (match-string 1))
            (name (match-string 2)))
        (unless (and skip-existing (git-find-status-file status name))
          (push (git-create-fileinfo (or (git-state-code state) default-state) name) infolist))))
    (dolist (info (nreverse infolist))
      (ewoc-enter-last status info))))

(defun git-parse-ls-unmerged (status)
  "Parse the output of git-ls-files -u in the current buffer."
  (goto-char (point-min))
  (let (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) files))))
    (git-set-files-state files 'unmerged)))

(defun git-add-status-file (state name)
  "Add a new file to the status list (if not existing already) and return its node."
  (unless git-status (error "Not in git-status buffer."))
  (or (git-find-status-file git-status name)
      (ewoc-enter-last git-status (git-create-fileinfo state name))))

(defun git-marked-files ()
  "Return a list of all marked files, or if none a list containing just the file at cursor position."

    (sort-lines nil (point-min) (point-max))
    (save-buffer))
  (when created
    (git-run-command nil nil "update-index" "--add" "--" (file-relative-name ignore-name)))
  (git-update-status-files (list (file-relative-name ignore-name)) 'unknown)))

; propertize definition for XEmacs, stolen from erc-compat
(eval-when-compile
