git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-diff: Introduce --index and deprecate --cached.

From
Junio C Hamano <junkio@cox.net>
Date
Dec 9, 2006, 02:24 UTC
Message-ID
<7vac1xg61s.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20061130115913.EA36C5BA19@nox.op5.se>
Andreas Ericsson <ae@op5.se> writes:
> 'git diff --cached' still works, but its use is discouraged
> in the documentation. 'git diff --index' does the same thing
> and is consistent with how 'git apply --index' works.

Although I've applied this long time ago (in git timescale anyway), this patch and the above rationale is wrong.

'diff --cached' is more in line with how 'apply --cached' works, not how 'apply --index' works.

With apply, --cached and --index both tell the command to be aware of the index, but --cached means "operate on the index, and never look at working tree", while --index means "operate both on the index and working tree at the same time". In particular, the former does not care if the file in the working tree matches the index, while the latter does.

'diff --cached' is about the tree and the index without looking at the working tree. Since there is no mode of operation that looks at both the index and the working tree in the underlying diff-index, I made the mistake of applying this patch, but it is conceivable that we may want to have a 'diff --index' that compares HEAD, the index and the working tree, perhaps in a combined diff format.

I think we should revert this patch.
Previous: Andreas EricssonNext: Junio C Hamano
Message 2 of 3 in “git-diff: Introduce --index and deprecate --cached.”
  1. git-diff: Introduce --index and deprecate --cached.Andreas Ericsson, Nov 30, 2006
  2. Junio C HamanoDec 9, 2006
  3. Junio C HamanoDec 9, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.