archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <>
To: Miklos Vajna <>
Cc: Paolo Ciarrocchi <>,
	Git Mailing List <>
Subject: Re: A few usability question about git diff --cached
Date: Thu, 04 Oct 2007 06:14:51 -0700	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <> (Miklos Vajna's message of "Thu, 4 Oct 2007 14:56:41 +0200")

Miklos Vajna <> writes:

> On Thu, Oct 04, 2007 at 02:27:41PM +0200, Paolo Ciarrocchi <> wrote:
>> Why do we have the option "--cached" and not "--index"?
> according to glossary.txt, 'cache' is an obsolete for 'index'. probably
> this is the reason
> probably cache.h will be never renamed to index.h, i don't know if diff
> --cached will be ever renamed to diff --index

Probably never.

Some commands support both --index and --cached and have
different meanings.  For them,

 * --index means work on both index and work tree;
 * --cached means work only on index and ignore work tree.

In the case of "diff --cached", the latter is exactly what's
happening.  We do not say "git diff-index --index $commit"
because "git diff-index" (and by extension, when you give only
one commit to "git diff" as parameter) is all about a commit vs
your uncommitted changes, so having you say "--index" is just
silly.  "git diff --cached" is just a shorthand for "git diff
--cached HEAD".  Because --cached would make sense to no other
form of diff, its presense by definition means you are talking
about the one-tree form of diff i.e. compare a commit with your
uncommitted changes.

An example of a command that supports both is "git apply".
Actually it is an extreme case in that it allows "no index" form
of operation, so it has "git apply", "git apply --cached", and
"git apply --index".  The --cached would only apply to index
without touching work tree, the --index would apply to both
index and work tree.

  parent reply	other threads:[~2007-10-04 13:15 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-04 12:27 A few usability question about git diff --cached Paolo Ciarrocchi
2007-10-04 12:54 ` Wincent Colaiuta
2007-10-05  5:59   ` Miles Bader
2007-10-05 10:27     ` Wincent Colaiuta
2007-10-05 10:41       ` Miles Bader
2007-10-04 12:56 ` Miklos Vajna
2007-10-04 13:10   ` Paolo Ciarrocchi
2007-10-04 13:14   ` Junio C Hamano [this message]
2007-10-04 13:39     ` Paolo Ciarrocchi
2007-10-04 14:09     ` Wincent Colaiuta
2007-10-04 14:34     ` Johannes Schindelin
2007-10-04 14:40       ` Junio C Hamano
2007-10-04 14:47         ` David Kastrup
2007-10-04 14:44       ` Matthieu Moy
2007-10-04 15:51         ` J. Bruce Fields
2007-10-04 16:02           ` Matthieu Moy
2007-10-04 16:19             ` J. Bruce Fields
2007-10-05  6:40               ` Matthieu Moy
2007-10-05  5:22         ` David Tweed
2007-10-04 15:49       ` Wincent Colaiuta
2021-08-14 19:31 Court Rankin
2023-01-12 11:54 Mohammed Al-Mahmeed

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \

* 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).