all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dan Nicolaescu <dann@ics.uci.edu>
To: mathias@mnet-mail.de
Cc: emacs-devel@gnu.org
Subject: Re: C-x v u for added files in vc-git
Date: Thu, 3 Dec 2009 10:22:35 -0800 (PST)	[thread overview]
Message-ID: <200912031822.nB3IMZt0027156@godzilla.ics.uci.edu> (raw)
In-Reply-To: <20091203131514.cq73r2k3cwso8sow@webmail.mnet-online.de> (mathias@mnet-mail.de's message of "Thu, 03 Dec 2009 13:15:14 +0100")

mathias@mnet-mail.de writes:

  > Zitat von Dan Nicolaescu <dann@ics.uci.edu>:
  > 
  > > mathias@mnet-mail.de writes:
  > >
  > >   > Zitat von Dan Nicolaescu <dann@ics.uci.edu>:
  > >   >
  > >   > > In a git tree doing:
  > >   > >
  > >   > > C-x C-f BLAH_BLAH RET
  > >   > > RET
  > >   > > C-x v v
  > >   > >
  > >   > > will put the BLAH_BLAH in the 'added state
  > >   > >
  > >   > > Doing a C-x v u
  > >   > > after that should return it to the 'unregistered state, but that does
  > >   > > not happen the file stays in the 'added state.
  > >   > >
  > >   > > This is because vc-git-revert runs:
  > >   > > (vc-git-command nil 0 file "checkout" "HEAD")
  > >   > >
  > >   > > What should vc-git-revert do that it works in the above case too?
  > >   >
  > >   > git rm --cached <file>
  > >   >
  > >   > removes the file from the index,  i.e. reverts the 'add' command.
  > >
  > > Does it also restore the file contents in the case where the file is
  > > registered and it has been changed ? (that's another use for the
  > > function in question).
  > 
  > 'git add <file>' not only registers the file as 'cvs add <file>' does.
  > It  also adds the content of the file to the index.
  > 'git rm --cached <file>' removes the content from the index and doesn't
  > touch the file.
  > 
  > I think there are 3 cases here:
  > 
  > 1. If you have mistakenly added a new file with 'git add' that should not be
  >    under version control then 'git rm --cached <file<' is the right command
  >    to undo it.
  > 
  > 2. <file> is already in the repository. If you have changed it and added
  >    to the index but don't want to commit this change now, then again
  >     'git rm --cached <file<' is the right command. <file> will still be
  >    in your worktree in the modified state.
  > 
  > 3. <file> is already in the repository. If you have changed it and want revert
  >    this change. In this case 'git checkout HEAD <file>' restores the content
  >    to that of the last commit. 'git checkout' also updates the index.
  >    It didn't update the index in your case because the file wasn't in HEAD.
  > 
  > I think C-x v u should do 1. and 2. but not 3. because 3. deletes data.

3. is exactly the goal for the command, to get rid of unwanted changes!

So it seems that if we do the sequence:

git checkout HEAD <file>
git rm --cached <file>

that take care of all situations.




  reply	other threads:[~2009-12-03 18:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-03  6:06 C-x v u for added files in vc-git Dan Nicolaescu
2009-12-03  8:02 ` mathias
2009-12-03  9:09   ` Dan Nicolaescu
2009-12-03 12:15     ` mathias
2009-12-03 18:22       ` Dan Nicolaescu [this message]
2009-12-04  3:39         ` Miles Bader
2009-12-04  4:49           ` Dan Nicolaescu
2009-12-04  5:24             ` Miles Bader
2009-12-04  5:44               ` Dan Nicolaescu
2009-12-04  7:58                 ` Miles Bader
2009-12-04 18:55                   ` Dan Nicolaescu

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=200912031822.nB3IMZt0027156@godzilla.ics.uci.edu \
    --to=dann@ics.uci.edu \
    --cc=emacs-devel@gnu.org \
    --cc=mathias@mnet-mail.de \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.