Re: [PATCH v2] diff: support --cached on unborn branches

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

 



Nguyán ThÃi Ngác Duy  <pclouds@xxxxxxxxx> writes:

> "git diff --cached" (without revision) used to mean "git diff --cached
> HEAD" (i.e. the user was too lazy to type HEAD). This "correctly"
> failed when there was no commit yet. But was that correctness useful?
>
> This patch changes the definition of what particular command means.
> It is a request to show what _would_ be committed without further "git
> add". The internal implementation is still the same "git diff
> --cached HEAD" when HEAD exists, but when there is no commit yet, it
> compares the index with an empty tree object to achieve the desired
> result.
>
> Signed-off-by: Nguyán ThÃi Ngác Duy <pclouds@xxxxxxxxx>

Will take a look at it, and queue.  Thanks.

>  "git diff --cached HEAD" does fail, but I don't really care.

I _do_ care, and so should you.  And I think it _should_ fail, if the user
explicitly asked to compare the index with HEAD that does not exist yet.

As we are updating the semantics of a Porcelain command, there should be
an update that explains the new usage in the documentation, no?
--
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]