Thread (11 messages) flat view 11 messages, 6 authors, 2016-06-15

Re: [PATCH] cmd_reset: don't trash uncommitted changes unless told to

From: Avery Pennarun <hidden>
Date: 2016-06-15 22:44:49

On 6/25/08, Theodore Tso [off-list ref] wrote:
On Wed, Jun 25, 2008 at 10:22:08AM -0700, Junio C Hamano wrote:
 >         exec git checkout HEAD -- "$@"

Well, I think you really want this to handle filenames with spaces:

 for i in $*
 do
    git checkout HEAD -- "$i"
 done
"$@" notation actually handles spaces just fine.  It's magic that way.
 On the other hand, "for i in $*" does not, because all the spaces get
split as part of the unquoted $* in "for".  Beware!
 I still think it would be nice this as a built-in for "git
 revert-file" since this is much easier to type than "git checkout HEAD
 -- " (all those characters and capital letters).  But if it ends up
 being a private shell script for people who do this a lot, that's also fine.
How about making "git checkout" default to HEAD if no revision is
supplied?  There's precedent for this in, say, git-diff (and I think a
few others).

Incidentally, "checkout <filename>" was also the way to do a revert
operation in CVS.  And the way to switch branches, too, iirc.  So git
isn't being too unusual here.  That said, the commands were
deliberately renamed in svn because CVS was considered largely insane.

Have fun,

Avery
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help