Re: [RFC] Reverting individual files to HEAD

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

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

> Matthieu Moy <Matthieu.Moy@xxxxxxx> writes:
>
>> Junio C Hamano <gitster@xxxxxxxxx> writes:
>>
>>> 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;
>>
>> True, but that's already true of "git reset --hard", alone, isn't
>>it?  Unless I missed something, "git reset --soft" is a no-op if you
>>don't provide arguments.
>
> I think I see where you are coming from.  To you "git reset" (any of
> three reset_type) is something special and different from "git reset
> <any-commit>".  If we take that approach, "git reset" and "git reset
> HEAD" can behave differently and you can certainly argue "git reset
> --soft" is a no-op.
>
> To me, it is just a shorthand of not giving an explicit commit
> (and defaults to HEAD), and it is not particularly special.
> Neither "git reset --hard not-HEAD" nor "git reset --soft
> not-HEAD" is a no-op.
>
> That makes "git reset --soft not-HEAD -- paths" being a no-op
> doubly confusing while "git reset --hard not-HEAD -- paths" does
> what exactly "git checkout not-HEAD -- paths" does.

Well, it is not "doubly confusing" in my book but "just as confusing".
I would make the usage of everything consistent, and spew out a
warning in the case of

git reset --soft HEAD
and
git reset --soft anything files

that says
"`git-reset --soft HEAD' has no effect."
or
"`git-reset --soft' has no effect with a file list."

I'd prefer a warning instead of an error since it is conceivable that
the calls occur in the course of a script that does something useful
even when $commit is HEAD.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
-
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