git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Mismatch between "git status" and "git ls-files" [was Re: Teach git status to do "git diff --name-status HEAD"]

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Sep 17, 2008, 15:16 UTC
Message-ID
<48D11F40.4000307@drmicha.warpmail.net>
In-Reply-To
<m3ej3jm3ux.fsf@localhost.localdomain>

Following up on the discussion about "git status" versus "youknowwhichscm status" and suggestions to use "git diff --name-status" or "git ls-files -d -m -o -t" I made a little test case, see the attached script and output (git version 1.6.0.2.249.g97d7f). Observations:

- "git diff --name-status" and "git ls-files" use very similar form,
even the same status letters, but with completely different meaning for
C, M, R. That is highly confusing (this what I mean by mismatch).
- "git diff --name-status" has no way of showing ignored or untracked files
- "git status" has no way of showing ignored files
- "git ls-files -d -m -o -t" does not distinguish between ignored and
untracked (all is ?)
- "git ls-files" is plumbing, one should not need plumbing to get status
output.
I guess what's needed would be a porcelain that:
- shows state in concise form ("X filename" lines like --name-status or
ls-files -t)
- has options to show ignored and untracked file optionally

To me the most direct approach would be: If "git diff" compares with the work-tree, teach it to include ignored resp. untracked files optionally.

I guess I wouldn't care about the mismatch then. Are there specific reasons (other than evolution) for the conflicting status letters?

Michael
Initialized empty Git repository in /tmp/mjg/stats/.git/
Created initial commit 345adf7: files to be changed
 10 files changed, 10 insertions(+), 0 deletions(-)
 create mode 100644 copied
 create mode 100644 gitmoved
 create mode 100644 gitremoved
 create mode 100644 modified
 create mode 100644 modifiedadded
 create mode 100644 moved
 create mode 100644 removed
 create mode 100644 typechanged
 create mode 100644 typechangedadded
 create mode 100644 unchanged
rm 'gitremoved'
### git status ###
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	new file:   added
#	new file:   copiedadded
#	renamed:    gitmoved -> gitmoved2
#	deleted:    gitremoved
#	modified:   modifiedadded
#	modified:   typechangedadded
#
# Changed but not updated:
#   (use "git add/rm <file>..." to update what will be committed)
#
#	modified:   modified
#	deleted:    moved
#	deleted:    removed
#	modified:   typechanged
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	copiedonly
#	moved2
#	untracked
### git diff ###
M	modified
D	moved
D	removed
M	typechanged
### git diff HEAD ###
A	added
C100	copied	copiedadded
R100	gitmoved	gitmoved2
D	gitremoved
M	modified
M	modifiedadded
D	moved
D	removed
M	typechanged
M	typechangedadded
### git diff --cached HEAD ###
A	added
C100	copied	copiedadded
R100	gitmoved	gitmoved2
D	gitremoved
M	modifiedadded
M	typechangedadded
### git ls-files
? copiedonly
? ignored
? moved2
? untracked
C modified
R moved
C moved
R removed
C removed
C typechanged
Previous: Michael J GruberNext: Jeff King
Message 5 of 6 in “Teach git status to do "git diff --name-status HEAD"”
  1. Martin LanghoffSep 17, 2008
  2. Michael J GruberSep 17, 2008
  3. Jakub NarebskiSep 17, 2008
  4. Michael J GruberSep 17, 2008
  5. Mismatch between "git status" and "git ls-files" [was Re: Teach git status to do "git diff --name-status HEAD"]Michael J Gruber, Sep 17, 2008
  6. Jeff KingSep 17, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.