Skip to content

Commit 2baf185

Browse files
dsymondsgitster
authored andcommitted
git-diff: Add --staged as a synonym for --cached.
Signed-off-by: Junio C Hamano <[email protected]>
1 parent 36bd844 commit 2baf185

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Documentation/git-diff.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ forced by --no-index.
3333
commit relative to the named <commit>. Typically you
3434
would want comparison with the latest commit, so if you
3535
do not give <commit>, it defaults to HEAD.
36+
--staged is a synonym of --cached.
3637

3738
'git diff' [--options] <commit> [--] [<path>...]::
3839

builtin-diff.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static int builtin_diff_index(struct rev_info *revs,
118118
int cached = 0;
119119
while (1 < argc) {
120120
const char *arg = argv[1];
121-
if (!strcmp(arg, "--cached"))
121+
if (!strcmp(arg, "--cached") || !strcmp(arg, "--staged"))
122122
cached = 1;
123123
else
124124
usage(builtin_diff_usage);
@@ -319,7 +319,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
319319
const char *arg = argv[i];
320320
if (!strcmp(arg, "--"))
321321
break;
322-
else if (!strcmp(arg, "--cached")) {
322+
else if (!strcmp(arg, "--cached") ||
323+
!strcmp(arg, "--staged")) {
323324
add_head_to_pending(&rev);
324325
if (!rev.pending.nr)
325326
die("No HEAD commit to compare with (yet)");

0 commit comments

Comments
 (0)