{"thread":{"id":"43407","subject":"Re: [PATCH] git-diff: Introduce --index and deprecate --cached.","startedAt":"2006-11-30T11:43:13Z","lastAt":"2006-12-09T02:29:02Z","messageCount":3,"participants":["Junio C Hamano","Andreas Ericsson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"294721","messageId":"20061130115913.EA36C5BA19@nox.op5.se","threadId":"43407","inReplyTo":null,"subject":"[PATCH] git-diff: Introduce --index and deprecate --cached.","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2006-11-30T11:43:13Z","receivedAt":"2006-11-30T11:43:13Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"'git diff --cached' still works, but its use is discouraged\nin the documentation. 'git diff --index' does the same thing\nand is consistent with how 'git apply --index' works.\n\nSigned-off-by: Andreas Ericsson <ae@op5.se>\n---\n Documentation/git-diff.txt |    6 ++++--\n builtin-diff.c             |    2 +-\n 2 files changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt\nindex 228c4d9..3144864 100644\n--- a/Documentation/git-diff.txt\n+++ b/Documentation/git-diff.txt\n@@ -22,8 +22,10 @@ the number of trees given to the command.\n \n * When one <tree-ish> is given, the working tree and the named\n   tree are compared, using `git-diff-index`.  The option\n-  `--cached` can be given to compare the index file and\n+  `--index` can be given to compare the index file and\n   the named tree.\n+  `--cached` is a deprecated alias for `--index`. It's use is\n+  discouraged.\n \n * When two <tree-ish>s are given, these two trees are compared\n   using `git-diff-tree`.\n@@ -47,7 +49,7 @@ Various ways to check your working tree::\n +\n ------------\n $ git diff            <1>\n-$ git diff --cached   <2>\n+$ git diff --index    <2>\n $ git diff HEAD       <3>\n ------------\n +\ndiff --git a/builtin-diff.c b/builtin-diff.c\nindex a659020..1c535b1 100644\n--- a/builtin-diff.c\n+++ b/builtin-diff.c\n@@ -137,7 +137,7 @@ static int builtin_diff_index(struct rev_info *revs,\n \tint cached = 0;\n \twhile (1 < argc) {\n \t\tconst char *arg = argv[1];\n-\t\tif (!strcmp(arg, \"--cached\"))\n+\t\tif (!strcmp(arg, \"--index\") || !strcmp(arg, \"--cached\"))\n \t\t\tcached = 1;\n \t\telse\n \t\t\tusage(builtin_diff_usage);\n-- \n1.4.4.1.GIT\n"},{"id":"296357","messageId":"7vac1xg61s.fsf@assigned-by-dhcp.cox.net","threadId":"43407","inReplyTo":"20061130115913.EA36C5BA19@nox.op5.se","subject":"Re: [PATCH] git-diff: Introduce --index and deprecate --cached.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-09T02:24:31Z","receivedAt":"2006-12-09T02:24:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andreas Ericsson <ae@op5.se> writes:\n\n> 'git diff --cached' still works, but its use is discouraged\n> in the documentation. 'git diff --index' does the same thing\n> and is consistent with how 'git apply --index' works.\n\nAlthough I've applied this long time ago (in git timescale\nanyway), this patch and the above rationale is wrong.\n\n'diff --cached' is more in line with how 'apply --cached' works,\nnot how 'apply --index' works.\n\nWith apply, --cached and --index both tell the command to be\naware of the index, but --cached means \"operate on the index,\nand never look at working tree\", while --index means \"operate\nboth on the index and working tree at the same time\".  In\nparticular, the former does not care if the file in the working\ntree matches the index, while the latter does.\n\n'diff --cached' is about the tree and the index without looking\nat the working tree.  Since there is no mode of operation that\nlooks at both the index and the working tree in the underlying\ndiff-index, I made the mistake of applying this patch, but it is\nconceivable that we may want to have a 'diff --index' that\ncompares HEAD, the index and the working tree, perhaps in a\ncombined diff format.\n\nI think we should revert this patch.\n"},{"id":"294644","messageId":"7v64clg5u9.fsf@assigned-by-dhcp.cox.net","threadId":"43407","inReplyTo":"7vac1xg61s.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-diff: Introduce --index and deprecate --cached.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-09T02:29:02Z","receivedAt":"2006-12-09T02:29:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <junkio@cox.net> writes:\n\n> Although I've applied this long time ago (in git timescale\n> anyway), this patch and the above rationale is wrong.\n>\n> 'diff --cached' is more in line with how 'apply --cached' works,\n> not how 'apply --index' works.\n\nSide note.  I do not think --index and --cached are a good pair\nof words to express the different semantics (the former works on\nthe working tree through the index, the latter works only on the\ncached data and not on the working tree).  I was only pointing\nout that making 'diff --index' a synonym to 'diff --cached'\ncloses the door for the possibility to have these two semantics\nthat are consistently spelled (well, maybe \"confusingly\nspelled\", but still consistently) between diff and apply.\n"}]}