From: Junio C Hamano <email@example.com> To: Miklos Vajna <firstname.lastname@example.org> Cc: Paolo Ciarrocchi <email@example.com>, Git Mailing List <firstname.lastname@example.org> Subject: Re: A few usability question about git diff --cached Date: Thu, 04 Oct 2007 06:14:51 -0700 Message-ID: <email@example.com> (raw) In-Reply-To: <20071004125641.GE15339@genesis.frugalware.org> (Miklos Vajna's message of "Thu, 4 Oct 2007 14:56:41 +0200") Miklos Vajna <firstname.lastname@example.org> writes: > On Thu, Oct 04, 2007 at 02:27:41PM +0200, Paolo Ciarrocchi <email@example.com> 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.
next prev parent reply index Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2007-10-04 12:27 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
Reply instructions: You may reply publically 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 \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ /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
Git Mailing List Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/git/0 git/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 git git/ https://lore.kernel.org/git \ email@example.com public-inbox-index git Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.kernel.vger.git AGPL code for this site: git clone https://public-inbox.org/public-inbox.git