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

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

From
Andreas Ericsson <ae@op5.se>
Date
Nov 30, 2006, 11:43 UTC
Message-ID
<20061130115913.EA36C5BA19@nox.op5.se>

'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.

Signed-off-by: Andreas Ericsson <ae@op5.se>
---
 Documentation/git-diff.txt |    6 ++++--
 builtin-diff.c             |    2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt
index 228c4d9..3144864 100644
--- a/Documentation/git-diff.txt
+++ b/Documentation/git-diff.txt
@@ -22,8 +22,10 @@ the number of trees given to the command.
 
 * When one <tree-ish> is given, the working tree and the named
   tree are compared, using `git-diff-index`.  The option
-  `--cached` can be given to compare the index file and
+  `--index` can be given to compare the index file and
   the named tree.
+  `--cached` is a deprecated alias for `--index`. It's use is
+  discouraged.
 
 * When two <tree-ish>s are given, these two trees are compared
   using `git-diff-tree`.
@@ -47,7 +49,7 @@ Various ways to check your working tree::
 +
 ------------
 $ git diff            <1>
-$ git diff --cached   <2>
+$ git diff --index    <2>
 $ git diff HEAD       <3>
 ------------
 +
diff --git a/builtin-diff.c b/builtin-diff.c
index a659020..1c535b1 100644
--- a/builtin-diff.c
+++ b/builtin-diff.c
@@ -137,7 +137,7 @@ static int builtin_diff_index(struct rev_info *revs,
 	int cached = 0;
 	while (1 < argc) {
 		const char *arg = argv[1];
-		if (!strcmp(arg, "--cached"))
+		if (!strcmp(arg, "--index") || !strcmp(arg, "--cached"))
 			cached = 1;
 		else
 			usage(builtin_diff_usage);
-- 
1.4.4.1.GIT
Next: Junio C Hamano
Message 1 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.