git-diff: Add --staged as a synonym for --cached.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
David Symonds committed
Oct 29, 2008 at 09:15 UTC
2baf1850ceb01dfbee862e30f2a69cf6064e13eb
2 files changed
+4
-2
Documentation/git-diff.txt
+1
@@ -33,6 +33,7 @@ forced by --no-index.
33
commit relative to the named <commit>. Typically you
34
would want comparison with the latest commit, so if you
35
do not give <commit>, it defaults to HEAD.
36
+ --staged is a synonym of --cached.
37
38
'git diff' [--options] <commit> [--] [<path>...]::
39
builtin-diff.c
+3
-2
@@ -118,7 +118,7 @@ static int builtin_diff_index(struct rev_info *revs,
118
int cached = 0;
119
while (1 < argc) {
120
const char *arg = argv[1];
121
- if (!strcmp(arg, "--cached"))
121
+ if (!strcmp(arg, "--cached") || !strcmp(arg, "--staged"))
122
cached = 1;
123
else
124
usage(builtin_diff_usage);
@@ -319,7 +319,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
319
const char *arg = argv[i];
320
if (!strcmp(arg, "--"))
321
break;
322
- else if (!strcmp(arg, "--cached")) {
322
+ else if (!strcmp(arg, "--cached") ||
323
+ !strcmp(arg, "--staged")) {
324
add_head_to_pending(&rev);
325
if (!rev.pending.nr)
326
die("No HEAD commit to compare with (yet)");