git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Raymond <esr@thyrsus.com>
To: "Randal L. Schwartz" <merlyn@stonehenge.com>
Cc: Jacob Helwig <jacob.helwig@gmail.com>,
	Eric Raymond <esr@snark.thyrsus.com>,
	git@vger.kernel.org
Subject: Re: Status of all files (was: Re: How can I tell if a file is ignored by git?
Date: Fri, 9 Apr 2010 09:20:37 -0400	[thread overview]
Message-ID: <20100409132037.GA27899@thyrsus.com> (raw)
In-Reply-To: <864ojkx1un.fsf@red.stonehenge.com>

Randal L. Schwartz <merlyn@stonehenge.com>:
> A lot of these don't make sense for git and other DVCS.  How have
> hg and bzr interpreted these "canonical" states?

That asks the question the wrong way around.  These state codes
are used to change how VC *itself* performs when you fire various
commands; the VCSes called by the VC back ends never have to
'interpret' them.

It is not expected that every VCS will report all of them; in
particular, as you say, some only make sense in locking systems.  
When VC knows it's dealing with a merging system, it will never go
down a logic path where a locking-related state is checked for.

I deleted two of the locking-system-only states from what you saw, but
may have missed others; I don't completely understand all the states,
because at least eleven other people hacked on VC during the 15 years
I was doing other things and added several that were not in my
original design.

(There is some excuse for this. Emacs VC is probably unique in that
its ontology has to be rich enough to accomodate *every VCS there
is*. Nothing else even attempts that, AFAIK.)

But to answer your question at least in part, here is a piece of code
mapping status codes from Mercurial's hg status -A command to Emacs
state codes.

    (when (eq 0 status)
        (when (null (string-match ".*: No such file or directory$" out))
          (let ((state (aref out 0)))
            (cond
             ((eq state ?=) 'up-to-date)
             ((eq state ?A) 'added)
             ((eq state ?M) 'edited)
             ((eq state ?I) 'ignored)
             ((eq state ?R) 'removed)
             ((eq state ?!) 'missing)
             ((eq state ??) 'unregistered)
             ((eq state ?C) 'up-to-date) ;; Older mercurials use this
             (t 'up-to-date)))))))

This is failing to report at least one interesting state, 
which is 'conflict.  But otherwise it looks pretty complete.

What I'm really looking for is a git functional equivalent of hg status -A.
The git backend presently uses diff-index and interprets the output in
a way that I fear is rather brittle.

I'm inclined to think you are right that 'need-update and 'need-merge
don't make any sense in a tree-oriented VCS.  On the other hand, SVN 
and Monotone both report them.  On the gripping hand, I'm not certain these
qualify as "tree-oriented" in quite as strong a sense as hg and git do.
I need to understand this better.

If nothing else, perhaps this discussion will lead to me being able to
document Emacs statuses more completely.  There is a fair amount of
murk around them now, because the mode did a lot of growing by
accretion that I have not completely cleaned up yet.

> Eric>   'removed         Scheduled to be deleted from the repository
> Eric>                    on next commit.
> 
> Not useful in git.

I disagree.  At least, git status reports "removed" files before a commit.
This seems like the logical state for a file after it has been subjected 
to "git rm' but before commit.
 
> Eric>   'missing      The file is not present in the file system, but the VC
> Eric>                 system still tracks it.
> 
> Not available in git.  (If it's not a real file, it can't be tracked. :)

What about a file that has been deleted from the working copy with ordinary
rm (as opposed to git rm) so it's still in the index?  Wouldn't that qualify?

> Eric>   'ignored      The file showed up in a dir-status listing with a flag
> Eric>                 indicating the version-control system is ignoring it,
> 
> Eric>   'unregistered The file is not under version control.
> 
> These two would be identical in git.

Certainly not.  If I have "*.o" in my .gitignore, and two untracked files
foo.c and foo.o in my directory, both are unregistered, but only
foo.o is ignored.  Emacs wants to see foo.c -> 'unregistered but 
foo.o -> 'ignored.
-- 
		<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>

  reply	other threads:[~2010-04-09 13:20 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-09  4:04 How can I tell if a file is ignored by git? Eric Raymond
2010-04-09  4:10 ` Jacob Helwig
2010-04-09 11:32   ` Status of all files (was: " Eric Raymond
2010-04-09 12:11     ` Randal L. Schwartz
2010-04-09 13:20       ` Eric Raymond [this message]
2010-04-10 19:07       ` Junio C Hamano
2010-04-09 12:56     ` Jakub Narebski
2010-04-09 14:02       ` Eric Raymond
2010-04-09 14:23         ` Matthieu Moy
2010-04-09 16:24           ` Eric Raymond
     [not found]             ` <z2h62a3a9cb1004091615q52bd5f5aqc24079de7f0038ba@mail.gmail.com>
2010-04-09 23:18               ` Daniel Grace
2010-04-10  3:35               ` Eric Raymond
2010-04-09 16:52           ` Junio C Hamano
2010-04-09 14:50         ` Jakub Narebski
2010-04-10 22:12         ` Status of all files Paolo Bonzini
2010-04-11 10:25           ` Jeff King
2010-04-09  4:50 ` How can I tell if a file is ignored by git? Ramkumar Ramachandra
2010-04-09  5:01   ` Ævar Arnfjörð Bjarmason
2010-04-09 10:50     ` Eric Raymond

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100409132037.GA27899@thyrsus.com \
    --to=esr@thyrsus.com \
    --cc=esr@snark.thyrsus.com \
    --cc=git@vger.kernel.org \
    --cc=jacob.helwig@gmail.com \
    --cc=merlyn@stonehenge.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).