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

[PATCH] git-diff: Add --staged as a synonym for --cached.

From
David Symonds <dsymonds@gmail.com>
Date
Oct 29, 2008, 16:15 UTC
Message-ID
<1225296936-1357-1-git-send-email-dsymonds@gmail.com>
---
 Consider this as a replacement to the previous git-staged series.
 Documentation/git-diff.txt |    1 +
 builtin-diff.c             |    5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt
index c53eba5..a2f192f 100644
--- a/Documentation/git-diff.txt
+++ b/Documentation/git-diff.txt
@@ -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>...]::
 
diff --git a/builtin-diff.c b/builtin-diff.c
index 2de5834..7ceceeb 100644
--- a/builtin-diff.c
+++ b/builtin-diff.c
@@ -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);
@@ -320,7 +320,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)");
-- 
1.6.0
Next: Jeff King
Message 1 of 29 in “git-diff: Add --staged as a synonym for --cached.”
  1. git-diff: Add --staged as a synonym for --cached.David Symonds, Oct 29, 2008
  2. Jeff KingOct 29, 2008
  3. David SymondsOct 29, 2008
  4. Johannes SchindelinOct 29, 2008
  5. Jeff KingOct 29, 2008
  6. Junio C HamanoNov 2, 2008
  7. Jeff KingNov 3, 2008
  8. Björn SteinbrinkNov 2, 2008
  9. Junio C HamanoNov 2, 2008
  10. Björn SteinbrinkNov 2, 2008
  11. Jeff KingNov 3, 2008
  12. David SymondsNov 10, 2008
  13. Jeff KingNov 11, 2008
  14. Junio C HamanoNov 11, 2008
  15. Jeff KingNov 11, 2008
  16. Junio C HamanoNov 12, 2008
  17. Avery PennarunNov 11, 2008
  18. Miles BaderNov 11, 2008
  19. Jeff KingNov 12, 2008
  20. Johannes SchindelinNov 12, 2008
  21. Jeff KingNov 12, 2008
  22. Avery PennarunNov 12, 2008
  23. Jeff KingNov 12, 2008
  24. Junio C HamanoNov 12, 2008
  25. Jeff KingNov 12, 2008
  26. Junio C HamanoNov 12, 2008
  27. Avery PennarunNov 12, 2008
  28. Junio C HamanoNov 12, 2008
  29. Avery PennarunNov 12, 2008

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.