From a85a54140a2deb77d637b077d8cd1ddac2bf33d1 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 7 Jun 2025 13:09:19 +0100 Subject: [PATCH] ; * lisp/vc/vc-git.el (vc-git-after-dir-status-stage): Comments. (cherry picked from commit 29990aadda8d4f9fcf8961fdbc0a107469829e8c) --- lisp/vc/vc-git.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index cdbf80ebaaf..9a253b66010 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -592,6 +592,13 @@ or an empty string if none." "Process sentinel for the various dir-status stages." (let (next-stage (files (vc-git-dir-status-state->files git-state))) + ;; First stage is always update-index. + ;; After that, if no commits yet, ls-files-added. + ;; Otherwise, if there are commits, diff-index. + ;; After diff-index, if FILES non-nil, ls-files-up-to-date. + ;; After diff-index, if FILES nil, ls-files-conflict. + ;; Then always ls-files-unknown. + ;; Finally, if FILES non-nil, ls-files-ignored. (goto-char (point-min)) (pcase (vc-git-dir-status-state->stage git-state) ('update-index @@ -639,6 +646,9 @@ or an empty string if none." (vc-git-dir-status-update-file git-state (match-string 1) 'ignored (vc-git-create-extra-fileinfo 0 0)))) ('diff-index + ;; This is output from 'git diff-index' without --cached. + ;; Therefore this stage compares HEAD and the working tree and + ;; ignores the index (cf. git-diff-index(1) "RAW OUTPUT FORMAT"). (setq next-stage (if files 'ls-files-up-to-date 'ls-files-conflict)) (while (re-search-forward ":\\([0-7]\\{6\\}\\) \\([0-7]\\{6\\}\\) [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\(\\([ADMUT]\\)\0\\([^\0]+\\)\\|\\([CR]\\)[0-9]*\0\\([^\0]+\\)\0\\([^\0]+\\)\\)\0" -- 2.39.5