Skip to content

Commit 4c81c21

Browse files
agericJunio C Hamano
authored andcommitted
git-diff: Introduce --index and deprecate --cached.
'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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ced7b82 commit 4c81c21

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Documentation/git-diff.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ the number of trees given to the command.
2222

2323
* When one <tree-ish> is given, the working tree and the named
2424
tree are compared, using `git-diff-index`. The option
25-
`--cached` can be given to compare the index file and
25+
`--index` can be given to compare the index file and
2626
the named tree.
27+
`--cached` is a deprecated alias for `--index`. It's use is
28+
discouraged.
2729

2830
* When two <tree-ish>s are given, these two trees are compared
2931
using `git-diff-tree`.
@@ -47,7 +49,7 @@ Various ways to check your working tree::
4749
+
4850
------------
4951
$ git diff <1>
50-
$ git diff --cached <2>
52+
$ git diff --index <2>
5153
$ git diff HEAD <3>
5254
------------
5355
+

builtin-diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static int builtin_diff_index(struct rev_info *revs,
137137
int cached = 0;
138138
while (1 < argc) {
139139
const char *arg = argv[1];
140-
if (!strcmp(arg, "--cached"))
140+
if (!strcmp(arg, "--index") || !strcmp(arg, "--cached"))
141141
cached = 1;
142142
else
143143
usage(builtin_diff_usage);

0 commit comments

Comments
 (0)