{"thread":{"id":"38347","subject":"How to prevent empty git commit --amend","startedAt":"2015-01-13T08:56:39Z","lastAt":"2015-03-05T20:27:53Z","messageCount":30,"participants":["Ivo Anjo","Daniel Knittl-Frank","Michael J Gruber","Matthieu Moy","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"254596","messageId":"CA+iO_8mLsdsf1PepiB4M9jJh7pX8brqPdiwAvWGMdfYO0YKrCQ@mail.gmail.com","threadId":"38347","inReplyTo":null,"subject":"How to prevent empty git commit --amend","fromName":"Ivo Anjo","fromEmail":"ivo.anjo@ist.utl.pt","sentAt":"2015-01-13T08:56:39Z","receivedAt":"2015-01-13T08:56:39Z","isPatch":false,"sender":{"key":"ivo.anjo@ist.utl.pt","avatar":"https://gravatar.com/avatar/ef7b8894c579c2173473c8f277639f3ed464bf8d5a2ede63f24054d637df6e65?d=mp&s=160"},"body":"Hello,\n\nI sometimes get a bit distracted when making amends. Once or twice per\nweek I do a commit, then realize I added something I shouldn't, or\nforgot to add a line here or there, and then I do a git commit --amend\nto fix it.\n\nThe thing is, a lot of times I forget to stage the modifications I did.\nAnd here is my issue: *git commit* refuses to work when there's\nnothing to commit, but *git commit --amend* happily pops up the editor\nand says you have committed something when you did not add/change\nanything.\n\nIs there a way to prevent a *git commit --amend** with nothing to\ncommit from working?\nIf not, I would like to suggest that this feature would be very helpful :)\n\nThanks for your time!\nIvo Anjo\n"},{"id":"254597","messageId":"CACx-yZ12mn-EyR5Mx9rmACLtyeYWRdyef4jDqdFAPzeQDm03ug@mail.gmail.com","threadId":"38347","inReplyTo":"CA+iO_8mLsdsf1PepiB4M9jJh7pX8brqPdiwAvWGMdfYO0YKrCQ@mail.gmail.com","subject":"Re: How to prevent empty git commit --amend","fromName":"Daniel Knittl-Frank","fromEmail":"knittl89@googlemail.com","sentAt":"2015-01-13T08:59:28Z","receivedAt":"2015-01-13T08:59:28Z","isPatch":false,"sender":{"key":"knittl89@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/2149217?v=4"},"body":"On Tue, Jan 13, 2015 at 9:56 AM, Ivo Anjo <ivo.anjo@ist.utl.pt> wrote:\n> Hello,\n>\n> I sometimes get a bit distracted when making amends. Once or twice per\n> week I do a commit, then realize I added something I shouldn't, or\n> forgot to add a line here or there, and then I do a git commit --amend\n> to fix it.\n>\n> The thing is, a lot of times I forget to stage the modifications I did.\n> And here is my issue: *git commit* refuses to work when there's\n> nothing to commit, but *git commit --amend* happily pops up the editor\n> and says you have committed something when you did not add/change\n> anything.\n>\n> Is there a way to prevent a *git commit --amend** with nothing to\n> commit from working?\n> If not, I would like to suggest that this feature would be very helpful :)\n\nHi Ivo,\n\nsimply delete all text from the commit editor and exit/save the empty\nfile. This will abort the commit.\n\nThe same logic applies to git rebase --interactive: deleting\neverything will do nothing.\n\nRegards,\nDaniel\n\n-- \ntyped with http://neo-layout.org\n"},{"id":"254600","messageId":"CA+iO_8niTScwtYVRV-5wBNHOzr08k=1Vug0yH3+vQ-Y9GgyJKg@mail.gmail.com","threadId":"38347","inReplyTo":"CACx-yZ12mn-EyR5Mx9rmACLtyeYWRdyef4jDqdFAPzeQDm03ug@mail.gmail.com","subject":"Re: How to prevent empty git commit --amend","fromName":"Ivo Anjo","fromEmail":"ivo.anjo@ist.utl.pt","sentAt":"2015-01-13T10:22:02Z","receivedAt":"2015-01-13T10:22:02Z","isPatch":false,"sender":{"key":"ivo.anjo@ist.utl.pt","avatar":"https://gravatar.com/avatar/ef7b8894c579c2173473c8f277639f3ed464bf8d5a2ede63f24054d637df6e65?d=mp&s=160"},"body":"Hello Daniel,\n\nThanks for your answer!\n\nMy issue is not with cancelling the amend commit, is that because the\namend commit already lists changes to the files I am working on (those\nchanges that already went in the commit I was ammending), I don't\nrealize that I forgot to add what I changed. For instance:\n\n$ echo \"Hello\" >> readme.txt\n$ git add readme.txt\n$ git commit -m \"Add readme\"\n\n$ echo \"World\" >> readme.txt\n$ git commit --amend\n\nnow if I just save and close the editor git will say it committed\nsuccessfully (which it did), but in reality nothing at all happened.\n\nOf course I can check the status or some other things before/after the\namend commit, but since end up doing this error sometimes I was hoping\nI could set up git to stop me from doing it.\n\nIvo Anjo\n\nOn Tue, Jan 13, 2015 at 8:59 AM, Daniel Knittl-Frank\n<knittl89@googlemail.com> wrote:\n>\n> On Tue, Jan 13, 2015 at 9:56 AM, Ivo Anjo <ivo.anjo@ist.utl.pt> wrote:\n> > Hello,\n> >\n> > I sometimes get a bit distracted when making amends. Once or twice per\n> > week I do a commit, then realize I added something I shouldn't, or\n> > forgot to add a line here or there, and then I do a git commit --amend\n> > to fix it.\n> >\n> > The thing is, a lot of times I forget to stage the modifications I did.\n> > And here is my issue: *git commit* refuses to work when there's\n> > nothing to commit, but *git commit --amend* happily pops up the editor\n> > and says you have committed something when you did not add/change\n> > anything.\n> >\n> > Is there a way to prevent a *git commit --amend** with nothing to\n> > commit from working?\n> > If not, I would like to suggest that this feature would be very helpful :)\n>\n> Hi Ivo,\n>\n> simply delete all text from the commit editor and exit/save the empty\n> file. This will abort the commit.\n>\n> The same logic applies to git rebase --interactive: deleting\n> everything will do nothing.\n>\n> Regards,\n> Daniel\n>\n> --\n> typed with http://neo-layout.org\n"},{"id":"254602","messageId":"54B4FF90.2050306@drmicha.warpmail.net","threadId":"38347","inReplyTo":"CA+iO_8niTScwtYVRV-5wBNHOzr08k=1Vug0yH3+vQ-Y9GgyJKg@mail.gmail.com","subject":"Re: How to prevent empty git commit --amend","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2015-01-13T11:20:48Z","receivedAt":"2015-01-13T11:20:48Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Ivo Anjo schrieb am 13.01.2015 um 11:22:\n> Hello Daniel,\n> \n> Thanks for your answer!\n> \n> My issue is not with cancelling the amend commit, is that because the\n> amend commit already lists changes to the files I am working on (those\n> changes that already went in the commit I was ammending), I don't\n> realize that I forgot to add what I changed. For instance:\n> \n> $ echo \"Hello\" >> readme.txt\n> $ git add readme.txt\n> $ git commit -m \"Add readme\"\n> \n> $ echo \"World\" >> readme.txt\n> $ git commit --amend\n> \n> now if I just save and close the editor git will say it committed\n> successfully (which it did), but in reality nothing at all happened.\n> \n> Of course I can check the status or some other things before/after the\n> amend commit, but since end up doing this error sometimes I was hoping\n> I could set up git to stop me from doing it.\n\n\"git commit --amend\" is (also) the way to edit the last commit message,\nand for that you need to be able to do an \"empty\" amend.\n\nIn your example above, git will also tell you that you have unstaged\nchanges to readme.txt.\n\nIf that isn't enough, you can use \"-v\" to display the diff in the editor\n(and remove it).\n\nMichael\n"},{"id":"254639","messageId":"vpqzj9lfzqg.fsf@anie.imag.fr","threadId":"38347","inReplyTo":"CA+iO_8mLsdsf1PepiB4M9jJh7pX8brqPdiwAvWGMdfYO0YKrCQ@mail.gmail.com","subject":"Re: How to prevent empty git commit --amend","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-01-14T10:00:55Z","receivedAt":"2015-01-14T10:00:55Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Ivo Anjo <ivo.anjo@ist.utl.pt> writes:\n\n> Is there a way to prevent a *git commit --amend** with nothing to\n> commit from working?\n> If not, I would like to suggest that this feature would be very helpful :)\n\nI don't know any way to let Git do the check for you, but \n\ngit diff --staged --quiet || git commit --amend\n\nshould do it. You can alias it like\n\n[alias]\n\tamend = !git diff --staged --quiet || git commit --amend\n\nand then use \"git amend\".\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"254645","messageId":"CA+iO_8nmrw7SiXWS22VcEHObQDJYDwKqRPariAmv5DzUvzAdsQ@mail.gmail.com","threadId":"38347","inReplyTo":"vpqzj9lfzqg.fsf@anie.imag.fr","subject":"Re: How to prevent empty git commit --amend","fromName":"Ivo Anjo","fromEmail":"ivo.anjo@ist.utl.pt","sentAt":"2015-01-14T12:15:16Z","receivedAt":"2015-01-14T12:15:16Z","isPatch":false,"sender":{"key":"ivo.anjo@ist.utl.pt","avatar":"https://gravatar.com/avatar/ef7b8894c579c2173473c8f277639f3ed464bf8d5a2ede63f24054d637df6e65?d=mp&s=160"},"body":"Hello,\n\nOn Wed, Jan 14, 2015 at 10:00 AM, Matthieu Moy\n<Matthieu.Moy@grenoble-inp.fr> wrote:\n> I don't know any way to let Git do the check for you, but\n>\n> git diff --staged --quiet || git commit --amend\n>\n> should do it. You can alias it like\n>\n> [alias]\n>         amend = !git diff --staged --quiet || git commit --amend\n>\n> and then use \"git amend\".\n\nGenius! This is exactly what I wanted, thanks!\n\nIvo Anjo\n"},{"id":"254649","messageId":"vpqvbk9a5uc.fsf@anie.imag.fr","threadId":"38347","inReplyTo":"CA+iO_8nmrw7SiXWS22VcEHObQDJYDwKqRPariAmv5DzUvzAdsQ@mail.gmail.com","subject":"Re: How to prevent empty git commit --amend","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-01-14T12:45:31Z","receivedAt":"2015-01-14T12:45:31Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Ivo Anjo <ivo.anjo@ist.utl.pt> writes:\n\n> Hello,\n>\n> On Wed, Jan 14, 2015 at 10:00 AM, Matthieu Moy\n> <Matthieu.Moy@grenoble-inp.fr> wrote:\n>> [alias]\n>>         amend = !git diff --staged --quiet || git commit --amend\n>>\n>> and then use \"git amend\".\n>\n> Genius! This is exactly what I wanted, thanks!\n\nYou probably want to tweak the alias by adding a && echo \"Nothing to\ncommit, sorry\" (or an if/then/fi) after git diff to get the appropriate\nerror message though.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"254660","messageId":"xmqqfvbdb7dc.fsf@gitster.dls.corp.google.com","threadId":"38347","inReplyTo":"vpqzj9lfzqg.fsf@anie.imag.fr","subject":"Re: How to prevent empty git commit --amend","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-01-14T17:27:11Z","receivedAt":"2015-01-14T17:27:11Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> Ivo Anjo <ivo.anjo@ist.utl.pt> writes:\n>\n>> Is there a way to prevent a *git commit --amend** with nothing to\n>> commit from working?\n>> If not, I would like to suggest that this feature would be very helpful :)\n>\n> I don't know any way to let Git do the check for you, but \n>\n> git diff --staged --quiet || git commit --amend\n>\n> should do it. You can alias it like\n>\n> [alias]\n> \tamend = !git diff --staged --quiet || git commit --amend\n>\n> and then use \"git amend\".\n\nThat would not let you say \"git amend Makefile\", no?\n\n\t!sh -c 'git diff --cached --quiet \"$@\" || git commit --amend \"$@\"' -\n\nor something, perhaps?\n"},{"id":"254666","messageId":"xmqq387db6xy.fsf@gitster.dls.corp.google.com","threadId":"38347","inReplyTo":"xmqqfvbdb7dc.fsf@gitster.dls.corp.google.com","subject":"Re: How to prevent empty git commit --amend","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-01-14T17:36:25Z","receivedAt":"2015-01-14T17:36:25Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n>\n>> Ivo Anjo <ivo.anjo@ist.utl.pt> writes:\n>>\n>>> Is there a way to prevent a *git commit --amend** with nothing to\n>>> commit from working?\n>>> If not, I would like to suggest that this feature would be very helpful :)\n>>\n>> I don't know any way to let Git do the check for you, but \n>>\n>> git diff --staged --quiet || git commit --amend\n>>\n>> should do it. You can alias it like\n>>\n>> [alias]\n>> \tamend = !git diff --staged --quiet || git commit --amend\n>>\n>> and then use \"git amend\".\n>\n> That would not let you say \"git amend Makefile\", no?\n>\n> \t!sh -c 'git diff --cached --quiet \"$@\" || git commit --amend \"$@\"' -\n>\n> or something, perhaps?\n\nHeh, not that but something like that ;-).\n\n * If we have pathspec, we would want to see if the HEAD and the\n   working tree differ at the given paths;\n\n * Otherwise we would want to see if the HEAD and the index differ.\n\nSo it would be more like this, I guess.\n\n\tcase \"$#\" in\n        0)\tgit diff --quiet --cached ;;\n        *)\tgit diff --quiet HEAD -- \"$@\" ;;\n\tesac || git commit --amend ${1+--} \"$@\"\n"},{"id":"254750","messageId":"038e08973a5872ea13a0ea76bf2a0443fe3c3b50.1421337740.git.git@drmicha.warpmail.net","threadId":"38347","inReplyTo":"xmqq387db6xy.fsf@gitster.dls.corp.google.com","subject":"[RFC/PATCH] commit/status: show the index-worktree with -v -v","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2015-01-15T16:08:03Z","receivedAt":"2015-01-15T16:08:03Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"git commit and git status in long format show the diff between HEAD\nand the index when given -v. This allows previewing a commit to be made.\n\nThey also list tracked files with unstaged changes, but without a diff.\n\nIntroduce '-v -v' which shows the diff between the index and the\nworktree in addition to HEAD index diff. This allows to review unstaged\nchanges which might be missing from the commit.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\nAlso, the git status man page does not mention -v at all, and the doc\nfor git status (long format) and the status parts of the git commit\nman page should really be the same.\n\nIn any case, this may have helped the OP with his amend oversight.\n\n Documentation/git-commit.txt | 4 ++++\n wt-status.c                  | 8 ++++++++\n 2 files changed, 12 insertions(+)\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex 1e74b75..f14d2ec 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -284,6 +284,10 @@ configuration variable documented in linkgit:git-config[1].\n \twould be committed at the bottom of the commit message\n \ttemplate.  Note that this diff output doesn't have its\n \tlines prefixed with '#'.\n++\n+If specified twice, show in addition the unified diff between\n+what would be committed and the worktree files, i.e. the unstaged\n+changes to tracked files.\n \n -q::\n --quiet::\ndiff --git a/wt-status.c b/wt-status.c\nindex b54eac5..75674c2 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -874,6 +874,14 @@ static void wt_status_print_verbose(struct wt_status *s)\n \t\twt_status_add_cut_line(s->fp);\n \t}\n \trun_diff_index(&rev, 1);\n+\tif (s->verbose > 1) {\n+\t\tsetup_work_tree();\n+\t\tif (read_cache_preload(&rev.diffopt.pathspec) < 0)\n+\t\t\tperror(\"read_cache_preload\");\n+\t\trev.diffopt.a_prefix = 0; /* allow run_diff_files */\n+\t\trev.diffopt.b_prefix = 0; /* to reset the prefixes */\n+\t\trun_diff_files(&rev, 0);\n+\t}\n }\n \n static void wt_status_print_tracking(struct wt_status *s)\n-- \n2.3.0.rc0.202.g6f441c7\n"},{"id":"254772","messageId":"xmqq1tmv7qjg.fsf@gitster.dls.corp.google.com","threadId":"38347","inReplyTo":"038e08973a5872ea13a0ea76bf2a0443fe3c3b50.1421337740.git.git@drmicha.warpmail.net","subject":"Re: [RFC/PATCH] commit/status: show the index-worktree with -v -v","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-01-15T20:11:15Z","receivedAt":"2015-01-15T20:11:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> git commit and git status in long format show the diff between HEAD\n> and the index when given -v. This allows previewing a commit to be made.\n>\n> They also list tracked files with unstaged changes, but without a diff.\n>\n> Introduce '-v -v' which shows the diff between the index and the\n> worktree in addition to HEAD index diff. This allows to review unstaged\n> changes which might be missing from the commit.\n>\n> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n> ---\n> Also, the git status man page does not mention -v at all, and the doc\n> for git status (long format) and the status parts of the git commit\n> man page should really be the same.\n>\n> In any case, this may have helped the OP with his amend oversight.\n\nHmm, does this show what change relative to HEAD is committed fully\nand then after that show what change relative to the index being\ncommited remains in the working tree at the end?  \n\nI do not think that output order is very helpful.  Two diffs to the\nsame file next to each other may make it easier to notice, though.\nThat is, not like this:\n\n\tdiff --git a/A b/A\n        ...\n        diff --git a/B b/B\n        ...\n        diff --git i/A w/A\n        ...\n\nbut like this:\n\n\tdiff --git a/A b/A\n        ...\n        diff --git i/A w/A\n        ...\n        diff --git a/B b/B\n        ...\n\nor it may want to even be like this:\n\n\tdiff --git a/A b/A\n        ...\n        diff --git to-be-committed/A left-out-of-the-commit/A\n        ...\n        diff --git a/B b/B\n        ...\n\nby using a custom, unusual and easy-to-notice prefixes.\n\n>  Documentation/git-commit.txt | 4 ++++\n>  wt-status.c                  | 8 ++++++++\n>  2 files changed, 12 insertions(+)\n>\n> diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\n> index 1e74b75..f14d2ec 100644\n> --- a/Documentation/git-commit.txt\n> +++ b/Documentation/git-commit.txt\n> @@ -284,6 +284,10 @@ configuration variable documented in linkgit:git-config[1].\n>  \twould be committed at the bottom of the commit message\n>  \ttemplate.  Note that this diff output doesn't have its\n>  \tlines prefixed with '#'.\n> ++\n> +If specified twice, show in addition the unified diff between\n> +what would be committed and the worktree files, i.e. the unstaged\n> +changes to tracked files.\n>  \n>  -q::\n>  --quiet::\n> diff --git a/wt-status.c b/wt-status.c\n> index b54eac5..75674c2 100644\n> --- a/wt-status.c\n> +++ b/wt-status.c\n> @@ -874,6 +874,14 @@ static void wt_status_print_verbose(struct wt_status *s)\n>  \t\twt_status_add_cut_line(s->fp);\n>  \t}\n>  \trun_diff_index(&rev, 1);\n> +\tif (s->verbose > 1) {\n> +\t\tsetup_work_tree();\n> +\t\tif (read_cache_preload(&rev.diffopt.pathspec) < 0)\n> +\t\t\tperror(\"read_cache_preload\");\n\nHmm, as we have run diff-index already, we must have had the index\nloaded, no?  What is going on here?\n\n> +\t\trev.diffopt.a_prefix = 0; /* allow run_diff_files */\n> +\t\trev.diffopt.b_prefix = 0; /* to reset the prefixes */\n\nThis is not just \"allow to reset the prefixes\", but forces the use\nof mnemonic prefixes to make sure they look different from the\nnormal \"diff --cached\" output that shows what is going to be\ncommitted.  If we were to do this, for consistency, we may want to\nuse the mnemonic prefix for the \"to be commited\" part, no?\n\n> +\t\trun_diff_files(&rev, 0);\n> +\t}\n>  }\n>  \n>  static void wt_status_print_tracking(struct wt_status *s)\n"},{"id":"254775","messageId":"xmqqoapz6aq5.fsf@gitster.dls.corp.google.com","threadId":"38347","inReplyTo":"xmqq1tmv7qjg.fsf@gitster.dls.corp.google.com","subject":"Re: [RFC/PATCH] commit/status: show the index-worktree with -v -v","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-01-15T20:38:10Z","receivedAt":"2015-01-15T20:38:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> I do not think that output order is very helpful.  Two diffs to the\n> same file next to each other may make it easier to notice, though.\n> ...\n> or it may want to even be like this:\n>\n> \t  diff --git a/A b/A\n>         ...\n>         diff --git to-be-committed/A left-out-of-the-commit/A\n>         ...\n>         diff --git a/B b/B\n>         ...\n>\n> by using a custom, unusual and easy-to-notice prefixes.\n\nFWIW, with such a loud custom prefixes, I think it is OK to have all\nthe changes to be committed first and then everything that is left\nout at the end.\n"},{"id":"254804","messageId":"54B8C82E.8000707@drmicha.warpmail.net","threadId":"38347","inReplyTo":"xmqq1tmv7qjg.fsf@gitster.dls.corp.google.com","subject":"Re: [RFC/PATCH] commit/status: show the index-worktree with -v -v","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2015-01-16T08:13:34Z","receivedAt":"2015-01-16T08:13:34Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Junio C Hamano schrieb am 15.01.2015 um 21:11:\n> Michael J Gruber <git@drmicha.warpmail.net> writes:\n> \n>> git commit and git status in long format show the diff between HEAD\n>> and the index when given -v. This allows previewing a commit to be made.\n>>\n>> They also list tracked files with unstaged changes, but without a diff.\n>>\n>> Introduce '-v -v' which shows the diff between the index and the\n>> worktree in addition to HEAD index diff. This allows to review unstaged\n>> changes which might be missing from the commit.\n>>\n>> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n>> ---\n>> Also, the git status man page does not mention -v at all, and the doc\n>> for git status (long format) and the status parts of the git commit\n>> man page should really be the same.\n>>\n>> In any case, this may have helped the OP with his amend oversight.\n> \n> Hmm, does this show what change relative to HEAD is committed fully\n> and then after that show what change relative to the index being\n> commited remains in the working tree at the end?  \n> \n> I do not think that output order is very helpful.  Two diffs to the\n> same file next to each other may make it easier to notice, though.\n> That is, not like this:\n> \n> \tdiff --git a/A b/A\n>         ...\n>         diff --git a/B b/B\n>         ...\n>         diff --git i/A w/A\n>         ...\n> \n> but like this:\n> \n> \tdiff --git a/A b/A\n>         ...\n>         diff --git i/A w/A\n>         ...\n>         diff --git a/B b/B\n>         ...\n> \n> or it may want to even be like this:\n> \n> \tdiff --git a/A b/A\n>         ...\n>         diff --git to-be-committed/A left-out-of-the-commit/A\n>         ...\n>         diff --git a/B b/B\n>         ...\n> \n> by using a custom, unusual and easy-to-notice prefixes.\n> \n>>  Documentation/git-commit.txt | 4 ++++\n>>  wt-status.c                  | 8 ++++++++\n>>  2 files changed, 12 insertions(+)\n>>\n>> diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\n>> index 1e74b75..f14d2ec 100644\n>> --- a/Documentation/git-commit.txt\n>> +++ b/Documentation/git-commit.txt\n>> @@ -284,6 +284,10 @@ configuration variable documented in linkgit:git-config[1].\n>>  \twould be committed at the bottom of the commit message\n>>  \ttemplate.  Note that this diff output doesn't have its\n>>  \tlines prefixed with '#'.\n>> ++\n>> +If specified twice, show in addition the unified diff between\n>> +what would be committed and the worktree files, i.e. the unstaged\n>> +changes to tracked files.\n>>  \n>>  -q::\n>>  --quiet::\n>> diff --git a/wt-status.c b/wt-status.c\n>> index b54eac5..75674c2 100644\n>> --- a/wt-status.c\n>> +++ b/wt-status.c\n>> @@ -874,6 +874,14 @@ static void wt_status_print_verbose(struct wt_status *s)\n>>  \t\twt_status_add_cut_line(s->fp);\n>>  \t}\n>>  \trun_diff_index(&rev, 1);\n>> +\tif (s->verbose > 1) {\n>> +\t\tsetup_work_tree();\n>> +\t\tif (read_cache_preload(&rev.diffopt.pathspec) < 0)\n>> +\t\t\tperror(\"read_cache_preload\");\n> \n> Hmm, as we have run diff-index already, we must have had the index\n> loaded, no?  What is going on here?\n\nIt was late and simply calling run_diff_files() didn't work (because of\nthe missing setup_work_tree()), so I added the lines from our diff.c and\noverlooked that read_cache_preload() must have happened somewhere already.\n\n>> +\t\trev.diffopt.a_prefix = 0; /* allow run_diff_files */\n>> +\t\trev.diffopt.b_prefix = 0; /* to reset the prefixes */\n> \n> This is not just \"allow to reset the prefixes\", but forces the use\n> of mnemonic prefixes to make sure they look different from the\n> normal \"diff --cached\" output that shows what is going to be\n> committed.  If we were to do this, for consistency, we may want to\n> use the mnemonic prefix for the \"to be commited\" part, no?\n\nI guess here I got blinded by me default config which does that.\n\n> \n>> +\t\trun_diff_files(&rev, 0);\n>> +\t}\n>>  }\n>>  \n>>  static void wt_status_print_tracking(struct wt_status *s)\n\nI really like your suggestion to use more verbose prefixes here for both\ncases. I guess we can do without additional subheadings for the diffs then.\n\nAs for the helpfulness, the intention was to show the diff for the two\ncategories of changes which \"git status\" lists without diff already:\n\n- changes to be committed (+index -HEAD) aka \"git diff --cached\"\n- changes present in worktree not to be committed (+worktree -index) aka\n\"git diff\"\n\nThe paths which would appear in the diff \"+worktree -HEAD\" are not\nmentioned in \"git status\" per se (as a category with subheading),\nalthough they fall into at least 1 of the 2 categories, of course.\n\nMichael\n"},{"id":"256901","messageId":"cover.1425390756.git.git@drmicha.warpmail.net","threadId":"38347","inReplyTo":"54B8C82E.8000707@drmicha.warpmail.net","subject":"[PATCHv2 0/2] More diffs for commit/status","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2015-03-03T14:16:20Z","receivedAt":"2015-03-03T14:16:20Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Trying to clean up my old RFCs, so here's a mini-series that\n\n1) adds a test for \"status -v\" (the diff between HEAD and index) and\n2) implements \"status -v -v\" (additional diff between index and worktree).\n\nThe idea is that in a case where \"commit -v\" would list fils with unstaged\nchanges one would get the diff for these changes with '-v -v' easily.\n\n2/2 also sets the diff prefixes (a/,b/ etc.) for both diffs in the '-v -v'\ncase to a really verbose version to avoid any confusion between the two\ntypes of diffs. We may want to do that for '-v' already, although that\nwould be a change in behavior.\n\nThe wording for the new prefixes is chosen after the status hints, although\nthey are not localised.\n\nMichael J Gruber (2):\n  t7508: test git status -v\n  commit/status: show the index-worktree diff with -v -v\n\n Documentation/git-commit.txt |  4 ++++\n t/t7508-status.sh            | 49 ++++++++++++++++++++++++++++++++++++++++++++\n wt-status.c                  | 10 +++++++++\n 3 files changed, 63 insertions(+)\n\n-- \n2.3.1.303.g5174db1\n"},{"id":"256902","messageId":"4979bf9de04197c1cd0d4a6af1348b45d4b0894c.1425390756.git.git@drmicha.warpmail.net","threadId":"38347","inReplyTo":"54B8C82E.8000707@drmicha.warpmail.net","subject":"[PATCHv2 1/2] t7508: test git status -v","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2015-03-03T14:16:21Z","receivedAt":"2015-03-03T14:16:21Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n t/t7508-status.sh | 6 ++++++\n 1 file changed, 6 insertions(+)\n\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex 8ed5788..4989e98 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -133,6 +133,12 @@ test_expect_success 'status with status.displayCommentPrefix=false' '\n \ttest_i18ncmp expect output\n '\n \n+test_expect_success 'status -v' '\n+\tgit diff --cached >>expect &&\n+\tgit status -v >output &&\n+\ttest_cmp expect output\n+'\n+\n test_expect_success 'setup fake editor' '\n \tcat >.git/editor <<-\\EOF &&\n \t#! /bin/sh\n-- \n2.3.1.303.g5174db1\n"},{"id":"256900","messageId":"33591b47a7ea8cfa23a3bee05fbf8c0ce4a00b3d.1425390756.git.git@drmicha.warpmail.net","threadId":"38347","inReplyTo":"54B8C82E.8000707@drmicha.warpmail.net","subject":"[PATCHv2 2/2] commit/status: show the index-worktree diff with -v -v","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2015-03-03T14:16:22Z","receivedAt":"2015-03-03T14:16:22Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"git commit and git status in long format show the diff between HEAD\nand the index when given -v. This allows previewing a commit to be made.\n\nThey also list tracked files with unstaged changes, but without a diff.\n\nIntroduce '-v -v' which shows the diff between the index and the\nworktree in addition to the HEAD index diff. This allows a review of unstaged\nchanges which might be missing from the commit.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n Documentation/git-commit.txt |  4 ++++\n t/t7508-status.sh            | 43 +++++++++++++++++++++++++++++++++++++++++++\n wt-status.c                  | 10 ++++++++++\n 3 files changed, 57 insertions(+)\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex 1e74b75..f14d2ec 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -284,6 +284,10 @@ configuration variable documented in linkgit:git-config[1].\n \twould be committed at the bottom of the commit message\n \ttemplate.  Note that this diff output doesn't have its\n \tlines prefixed with '#'.\n++\n+If specified twice, show in addition the unified diff between\n+what would be committed and the worktree files, i.e. the unstaged\n+changes to tracked files.\n \n -q::\n --quiet::\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex 4989e98..6779195 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -139,6 +139,49 @@ test_expect_success 'status -v' '\n \ttest_cmp expect output\n '\n \n+cat >expect <<\\EOF\n+On branch master\n+Changes to be committed:\n+  (use \"git reset HEAD <file>...\" to unstage)\n+\n+\tnew file:   dir2/added\n+\n+Changes not staged for commit:\n+  (use \"git add <file>...\" to update what will be committed)\n+  (use \"git checkout -- <file>...\" to discard changes in working directory)\n+\n+\tmodified:   dir1/modified\n+\n+Untracked files:\n+  (use \"git add <file>...\" to include in what will be committed)\n+\n+\tdir1/untracked\n+\tdir2/modified\n+\tdir2/untracked\n+\texpect\n+\toutput\n+\tuntracked\n+\n+diff --git HEAD=base-commit/dir2/added INDEX=staged-for-commit/dir2/added\n+new file mode 100644\n+index 0000000..00750ed\n+--- /dev/null\n++++ INDEX=staged-for-commit/dir2/added\n+@@ -0,0 +1 @@\n++3\n+diff --git INDEX=staged-for-commit/dir1/modified WORKTREE=not-staged-for-commit/dir1/modified\n+index e69de29..d00491f 100644\n+--- INDEX=staged-for-commit/dir1/modified\n++++ WORKTREE=not-staged-for-commit/dir1/modified\n+@@ -0,0 +1 @@\n++1\n+EOF\n+\n+test_expect_success 'status -v -v' '\n+\tgit status -v -v >output &&\n+\ttest_cmp expect output\n+'\n+\n test_expect_success 'setup fake editor' '\n \tcat >.git/editor <<-\\EOF &&\n \t#! /bin/sh\ndiff --git a/wt-status.c b/wt-status.c\nindex 29666d0..b6e9837 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -873,7 +873,17 @@ static void wt_status_print_verbose(struct wt_status *s)\n \t\trev.diffopt.use_color = 0;\n \t\twt_status_add_cut_line(s->fp);\n \t}\n+\tif (s->verbose > 1) {\n+\t\trev.diffopt.a_prefix = \"HEAD=base-commit/\";\n+\t\trev.diffopt.b_prefix = \"INDEX=staged-for-commit/\";\n+\t} /* else use prefix as per user config */\n \trun_diff_index(&rev, 1);\n+\tif (s->verbose > 1) {\n+\t\tsetup_work_tree();\n+\t\trev.diffopt.a_prefix = \"INDEX=staged-for-commit/\";\n+\t\trev.diffopt.b_prefix = \"WORKTREE=not-staged-for-commit/\";\n+\t\trun_diff_files(&rev, 0);\n+\t}\n }\n \n static void wt_status_print_tracking(struct wt_status *s)\n-- \n2.3.1.303.g5174db1\n"},{"id":"256932","messageId":"xmqqr3t5aicu.fsf@gitster.dls.corp.google.com","threadId":"38347","inReplyTo":"4979bf9de04197c1cd0d4a6af1348b45d4b0894c.1425390756.git.git@drmicha.warpmail.net","subject":"Re: [PATCHv2 1/2] t7508: test git status -v","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-03-03T21:20:17Z","receivedAt":"2015-03-03T21:20:17Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n> ---\n>  t/t7508-status.sh | 6 ++++++\n>  1 file changed, 6 insertions(+)\n>\n> diff --git a/t/t7508-status.sh b/t/t7508-status.sh\n> index 8ed5788..4989e98 100755\n> --- a/t/t7508-status.sh\n> +++ b/t/t7508-status.sh\n> @@ -133,6 +133,12 @@ test_expect_success 'status with status.displayCommentPrefix=false' '\n>  \ttest_i18ncmp expect output\n>  '\n>  \n> +test_expect_success 'status -v' '\n> +\tgit diff --cached >>expect &&\n\nThis makes the test rely on the previous one succeeding.  Do we\ncare, or is reproducing what ought to be in 'expect' at this step\ntoo expensive?\n\n> +\tgit status -v >output &&\n> +\ttest_cmp expect output\n> +'\n> +\n>  test_expect_success 'setup fake editor' '\n>  \tcat >.git/editor <<-\\EOF &&\n>  \t#! /bin/sh\n"},{"id":"256933","messageId":"xmqqmw3tai1q.fsf@gitster.dls.corp.google.com","threadId":"38347","inReplyTo":"33591b47a7ea8cfa23a3bee05fbf8c0ce4a00b3d.1425390756.git.git@drmicha.warpmail.net","subject":"Re: [PATCHv2 2/2] commit/status: show the index-worktree diff with -v -v","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-03-03T21:26:57Z","receivedAt":"2015-03-03T21:26:57Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> +diff --git INDEX=staged-for-commit/dir1/modified WORKTREE=not-staged-for-commit/dir1/modified\n> +index e69de29..d00491f 100644\n> +--- INDEX=staged-for-commit/dir1/modified\n> ++++ WORKTREE=not-staged-for-commit/dir1/modified\n\nThis might be OK for a project like Git itself, but I suspect people\nwith long pathnames (like, eh, those in Java land) would not\nappreciate it.\n\nWouldn't mnemonic prefix, which the users are already familiar with,\nbe the most suitable tool for this disambiguation?  After all that\nwas what it was invented for 8 years ago.\n"},{"id":"256941","messageId":"xmqqioehafb2.fsf@gitster.dls.corp.google.com","threadId":"38347","inReplyTo":"xmqqr3t5aicu.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCHv2 1/2] t7508: test git status -v","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-03-03T22:26:09Z","receivedAt":"2015-03-03T22:26:09Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Michael J Gruber <git@drmicha.warpmail.net> writes:\n>\n>> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n>> ---\n>>  t/t7508-status.sh | 6 ++++++\n>>  1 file changed, 6 insertions(+)\n>>\n>> diff --git a/t/t7508-status.sh b/t/t7508-status.sh\n>> index 8ed5788..4989e98 100755\n>> --- a/t/t7508-status.sh\n>> +++ b/t/t7508-status.sh\n>> @@ -133,6 +133,12 @@ test_expect_success 'status with status.displayCommentPrefix=false' '\n>>  \ttest_i18ncmp expect output\n>>  '\n>>  \n>> +test_expect_success 'status -v' '\n>> +\tgit diff --cached >>expect &&\n>\n> This makes the test rely on the previous one succeeding.  Do we\n> care, or is reproducing what ought to be in 'expect' at this step\n> too expensive?\n\nAhh, OK.  The way the existing tests prepare 'expect' is \"by hand\".\n\nSo I think what is wrong with this new test is not that relies on\nthe current contents of 'expect', but that it modifies it (imagine\nbeing a merge/patch monkey who has to accept this change while a\nchange from somebody else that wants to add another test that relies\non the original 'expect' intact and then have to scratch his or her\nhead when the two topics are merged, wondering why the latter test\nstarts failing).\n\nPerhaps\n\n\t( cat expect && git diff --cached ) >expect-with-v &&\n        git status -v >actual &&\n        test_cmp expect-with-v actual\n\nor something?\n"},{"id":"256991","messageId":"54F6E716.5050808@drmicha.warpmail.net","threadId":"38347","inReplyTo":"xmqqioehafb2.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCHv2 1/2] t7508: test git status -v","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2015-03-04T11:05:58Z","receivedAt":"2015-03-04T11:05:58Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Junio C Hamano venit, vidit, dixit 03.03.2015 23:26:\n> Junio C Hamano <gitster@pobox.com> writes:\n> \n>> Michael J Gruber <git@drmicha.warpmail.net> writes:\n>>\n>>> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n>>> ---\n>>>  t/t7508-status.sh | 6 ++++++\n>>>  1 file changed, 6 insertions(+)\n>>>\n>>> diff --git a/t/t7508-status.sh b/t/t7508-status.sh\n>>> index 8ed5788..4989e98 100755\n>>> --- a/t/t7508-status.sh\n>>> +++ b/t/t7508-status.sh\n>>> @@ -133,6 +133,12 @@ test_expect_success 'status with status.displayCommentPrefix=false' '\n>>>  \ttest_i18ncmp expect output\n>>>  '\n>>>  \n>>> +test_expect_success 'status -v' '\n>>> +\tgit diff --cached >>expect &&\n>>\n>> This makes the test rely on the previous one succeeding.  Do we\n>> care, or is reproducing what ought to be in 'expect' at this step\n>> too expensive?\n> \n> Ahh, OK.  The way the existing tests prepare 'expect' is \"by hand\".\n> \n> So I think what is wrong with this new test is not that relies on\n> the current contents of 'expect', but that it modifies it (imagine\n> being a merge/patch monkey who has to accept this change while a\n> change from somebody else that wants to add another test that relies\n> on the original 'expect' intact and then have to scratch his or her\n> head when the two topics are merged, wondering why the latter test\n> starts failing).\n> \n> Perhaps\n> \n> \t( cat expect && git diff --cached ) >expect-with-v &&\n>         git status -v >actual &&\n>         test_cmp expect-with-v actual\n> \n> or something?\n\nThat's what I had first, but the new file shows up as untracked file in\nthe status output...\n\nI don't mind setting this one up by hand also, if you prefer.\n\nMichael\n"},{"id":"256992","messageId":"54F6E87F.2010605@drmicha.warpmail.net","threadId":"38347","inReplyTo":"xmqqmw3tai1q.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCHv2 2/2] commit/status: show the index-worktree diff with -v -v","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2015-03-04T11:11:59Z","receivedAt":"2015-03-04T11:11:59Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Junio C Hamano venit, vidit, dixit 03.03.2015 22:26:\n> Michael J Gruber <git@drmicha.warpmail.net> writes:\n> \n>> +diff --git INDEX=staged-for-commit/dir1/modified WORKTREE=not-staged-for-commit/dir1/modified\n>> +index e69de29..d00491f 100644\n>> +--- INDEX=staged-for-commit/dir1/modified\n>> ++++ WORKTREE=not-staged-for-commit/dir1/modified\n> \n> This might be OK for a project like Git itself, but I suspect people\n> with long pathnames (like, eh, those in Java land) would not\n> appreciate it.\n> \n> Wouldn't mnemonic prefix, which the users are already familiar with,\n> be the most suitable tool for this disambiguation?  After all that\n> was what it was invented for 8 years ago.\n\nWell...:\n\n> or it may want to even be like this:\n> \n> \tdiff --git a/A b/A\n>         ...\n>         diff --git to-be-committed/A left-out-of-the-commit/A\n>         ...\n>         diff --git a/B b/B\n>         ...\n> \n> by using a custom, unusual and easy-to-notice prefixes.\n\nYour idea was to use these verbous prefixes so that one recognizes the\ndifferent types of diffs, and so that we don't need to sort them by file.\n\nI'm happy with c/,i/ and i/,w/ and without sorting. Maybe we would need\nheadings between the two diffs then?\n\nHEAD/,INDEX/ resp. INDEX/,WORKTREE/ would be a shorter alternativ that\nis inline with the short acronyms execept for c/, because COMMIT/\n(withiut \"base\") would be misleading during commit -v, I'm afraid.\n\nMichael\n"},{"id":"257018","messageId":"xmqqr3t479ey.fsf@gitster.dls.corp.google.com","threadId":"38347","inReplyTo":"54F6E87F.2010605@drmicha.warpmail.net","subject":"Re: [PATCHv2 2/2] commit/status: show the index-worktree diff with -v -v","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-03-04T21:13:57Z","receivedAt":"2015-03-04T21:13:57Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> Junio C Hamano venit, vidit, dixit 03.03.2015 22:26:\n>> Michael J Gruber <git@drmicha.warpmail.net> writes:\n>> \n>>> +diff --git INDEX=staged-for-commit/dir1/modified\n>>> WORKTREE=not-staged-for-commit/dir1/modified\n>>> +index e69de29..d00491f 100644\n>>> +--- INDEX=staged-for-commit/dir1/modified\n>>> ++++ WORKTREE=not-staged-for-commit/dir1/modified\n>> \n>> This might be OK for a project like Git itself, but I suspect people\n>> with long pathnames (like, eh, those in Java land) would not\n>> appreciate it.\n>> \n>> Wouldn't mnemonic prefix, which the users are already familiar with,\n>> be the most suitable tool for this disambiguation?  After all that\n>> was what it was invented for 8 years ago.\n>\n> Well...:\n>\n>> or it may want to even be like this:\n>> \n>> \tdiff --git a/A b/A\n>>         ...\n>>         diff --git to-be-committed/A left-out-of-the-commit/A\n>>         ...\n>>         diff --git a/B b/B\n>>         ...\n>> \n>> by using a custom, unusual and easy-to-notice prefixes.\n>\n> Your idea was to use these verbous prefixes so that one recognizes the\n> different types of diffs, and so that we don't need to sort them by file.\n\nYeah, but I can become wiser over time and change my opinion, no\n;-)?\n\nAs to pairing the diffs by paths so that c/i and i/w diffs for the\nsame path come together, which I mentioned in the older message you\nquoted, I think what you said in response made sense, i.e. \"the\nintention was to show the diff for the two categories of changes\nwhich \"git status\" lists without diff already\".  So I'd prefer\nshowing c/i diff and then optionall i/w diff like you did, without\nmixing them together.\n\n> I'm happy with c/,i/ and i/,w/ and without sorting. Maybe we would need\n> headings between the two diffs then?\n\nYup.  The i/w diff is a new thing and a heading before it to explain\nwhat it is would be very helpful for the users to understand what\nthey are looking at.  A new heading before c/i diff might help but\nit may be OK without.  E.g. something along the following lines\n\n\n    Changes to be committed:\n        modified: foo\n\n    Changes left in the working tree:\n        modified: bar\n\n    --------------------------------------------------\n    Changes to be committed\n    diff --git c/foo i/foo\n    ...\n\n    \n    --------------------------------------------------\n    Changes left in the working tree\n    diff --git i/bar w/bsar\n    ...\n\n    \n"},{"id":"257020","messageId":"xmqqk2yw78rx.fsf@gitster.dls.corp.google.com","threadId":"38347","inReplyTo":"54F6E716.5050808@drmicha.warpmail.net","subject":"Re: [PATCHv2 1/2] t7508: test git status -v","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-03-04T21:27:46Z","receivedAt":"2015-03-04T21:27:46Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n>> Ahh, OK.  The way the existing tests prepare 'expect' is \"by hand\".\n>> \n>> So I think what is wrong with this new test is not that relies on\n>> the current contents of 'expect', but that it modifies it (imagine\n>> being a merge/patch monkey who has to accept this change while a\n>> change from somebody else that wants to add another test that relies\n>> on the original 'expect' intact and then have to scratch his or her\n>> head when the two topics are merged, wondering why the latter test\n>> starts failing).\n>> \n>> Perhaps\n>> \n>> \t( cat expect && git diff --cached ) >expect-with-v &&\n>>         git status -v >actual &&\n>>         test_cmp expect-with-v actual\n>> \n>> or something?\n>\n> That's what I had first, but the new file shows up as untracked file in\n> the status output...\n\nIf we step back and wonder why it is not a problem for the test\nto create 'expect' and 'output' that are not untracked, what would\nwe find?\n\nIt seems that there are two ways to do this:\n\n - Spell these out in 'expect' as untracked; or\n - Throw them in .gitignore to be ignored by 'status'.\n\nAs some other tests want to see how untracked files appear in the\noutput, I wonder if throwing expect and output that are already used\nin the test, together with the new \"expect-with-v\" and friends, to a\n.gitignore file might not be a better direction to go.\n\nPerhaps such a clean-up effort might begin with something like this\npatch?\n\n-- >8 --\nt7508: .gitignore 'expect' and 'output' files\n\nThese files are used to observe the behaviour of the 'status'\ncommand and if there weren't any such observer, the expected\noutput from 'status' wouldn't even mention them.\n\nPlace them in .gitignore to unclutter the output expected by the\ntests.  An added benefit is that future tests can add such files\nthat are purely for use by the observer, i.e. the tests themselves,\nby naming them as expect-foo and/or output-bar.\n\n\n---\n\n t/t7508-status.sh | 62 +++++--------------------------------------------------\n 1 file changed, 5 insertions(+), 57 deletions(-)\n\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex 8ed5788..9d944a3 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -320,7 +320,11 @@ EOF\n \ttest_i18ncmp expect output\n '\n \n-rm -f .gitignore\n+cat >.gitignore <<\\EOF\n+.gitignore\n+expect*\n+output*\n+EOF\n \n cat >expect <<\\EOF\n ## master\n@@ -329,8 +333,6 @@ A  dir2/added\n ?? dir1/untracked\n ?? dir2/modified\n ?? dir2/untracked\n-?? expect\n-?? output\n ?? untracked\n EOF\n \n@@ -434,8 +436,6 @@ Untracked files:\n \tdir2/modified\n \tdir2/untracked\n \tdir3/\n-\texpect\n-\toutput\n \tuntracked\n \n EOF\n@@ -456,8 +456,6 @@ A  dir2/added\n ?? dir2/modified\n ?? dir2/untracked\n ?? dir3/\n-?? expect\n-?? output\n ?? untracked\n EOF\n test_expect_success 'status -s -unormal' '\n@@ -493,8 +491,6 @@ Untracked files:\n \tdir2/untracked\n \tdir3/untracked1\n \tdir3/untracked2\n-\texpect\n-\toutput\n \tuntracked\n \n EOF\n@@ -518,8 +514,6 @@ A  dir2/added\n ?? dir1/untracked\n ?? dir2/modified\n ?? dir2/untracked\n-?? expect\n-?? output\n ?? untracked\n EOF\n test_expect_success 'status -s -uall' '\n@@ -554,8 +548,6 @@ Untracked files:\n \tuntracked\n \t../dir2/modified\n \t../dir2/untracked\n-\t../expect\n-\t../output\n \t../untracked\n \n EOF\n@@ -569,8 +561,6 @@ A  ../dir2/added\n ?? untracked\n ?? ../dir2/modified\n ?? ../dir2/untracked\n-?? ../expect\n-?? ../output\n ?? ../untracked\n EOF\n test_expect_success 'status -s with relative paths' '\n@@ -586,8 +576,6 @@ A  dir2/added\n ?? dir1/untracked\n ?? dir2/modified\n ?? dir2/untracked\n-?? expect\n-?? output\n ?? untracked\n EOF\n \n@@ -625,8 +613,6 @@ Untracked files:\n \t<BLUE>dir1/untracked<RESET>\n \t<BLUE>dir2/modified<RESET>\n \t<BLUE>dir2/untracked<RESET>\n-\t<BLUE>expect<RESET>\n-\t<BLUE>output<RESET>\n \t<BLUE>untracked<RESET>\n \n EOF\n@@ -647,8 +633,6 @@ cat >expect <<\\EOF\n <BLUE>??<RESET> dir1/untracked\n <BLUE>??<RESET> dir2/modified\n <BLUE>??<RESET> dir2/untracked\n-<BLUE>??<RESET> expect\n-<BLUE>??<RESET> output\n <BLUE>??<RESET> untracked\n EOF\n \n@@ -676,8 +660,6 @@ cat >expect <<\\EOF\n <BLUE>??<RESET> dir1/untracked\n <BLUE>??<RESET> dir2/modified\n <BLUE>??<RESET> dir2/untracked\n-<BLUE>??<RESET> expect\n-<BLUE>??<RESET> output\n <BLUE>??<RESET> untracked\n EOF\n \n@@ -694,8 +676,6 @@ A  dir2/added\n ?? dir1/untracked\n ?? dir2/modified\n ?? dir2/untracked\n-?? expect\n-?? output\n ?? untracked\n EOF\n \n@@ -755,8 +735,6 @@ Untracked files:\n \tdir1/untracked\n \tdir2/modified\n \tdir2/untracked\n-\texpect\n-\toutput\n \tuntracked\n \n EOF\n@@ -772,8 +750,6 @@ A  dir2/added\n ?? dir1/untracked\n ?? dir2/modified\n ?? dir2/untracked\n-?? expect\n-?? output\n ?? untracked\n EOF\n \n@@ -798,8 +774,6 @@ Untracked files:\n \n \tdir1/untracked\n \tdir2/\n-\texpect\n-\toutput\n \tuntracked\n \n EOF\n@@ -848,8 +822,6 @@ Untracked files:\n \tdir1/untracked\n \tdir2/modified\n \tdir2/untracked\n-\texpect\n-\toutput\n \tuntracked\n \n EOF\n@@ -870,8 +842,6 @@ A  sm\n ?? dir1/untracked\n ?? dir2/modified\n ?? dir2/untracked\n-?? expect\n-?? output\n ?? untracked\n EOF\n test_expect_success 'status -s submodule summary is disabled by default' '\n@@ -913,8 +883,6 @@ Untracked files:\n \tdir1/untracked\n \tdir2/modified\n \tdir2/untracked\n-\texpect\n-\toutput\n \tuntracked\n \n EOF\n@@ -940,8 +908,6 @@ A  sm\n ?? dir1/untracked\n ?? dir2/modified\n ?? dir2/untracked\n-?? expect\n-?? output\n ?? untracked\n EOF\n test_expect_success 'status -s submodule summary' '\n@@ -964,8 +930,6 @@ Untracked files:\n \tdir1/untracked\n \tdir2/modified\n \tdir2/untracked\n-\texpect\n-\toutput\n \tuntracked\n \n no changes added to commit (use \"git add\" and/or \"git commit -a\")\n@@ -983,8 +947,6 @@ cat >expect <<EOF\n ?? dir1/untracked\n ?? dir2/modified\n ?? dir2/untracked\n-?? expect\n-?? output\n ?? untracked\n EOF\n test_expect_success 'status -s submodule summary (clean submodule)' '\n@@ -1025,8 +987,6 @@ Untracked files:\n \tdir1/untracked\n \tdir2/modified\n \tdir2/untracked\n-\texpect\n-\toutput\n \tuntracked\n \n EOF\n@@ -1080,8 +1040,6 @@ Untracked files:\n \tdir1/untracked\n \tdir2/modified\n \tdir2/untracked\n-\texpect\n-\toutput\n \tuntracked\n \n EOF\n@@ -1192,8 +1150,6 @@ Untracked files:\n \tdir1/untracked\n \tdir2/modified\n \tdir2/untracked\n-\texpect\n-\toutput\n \tuntracked\n \n EOF\n@@ -1254,8 +1210,6 @@ Untracked files:\n \tdir1/untracked\n \tdir2/modified\n \tdir2/untracked\n-\texpect\n-\toutput\n \tuntracked\n \n EOF\n@@ -1336,8 +1290,6 @@ cat > expect << EOF\n ;\tdir1/untracked\n ;\tdir2/modified\n ;\tdir2/untracked\n-;\texpect\n-;\toutput\n ;\tuntracked\n ;\n EOF\n@@ -1369,8 +1321,6 @@ Untracked files:\n \tdir1/untracked\n \tdir2/modified\n \tdir2/untracked\n-\texpect\n-\toutput\n \tuntracked\n \n no changes added to commit (use \"git add\" and/or \"git commit -a\")\n@@ -1400,8 +1350,6 @@ Untracked files:\n \tdir1/untracked\n \tdir2/modified\n \tdir2/untracked\n-\texpect\n-\toutput\n \tuntracked\n \n EOF\n"},{"id":"257075","messageId":"cover.1425564336.git.git@drmicha.warpmail.net","threadId":"38347","inReplyTo":"xmqqr3t479ey.fsf@gitster.dls.corp.google.com","subject":"[PATCHv3 0/3]More diffs for commit/status","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2015-03-05T14:13:01Z","receivedAt":"2015-03-05T14:13:01Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"v3 has the following changes:\n- new leading patch by Junio to clean up t7508 (slightly modified by myself)\n- adjust tests accordingly\n- revert back to standard c/,i/ resp. i/,w/ diff prefixes with a header line\n\nOpen questionis for 3/3:\n- Do we need the header to stick out even more? (I don't think so, although\n  having the STATUS_HEADER color to be different may help.)\n- Do we want the header line also for \"status -v\"? (I would say yes, but that\n  would be a change to current behaviour.)\n\nJunio C Hamano (1):\n  t7508: .gitignore 'expect' and 'output' files\n\nMichael J Gruber (2):\n  t7508: test git status -v\n  commit/status: show the index-worktree diff with -v -v\n\n Documentation/git-commit.txt |   4 ++\n t/t7508-status.sh            | 102 +++++++++++++++----------------------------\n wt-status.c                  |  16 +++++++\n 3 files changed, 55 insertions(+), 67 deletions(-)\n\n-- \n2.3.1.303.g5174db1\n"},{"id":"257076","messageId":"3d26af588ac54fd3060952b140c035f28b1b655b.1425564336.git.git@drmicha.warpmail.net","threadId":"38347","inReplyTo":"xmqqr3t479ey.fsf@gitster.dls.corp.google.com","subject":"[PATCHv3 1/3] t7508: .gitignore 'expect' and 'output' files","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2015-03-05T14:13:02Z","receivedAt":"2015-03-05T14:13:02Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"From: Junio C Hamano <gitster@pobox.com>\n\nThese files are used to observe the behaviour of the 'status'\ncommand and if there weren't any such observer, the expected\noutput from 'status' wouldn't even mention them.\n\nPlace them in .gitignore to unclutter the output expected by the\ntests.  An added benefit is that future tests can add such files\nthat are purely for use by the observer, i.e. the tests themselves,\nby naming them as expect-foo and/or output-bar.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n t/t7508-status.sh | 78 ++++++++++---------------------------------------------\n 1 file changed, 13 insertions(+), 65 deletions(-)\n\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex 8ed5788..514df67 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -66,6 +66,12 @@ strip_comments () {\n \trm \"$1\" && mv \"$1\".tmp \"$1\"\n }\n \n+cat >.gitignore <<\\EOF\n+.gitignore\n+expect*\n+output*\n+EOF\n+\n test_expect_success 'status --column' '\n \tcat >expect <<\\EOF &&\n # On branch master\n@@ -83,8 +89,8 @@ test_expect_success 'status --column' '\n # Untracked files:\n #   (use \"git add <file>...\" to include in what will be committed)\n #\n-#\tdir1/untracked dir2/untracked output\n-#\tdir2/modified  expect         untracked\n+#\tdir1/untracked dir2/untracked\n+#\tdir2/modified  untracked\n #\n EOF\n \tCOLUMNS=50 git -c status.displayCommentPrefix=true status --column=\"column dense\" >output &&\n@@ -116,8 +122,6 @@ cat >expect <<\\EOF\n #\tdir1/untracked\n #\tdir2/modified\n #\tdir2/untracked\n-#\texpect\n-#\toutput\n #\tuntracked\n #\n EOF\n@@ -167,8 +171,6 @@ Untracked files:\n \tdir1/untracked\n \tdir2/modified\n \tdir2/untracked\n-\texpect\n-\toutput\n \tuntracked\n \n EOF\n@@ -186,8 +188,6 @@ A  dir2/added\n ?? dir1/untracked\n ?? dir2/modified\n ?? dir2/untracked\n-?? expect\n-?? output\n ?? untracked\n EOF\n \n@@ -320,7 +320,11 @@ EOF\n \ttest_i18ncmp expect output\n '\n \n-rm -f .gitignore\n+cat >.gitignore <<\\EOF\n+.gitignore\n+expect*\n+output*\n+EOF\n \n cat >expect <<\\EOF\n ## master\n@@ -329,8 +333,6 @@ A  dir2/added\n ?? dir1/untracked\n ?? dir2/modified\n ?? dir2/untracked\n-?? expect\n-?? output\n ?? untracked\n EOF\n \n@@ -434,8 +436,6 @@ Untracked files:\n \tdir2/modified\n \tdir2/untracked\n \tdir3/\n-\texpect\n-\toutput\n \tuntracked\n \n EOF\n@@ -456,8 +456,6 @@ A  dir2/added\n ?? dir2/modified\n ?? dir2/untracked\n ?? dir3/\n-?? expect\n-?? output\n ?? untracked\n EOF\n test_expect_success 'status -s -unormal' '\n@@ -493,8 +491,6 @@ Untracked files:\n \tdir2/untracked\n \tdir3/untracked1\n \tdir3/untracked2\n-\texpect\n-\toutput\n \tuntracked\n \n EOF\n@@ -518,8 +514,6 @@ A  dir2/added\n ?? dir1/untracked\n ?? dir2/modified\n ?? dir2/untracked\n-?? expect\n-?? output\n ?? untracked\n EOF\n test_expect_success 'status -s -uall' '\n@@ -554,8 +548,6 @@ Untracked files:\n \tuntracked\n \t../dir2/modified\n \t../dir2/untracked\n-\t../expect\n-\t../output\n \t../untracked\n \n EOF\n@@ -569,8 +561,6 @@ A  ../dir2/added\n ?? untracked\n ?? ../dir2/modified\n ?? ../dir2/untracked\n-?? ../expect\n-?? ../output\n ?? ../untracked\n EOF\n test_expect_success 'status -s with relative paths' '\n@@ -586,8 +576,6 @@ A  dir2/added\n ?? dir1/untracked\n ?? dir2/modified\n ?? dir2/untracked\n-?? expect\n-?? output\n ?? untracked\n EOF\n \n@@ -625,8 +613,6 @@ Untracked files:\n \t<BLUE>dir1/untracked<RESET>\n \t<BLUE>dir2/modified<RESET>\n \t<BLUE>dir2/untracked<RESET>\n-\t<BLUE>expect<RESET>\n-\t<BLUE>output<RESET>\n \t<BLUE>untracked<RESET>\n \n EOF\n@@ -647,8 +633,6 @@ cat >expect <<\\EOF\n <BLUE>??<RESET> dir1/untracked\n <BLUE>??<RESET> dir2/modified\n <BLUE>??<RESET> dir2/untracked\n-<BLUE>??<RESET> expect\n-<BLUE>??<RESET> output\n <BLUE>??<RESET> untracked\n EOF\n \n@@ -676,8 +660,6 @@ cat >expect <<\\EOF\n <BLUE>??<RESET> dir1/untracked\n <BLUE>??<RESET> dir2/modified\n <BLUE>??<RESET> dir2/untracked\n-<BLUE>??<RESET> expect\n-<BLUE>??<RESET> output\n <BLUE>??<RESET> untracked\n EOF\n \n@@ -694,8 +676,6 @@ A  dir2/added\n ?? dir1/untracked\n ?? dir2/modified\n ?? dir2/untracked\n-?? expect\n-?? output\n ?? untracked\n EOF\n \n@@ -755,8 +735,6 @@ Untracked files:\n \tdir1/untracked\n \tdir2/modified\n \tdir2/untracked\n-\texpect\n-\toutput\n \tuntracked\n \n EOF\n@@ -772,8 +750,6 @@ A  dir2/added\n ?? dir1/untracked\n ?? dir2/modified\n ?? dir2/untracked\n-?? expect\n-?? output\n ?? untracked\n EOF\n \n@@ -798,8 +774,6 @@ Untracked files:\n \n \tdir1/untracked\n \tdir2/\n-\texpect\n-\toutput\n \tuntracked\n \n EOF\n@@ -848,8 +822,6 @@ Untracked files:\n \tdir1/untracked\n \tdir2/modified\n \tdir2/untracked\n-\texpect\n-\toutput\n \tuntracked\n \n EOF\n@@ -870,8 +842,6 @@ A  sm\n ?? dir1/untracked\n ?? dir2/modified\n ?? dir2/untracked\n-?? expect\n-?? output\n ?? untracked\n EOF\n test_expect_success 'status -s submodule summary is disabled by default' '\n@@ -913,8 +883,6 @@ Untracked files:\n \tdir1/untracked\n \tdir2/modified\n \tdir2/untracked\n-\texpect\n-\toutput\n \tuntracked\n \n EOF\n@@ -940,8 +908,6 @@ A  sm\n ?? dir1/untracked\n ?? dir2/modified\n ?? dir2/untracked\n-?? expect\n-?? output\n ?? untracked\n EOF\n test_expect_success 'status -s submodule summary' '\n@@ -964,8 +930,6 @@ Untracked files:\n \tdir1/untracked\n \tdir2/modified\n \tdir2/untracked\n-\texpect\n-\toutput\n \tuntracked\n \n no changes added to commit (use \"git add\" and/or \"git commit -a\")\n@@ -983,8 +947,6 @@ cat >expect <<EOF\n ?? dir1/untracked\n ?? dir2/modified\n ?? dir2/untracked\n-?? expect\n-?? output\n ?? untracked\n EOF\n test_expect_success 'status -s submodule summary (clean submodule)' '\n@@ -1025,8 +987,6 @@ Untracked files:\n \tdir1/untracked\n \tdir2/modified\n \tdir2/untracked\n-\texpect\n-\toutput\n \tuntracked\n \n EOF\n@@ -1080,8 +1040,6 @@ Untracked files:\n \tdir1/untracked\n \tdir2/modified\n \tdir2/untracked\n-\texpect\n-\toutput\n \tuntracked\n \n EOF\n@@ -1192,8 +1150,6 @@ Untracked files:\n \tdir1/untracked\n \tdir2/modified\n \tdir2/untracked\n-\texpect\n-\toutput\n \tuntracked\n \n EOF\n@@ -1254,8 +1210,6 @@ Untracked files:\n \tdir1/untracked\n \tdir2/modified\n \tdir2/untracked\n-\texpect\n-\toutput\n \tuntracked\n \n EOF\n@@ -1336,8 +1290,6 @@ cat > expect << EOF\n ;\tdir1/untracked\n ;\tdir2/modified\n ;\tdir2/untracked\n-;\texpect\n-;\toutput\n ;\tuntracked\n ;\n EOF\n@@ -1369,8 +1321,6 @@ Untracked files:\n \tdir1/untracked\n \tdir2/modified\n \tdir2/untracked\n-\texpect\n-\toutput\n \tuntracked\n \n no changes added to commit (use \"git add\" and/or \"git commit -a\")\n@@ -1400,8 +1350,6 @@ Untracked files:\n \tdir1/untracked\n \tdir2/modified\n \tdir2/untracked\n-\texpect\n-\toutput\n \tuntracked\n \n EOF\n-- \n2.3.1.303.g5174db1\n"},{"id":"257077","messageId":"b14c55bf72a73c9376ef22e4887cce0494009847.1425564336.git.git@drmicha.warpmail.net","threadId":"38347","inReplyTo":"xmqqr3t479ey.fsf@gitster.dls.corp.google.com","subject":"[PATCHv3 2/3] t7508: test git status -v","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2015-03-05T14:13:03Z","receivedAt":"2015-03-05T14:13:03Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"\"status -v\" had no test. Include one.\n\nThis also requires changing the .gitignore subtests, which is a good thing:\nthey include testing a .gitignore pattern now.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n t/t7508-status.sh | 14 ++++++++++++--\n 1 file changed, 12 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex 514df67..e3c9cf9 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -137,6 +137,12 @@ test_expect_success 'status with status.displayCommentPrefix=false' '\n \ttest_i18ncmp expect output\n '\n \n+test_expect_success 'status -v' '\n+\t(cat expect && git diff --cached) >expect-with-v &&\n+\tgit status -v >output &&\n+\ttest_i18ncmp expect-with-v output\n+'\n+\n test_expect_success 'setup fake editor' '\n \tcat >.git/editor <<-\\EOF &&\n \t#! /bin/sh\n@@ -201,7 +207,7 @@ test_expect_success 'status -s' '\n test_expect_success 'status with gitignore' '\n \t{\n \t\techo \".gitignore\" &&\n-\t\techo \"expect\" &&\n+\t\techo \"expect*\" &&\n \t\techo \"output\" &&\n \t\techo \"untracked\"\n \t} >.gitignore &&\n@@ -222,6 +228,7 @@ test_expect_success 'status with gitignore' '\n \t!! dir1/untracked\n \t!! dir2/untracked\n \t!! expect\n+\t!! expect-with-v\n \t!! output\n \t!! untracked\n \tEOF\n@@ -253,6 +260,7 @@ Ignored files:\n \tdir1/untracked\n \tdir2/untracked\n \texpect\n+\texpect-with-v\n \toutput\n \tuntracked\n \n@@ -264,7 +272,7 @@ EOF\n test_expect_success 'status with gitignore (nothing untracked)' '\n \t{\n \t\techo \".gitignore\" &&\n-\t\techo \"expect\" &&\n+\t\techo \"expect*\" &&\n \t\techo \"dir2/modified\" &&\n \t\techo \"output\" &&\n \t\techo \"untracked\"\n@@ -285,6 +293,7 @@ test_expect_success 'status with gitignore (nothing untracked)' '\n \t!! dir2/modified\n \t!! dir2/untracked\n \t!! expect\n+\t!! expect-with-v\n \t!! output\n \t!! untracked\n \tEOF\n@@ -312,6 +321,7 @@ Ignored files:\n \tdir2/modified\n \tdir2/untracked\n \texpect\n+\texpect-with-v\n \toutput\n \tuntracked\n \n-- \n2.3.1.303.g5174db1\n"},{"id":"257078","messageId":"cae757b238bdd71bf8d03f9040a08466194c3440.1425564336.git.git@drmicha.warpmail.net","threadId":"38347","inReplyTo":"xmqqr3t479ey.fsf@gitster.dls.corp.google.com","subject":"[PATCHv3 3/3] commit/status: show the index-worktree diff with -v -v","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2015-03-05T14:13:04Z","receivedAt":"2015-03-05T14:13:04Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"git commit and git status in long format show the diff between HEAD\nand the index when given -v. This allows previewing a commit to be made.\n\nThey also list tracked files with unstaged changes, but without a diff.\n\nIntroduce '-v -v' which shows the diff between the index and the\nworktree in addition to the HEAD index diff. This allows a review of unstaged\nchanges which might be missing from the commit.\n\nIn the case of '-v -v', additonal header lines\n\nChanges to be committed:\n\nand\n\nChanges not staged for commit:\n\nare inserted before the diffs, which are equal to those in the status\npart.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n Documentation/git-commit.txt |  4 ++++\n t/t7508-status.sh            | 10 ++++++++++\n wt-status.c                  | 16 ++++++++++++++++\n 3 files changed, 30 insertions(+)\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex 1e74b75..f14d2ec 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -284,6 +284,10 @@ configuration variable documented in linkgit:git-config[1].\n \twould be committed at the bottom of the commit message\n \ttemplate.  Note that this diff output doesn't have its\n \tlines prefixed with '#'.\n++\n+If specified twice, show in addition the unified diff between\n+what would be committed and the worktree files, i.e. the unstaged\n+changes to tracked files.\n \n -q::\n --quiet::\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex e3c9cf9..b392376 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -143,6 +143,16 @@ test_expect_success 'status -v' '\n \ttest_i18ncmp expect-with-v output\n '\n \n+test_expect_success 'status -v -v' '\n+\t(cat expect &&\n+\t echo \"Changes to be committed:\" &&\n+\t git -c diff.mnemonicprefix=true diff --cached &&\n+\t echo \"Changes not staged for commit:\" &&\n+\t git -c diff.mnemonicprefix=true diff) >expect-with-v &&\n+\tgit status -v -v >output &&\n+\ttest_i18ncmp expect-with-v output\n+'\n+\n test_expect_success 'setup fake editor' '\n \tcat >.git/editor <<-\\EOF &&\n \t#! /bin/sh\ndiff --git a/wt-status.c b/wt-status.c\nindex 29666d0..3cdb356 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -849,6 +849,8 @@ static void wt_status_print_verbose(struct wt_status *s)\n {\n \tstruct rev_info rev;\n \tstruct setup_revision_opt opt;\n+\tint dirty_submodules;\n+\tconst char *c = color(WT_STATUS_HEADER, s);\n \n \tinit_revisions(&rev, NULL);\n \tDIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV);\n@@ -873,7 +875,21 @@ static void wt_status_print_verbose(struct wt_status *s)\n \t\trev.diffopt.use_color = 0;\n \t\twt_status_add_cut_line(s->fp);\n \t}\n+\tif (s->verbose > 1 && s->commitable) {\n+\t\t/* print_updated() printed header */\n+\t\tstatus_printf_ln(s, c, _(\"Changes to be committed:\"));\n+\t\trev.diffopt.a_prefix = \"c/\";\n+\t\trev.diffopt.b_prefix = \"i/\";\n+\t} /* else use prefix as per user config */\n \trun_diff_index(&rev, 1);\n+\tif (s->verbose > 1 &&\n+\t    wt_status_check_worktree_changes(s, &dirty_submodules)) {\n+\t\tstatus_printf_ln(s, c, _(\"Changes not staged for commit:\"));\n+\t\tsetup_work_tree();\n+\t\trev.diffopt.a_prefix = \"i/\";\n+\t\trev.diffopt.b_prefix = \"w/\";\n+\t\trun_diff_files(&rev, 0);\n+\t}\n }\n \n static void wt_status_print_tracking(struct wt_status *s)\n-- \n2.3.1.303.g5174db1\n"},{"id":"257100","messageId":"xmqqtwxz2qmb.fsf@gitster.dls.corp.google.com","threadId":"38347","inReplyTo":"cover.1425564336.git.git@drmicha.warpmail.net","subject":"Re: [PATCHv3 0/3]More diffs for commit/status","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-03-05T19:25:48Z","receivedAt":"2015-03-05T19:25:48Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> v3 has the following changes:\n> - new leading patch by Junio to clean up t7508 (slightly modified by myself)\n> - adjust tests accordingly\n> - revert back to standard c/,i/ resp. i/,w/ diff prefixes with a header line\n>\n> Open questionis for 3/3:\n> - Do we need the header to stick out even more? (I don't think so, although\n>   having the STATUS_HEADER color to be different may help.)\n\nIf we have more than one paths in each category, I would think at\nleast a separator line (I used -{50} in my illustration you are\nreplying to) before the verbal \"Changes to be committed\" would help.\n\n> - Do we want the header line also for \"status -v\"? (I would say yes, but that\n>   would be a change to current behaviour.)\n\nI would not object to it very strongly, but I do not see a point in\nchanging the behaviour.\n\nAnd I do not see why a new user would want it anyway.  There is no\nneed to differenciate the changes to be committed from the changes\nleft in the working tree when the latter is not even shown.\n"},{"id":"257101","messageId":"xmqqlhjb2obv.fsf@gitster.dls.corp.google.com","threadId":"38347","inReplyTo":"xmqqtwxz2qmb.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCHv3 0/3]More diffs for commit/status","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-03-05T20:15:16Z","receivedAt":"2015-03-05T20:15:16Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Michael J Gruber <git@drmicha.warpmail.net> writes:\n>\n>> - Do we want the header line also for \"status -v\"? (I would say yes, but that\n>>   would be a change to current behaviour.)\n>\n> I would not object to it very strongly, but I do not see a point in\n> changing the behaviour.\n>\n> And I do not see why a new user would want it anyway.  There is no\n> need to differenciate the changes to be committed from the changes\n> left in the working tree when the latter is not even shown.\n\nExtending this line of thought further.\n\nIf I am reading your patch 3/3 right, \"status -v -v\" shows the\nheader when there are patches to be shown for the category.  I am\nnot sure if that is the most helpful way for the users, when either\nc/i xor i/w diffs is missing.\n\nThere are four cases, obviously ;-)\n\n1. When there are changes to be committed:\n\n a) When there is no change left in the working tree, the proposed\n    output would be the same as the more familiar \"status -v\"\n    output.  Showing changes to be committed header would of course\n    help.\n\n    I wondered if the proposed behaviour hurts the user by hiding\n    the header for changes to be left out, though.  By seeing that\n    the second header alone and no diff, the user will be assured\n    that there is no changes left in the working tree, forgotten to\n    be added.  But this point is minor.  As the users get used to\n    the behaviour of \"-v -v\", they will learn to read the emptyness\n    and find its proper meaning that there is no change left out.\n    So I think the proposed behaviour would be OK in this case.  In\n    fact, not showing the second header when there is no change left\n    in the working tree will help potential issues with case 2-b).\n\n b) When there is change left in the working tree, the proposed\n    output is fine.  Two headers are shown to indicate what the\n    following diff is about and cleanly shows where the boundary of\n    the two classes are (especially if you resurrect the -{50}\n    separator line I suggested, at least for the second header).\n\n\n2. When there is no change to be committed:\n\n a) When there is no change left in the working tree, the proposed\n    output is fine.  There is no output (no header, no diff), and\n    the user immediately knows that the working tree and the index\n    are clean.\n\n b) When there are changes left in the working tree, the user sees\n    one header followed by a diff in the proposed output.  Visually,\n    the single line heading (even with the separateor line) may be\n    so small in the context of the whole output, and the user needs\n    to READ it to notice that the diff being shown are not what is\n    going to be committed.  In other words, it is too similar to the\n    proposed output in case 1-a).\n\n    If we show the \"to be committed\" header followed by no diff, and\n    then the second header followed by diff, it would be crystial\n    clear to the user, because it looks unusual, that what is shown\n    is different from case 1-a).  This would especially be true if\n    you resurrected -{50} separator line after the heading.\n\n\nSo, my recommendation for \"status -v -v\" would be:\n\n    if (there are changes to be committed, or\n\tthere are changes left in the working tree) {\n\tshow \"to be committed\" with -{50};\n        show c/i diff;\n    }\n    if (there are changes left in the working tree) {\n\tshow \"left in the working tree\" with -{50};\n        show i/w diff;\n    }\n"},{"id":"257102","messageId":"xmqqfv9j2nqu.fsf@gitster.dls.corp.google.com","threadId":"38347","inReplyTo":"xmqqlhjb2obv.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCHv3 0/3]More diffs for commit/status","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-03-05T20:27:53Z","receivedAt":"2015-03-05T20:27:53Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Extending this line of thought further.\n> \n> If I am reading your patch 3/3 right, \"status -v -v\" shows the\n> header when there are patches to be shown for the category.  I am\n> not sure if that is the most helpful way for the users, when either\n> c/i xor i/w diffs is missing.\n> ...\n> So, my recommendation for \"status -v -v\" would be:\n\nTaking the conclusion part of what I said back.  I think the exact\nsame reasoning will lead to a much simpler and more concise output\nby (1) using exactly the same logic you have in 3/3 to decide when\nto show or not show the headers and (2) adding the ^-{50}$ separator\nonly before the second header that is shown before the changes left\nin the working tree.\n\nThen, 1-a) will show the same output as \"status -v\", 1-b) will start\nas the same as \"status -v\", followed by a visually significant\nseparator followed by diff, 2-a) will be empty, and 2-b) will start\nwith a visually significant and unusual separator line before the\ndiff.  That would make 1-a) and 2-b) visually very distinct and\nreduce the chance of confusion.\n\nThe updated outline for \"status -v -v\" would be:\n\n     if (there are changes to be committed) {\n         show \"to be committed\" header;\n         show c/i diff;\n     }\n     if (there are changes left in the working tree) {\n         show \"left in the working tree\" with -{50} header;\n         show i/w diff;\n     }\n\nThanks.\n"}]}