Re: [RFC] Reverting individual files to HEAD

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

 



Matthieu Moy <Matthieu.Moy@xxxxxxx> writes:

> ... In this command, I obviously don't want to move the HEAD,
> so why the hell should git refuse "git reset --hard -- file1
> file2"?

(1) because allowing it begs the question "what would happen if
    I replace that --hard with --soft", the answer to which has
    to be "nothing happens".  That answer is logically correct
    but not useful from the end user's point of view;

(2) because it is a good idea to remove "git reset --mixed --
    file1 file2" and spell it without --mixed in order to reduce
    confusion, after which happens the "--hard" variant would
    become even more special case;

(3) because there already is "git checkout HEAD -- file1 file2".

Having said that, if more synonyms make users less confused,
then I think the following is possible:

   (1) grabbing paths out of an existing commit and updating both
       index and work tree has two synonyms:

          $ git reset --hard <commit> -- paths...       <*>
          $ git checkout <commit> -- paths...

   (2) grabbing paths out of an existing commit and updating only
       the index has three synonyms:

          $ git reset --mixed <commit> -- paths...
          $ git reset <commit> -- paths...
          $ git checkout --cached <commit> -- paths...  <*>

   Note:
       In none of the cases the HEAD moves.
       Cases marked <*> do not exist yet.

I just prefer the simplicity of:

   (1) grabbing paths out of an existing commit and updating both
       index and work tree can be done with:

          $ git checkout <commit> -- paths...

   (2) grabbing paths out of an existing commit and updating only
       the index can be done with:

          $ git reset <commit> -- paths...              <*>

   Note:
       In none of the cases the HEAD moves.
       By accident, we allow "reset --mixed <commit> -- paths...",
       in addition to <*>, but we should deprecate it.

for two reasons.  Because you would not get confused by having
more than one ways to do the same thing, and because I think it
is easier to remember (the word "checkout" has stronger
association with work tree than the index).

I think the above two alternatives are equally valid, and I
think it eventually boils down to the matter of taste.  We
already have the code for the latter (except that "refusing
paths with --mixed" part), but for the former we don't.

I dunno.
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux