Skip to content

Commit

Permalink
git-diff: Add --staged as a synonym for --cached.
Browse files Browse the repository at this point in the history
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
David Symonds authored and Junio C Hamano committed Nov 11, 2008
1 parent 36bd844 commit 2baf185
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions Documentation/git-diff.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ forced by --no-index.
commit relative to the named <commit>. Typically you
would want comparison with the latest commit, so if you
do not give <commit>, it defaults to HEAD.
--staged is a synonym of --cached.

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

Expand Down
5 changes: 3 additions & 2 deletions builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,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, "--cached") || !strcmp(arg, "--staged"))
cached = 1;
else
usage(builtin_diff_usage);
Expand Down Expand Up @@ -319,7 +319,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
const char *arg = argv[i];
if (!strcmp(arg, "--"))
break;
else if (!strcmp(arg, "--cached")) {
else if (!strcmp(arg, "--cached") ||
!strcmp(arg, "--staged")) {
add_head_to_pending(&rev);
if (!rev.pending.nr)
die("No HEAD commit to compare with (yet)");
Expand Down

0 comments on commit 2baf185

Please sign in to comment.