emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C-x v u for added files in vc-git


From: Dan Nicolaescu
Subject: Re: C-x v u for added files in vc-git
Date: Fri, 4 Dec 2009 10:55:44 -0800 (PST)

Miles Bader <address@hidden> writes:

  > Dan Nicolaescu <address@hidden> writes:
  > >   > Since VC already appears to know whether the file's in the repo or 
just
  > >   > "added" (in the mode-line, it shows "@" for newly added files, but ":"
  > >   > or "-" for already-in-the-repo files), that should be possible, right?
  > >
  > > It should be.  BTW, can't git reset FILE be used here?
  > 
  > Hmm, maybe the sequence:
  > 
  >    git reset -q FILE; git checkout -q FILE 2>/dev/null
  > could be used.

Currently the checkout command used is:
git checkout HEAD FILE

Any difference between that and your proposal (WRT the checkout
command)?  Keep the old one, or use your version?

  > The "reset" removes any newly added files from the index (without
  > changing their contents), but seems to be ignored for files already in
  > the repo.
  > 
  > The "checkout" will revert the contents of files already in the repo,
  > but will be ignored (with an error message) for unknown files -- and any
  > newly added files should be unknown at this point because of the
  > previous "reset".

vc-do-command/vc-git-command deals with that without any problem.

Here's what I tested and seems to work fine for files with changes,
files just added and remove files:

(defun vc-git-revert (file &optional contents-done)
  "Revert FILE to the version stored in the git repository."
  (if contents-done
      (vc-git-command nil 0 file "update-index" "--")
    (vc-git-command nil 0 file "reset" "-q" "--")
    (vc-git-command nil nil file "checkout" "-q" "--")))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]