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

Status of all files (was: Re: How can I tell if a file is ignored by git?

From
Eric Raymond <esr@thyrsus.com>
Date
Apr 9, 2010, 11:32 UTC
Message-ID
<20100409113248.GB27353@thyrsus.com>
In-Reply-To
<j2z8c9a061004082110se894f925i80c1389cd4e247f@mail.gmail.com>
Jacob Helwig <jacob.helwig@gmail.com>:
Show 7 quoted lines
> On Thu, Apr 8, 2010 at 21:04, Eric Raymond <esr@snark.thyrsus.com> wrote:
> > I'm planning some work on Emacs VC mode.
> >
> > I need a command I can run on a path to tell if it's ignored by git.
> 
> What about a variant of:
>     git ls-files -i -o --exclude-standard
That will do nicely, thank you.

There could be something better. Emacs VC mode, and other similar front ends, would be greatly aided by a command that lists all files, each with a status code it can understand. Our canonical list (omitting two that apply only to locking systems) is:

  'up-to-date        The working file is unmodified with respect to the
                     latest version on the current branch, and not locked.
  'edited            The working file has been edited by the user.
  'needs-update      The file has not been edited by the user, but there is
                     a more recent version on the current branch stored
                     in the master file.
  'needs-merge       The file has been edited by the user, and there is also
                     a more recent version on the current branch stored in
                     the master file.  This state can only occur if locking
                     is not used for the file.
  'added             Scheduled to go into the repository on the next commit.
  'removed           Scheduled to be deleted from the repository on next commit.
  'conflict          The file contains conflicts as the result of a merge.
  'missing           The file is not present in the file system, but the VC
                     system still tracks it.
  'ignored           The file showed up in a dir-status listing with a flag
                     indicating the version-control system is ignoring it,
  'unregistered      The file is not under version control.

The -t mode of ls-files appears to be almost what is wanted, but not quite. (Among other things, it does not list ignored files.) I request comment on some related questions:

1. How do these statuses map to git terminology?  My tentative map, in terms 
of git file-list -t codes, is

up-to-date = H? edited = C needs-update = no equivalent needs-merge = no equivalent added = no equivalent removed = K conflict = no equivalent missing = R ignored = no equivalent unregistered = no equivalent

I am unclear on what your "unmerged" (M) status means.
2. I've played with various option combinations, but I can't seem to find one
that lists these codes for all files.  Is there one?
3. Is the use case for -t such that it would make sense to modify it so
it does a complete listing?
4. If the answer to question 3 is 'yes', is there some Emacs user here
who already knows git internals and would be willing to do this in
order to help VC be faster and more effective?  I would handle the VC
end, of course.
-- 
		<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>
Previous: Jacob HelwigNext: Randal L. Schwartz
Message 3 of 19 in “How can I tell if a file is ignored by git?”
  1. Eric RaymondApr 9, 2010
  2. Jacob HelwigApr 9, 2010
  3. Status of all files (was: Re: How can I tell if a file is ignored by git?Eric Raymond, Apr 9, 2010
  4. Randal L. SchwartzApr 9, 2010
  5. Eric RaymondApr 9, 2010
  6. Junio C HamanoApr 10, 2010
  7. Jakub NarebskiApr 9, 2010
  8. Eric RaymondApr 9, 2010
  9. Matthieu MoyApr 9, 2010
  10. Eric RaymondApr 9, 2010
  11. Junio C HamanoApr 9, 2010
  12. Jakub NarebskiApr 9, 2010
  13. Paolo BonziniApr 10, 2010
  14. Jeff KingApr 11, 2010
  15. Ramkumar RamachandraApr 9, 2010
  16. Ævar Arnfjörð BjarmasonApr 9, 2010
  17. Eric RaymondApr 9, 2010
  18. Daniel GraceApr 9, 2010
  19. Eric RaymondApr 10, 2010

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.