From: Nguyen Thai Ngoc Duy <pclouds@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Jonathan Niedier <jrnieder@gmail.com>,
Jeff King <peff@peff.net>
Subject: Re: [PATCH v2] diff: support --cached on unborn branches
Date: Sun, 31 Oct 2010 10:24:13 +0700 [thread overview]
Message-ID: <20101031032413.GA27346@do> (raw)
In-Reply-To: <7vwroz3vj8.fsf@alter.siamese.dyndns.org>
On Sat, Oct 30, 2010 at 08:12:27PM -0700, Junio C Hamano wrote:
> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> 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@gmail.com>
>
> 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?
Yes.
--8<--
diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt
index dd1fb32..518e46b 100644
--- a/Documentation/git-diff.txt
+++ b/Documentation/git-diff.txt
@@ -32,7 +32,9 @@ directories. This behavior can be forced by --no-index.
This form is to view the changes you staged for the next
commit relative to the named <commit>. Typically you
would want comparison with the latest commit, so if you
- do not give <commit>, it defaults to HEAD.
+ do not give <commit>, it defaults to HEAD. If HEAD does
+ not exist (e.g. unborn branches) and <commit> is not
+ given, it shows all staged changes.
--staged is a synonym of --cached.
'git diff' [--options] <commit> [--] [<path>...]::
--8<--
--
Duy
next prev parent reply other threads:[~2010-10-31 3:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-29 9:54 [PATCH] diff: support --root --cached combination Nguyễn Thái Ngọc Duy
2010-10-29 10:19 ` Jonathan Nieder
2010-10-29 11:00 ` Nguyen Thai Ngoc Duy
2010-10-29 17:06 ` Junio C Hamano
2010-10-30 11:16 ` [PATCH v2] diff: support --cached on unborn branches Nguyễn Thái Ngọc Duy
2010-10-31 3:12 ` Junio C Hamano
2010-10-31 3:24 ` Nguyen Thai Ngoc Duy [this message]
2011-02-03 6:23 ` [PATCH] " Nguyễn Thái Ngọc Duy
2010-10-29 15:40 ` [PATCH] diff: support --root --cached combination Jeff King
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=20101031032413.GA27346@do \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=peff@peff.net \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).