bug#81625: 31.0.60; vc-git-status can return incorrect status information

Lester Longley via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email protected]>
Newsgroups gmane.emacs.bugs
Message-ID <CAA3095-iE=MkgMFE+RcZSvbWc20Bh4=+VCgMh65TQ8e9pza4ZA@mail.gmail.com>
X-Debbugs-Cc:
--text follows this line--

My ~/.emacs is tracked in a Git repo.

The issue isn't specifically related to ~/.emacs; that's just how I
encountered it.

With:

  [~] emacs -Q .emacs

... I noticed that the `vc-mode' portion of mode-line shows
"Git!master", where "!" indicates "ignored".

Importantly, my ~/.gitignore contains this pertinent line:

  [~] grep emacs .gitignore
  .emacs.d/

This incorrect/misleading info. (i.e., `vc-mode' -> "Git!master",
rather than "Git-master", when the file is current/clean w.r.t. its
Git status)
seems to result from the following command constructed by `vc-git-state':

  [~] git status --porcelain -z --untracked-files --ignored -- .emacs
  !! .emacs.d/elpa/vterm-20260626.1906/build/libvterm-prefix/src/libvterm/^@

This latter path
(.emacs.d/elpa/vterm-20260626.1906/build/libvterm-prefix/src/libvterm/)
isn't special in any way that I'm aware of.

In contrast, when ~/.emacs is modified, the "git status" command
returns the following, and `vc-mode' indicates "Git:master", as
expected.

  [~] git status --porcelain -z --untracked-files --ignored -- .emacs
   M .emacs^@!!
.emacs.d/elpa/vterm-20260626.1906/build/libvterm-prefix/src/libvterm/^@

Or, without "-z", for readability here:

  [~] git status --porcelain --untracked-files --ignored -- .emacs
   M .emacs
  !! .emacs.d/elpa/vterm-20260626.1906/build/libvterm-prefix/src/libvterm/

I'm using:

  [~] git --version
  git version 2.47.3

It seems to me that one solution would be for `vc-git-state' to
post-process the `status',
as returned from (status (apply #'vc-git--run-command-string file args)),
so as to match up the returned info. with the specified `file'.

I can't see that this result relates to any recent Emacs changes, nor
have I found any applicable bug report.
(I found this old/fixed bug, but it seems unrelated: bug#39452:
[PATCH] vc-git-state fails for filenames with wildcards.)

Regards,
Lester

--------------------------------------------------

In GNU Emacs 31.0.60 (build 1, aarch64-unknown-linux-gnu, GTK+ Version
 3.24.49, cairo version 1.18.4) of 2026-06-28 built on penguin
Repository revision: e4d529c67b6a751c3a0858b057afafd1b37cd30a
Repository branch: emacs-31
System Description: Debian GNU/Linux 13 (trixie)

Configured using:
 'configure --with-pgtk 'CFLAGS=-g -O2
 -Werror=implicit-function-declaration
 -ffile-prefix-map=/tmp/emacs.git=. -fstack-protector-strong
 -fstack-clash-protection -Wformat -Werror=format-security
 -mbranch-protection=standard -Wall' 'CPPFLAGS=-Wdate-time
 -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY
PDUMPER PGTK PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
TREE_SITTER WEBP XIM GTK3 ZLIB

Important settings:
  value of $LANG: C.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Elisp/d

Minor modes in effect:
  outline-minor-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-nonselected-mode: t
  minibuffer-regexp-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug lisp-mnt message mailcap yank-media puny
dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg
rfc6068 epg-config gnus-util text-property-search time-date subr-x
mule-util mm-decode mm-bodies mm-encode mailabbrev gmm-utils mailheader
sendmail mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils comp-run bytecomp byte-compile comp-common rx
vc-git diff-mode track-changes easy-mmode files-x vc-dispatcher pcase
noutline outline cus-edit pp cus-start cus-load icons wid-edit
cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren electric
uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/pgtk-win pgtk-win term/common-win touch-screen pgtk-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify
dynamic-setting system-font-setting font-render-setting cairo gtk pgtk
lcms2 multi-tty move-toolbar make-network-process tty-child-frames
native-compile emacs)

Memory information:
((conses 16 102553 24015) (symbols 48 8869 0) (strings 32 21819 2299)
 (string-bytes 1 670103) (vectors 16 12851)
 (vector-slots 8 174733 13454) (floats 8 37 468)
 (intervals 56 2619 261) (buffers 1064 11))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.