{"thread":{"id":"44756","subject":"[RFC/PATCH] add diffstat information to rebase","startedAt":"2016-12-22T18:56:19Z","lastAt":"2016-12-25T00:53:04Z","messageCount":7,"participants":["Stefan Beller","Johannes Schindelin","Junio C Hamano","Jacob Keller","Duy Nguyen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"308258","messageId":"20161222185609.21139-1-sbeller@google.com","threadId":"44756","inReplyTo":null,"subject":"[RFC/PATCH] add diffstat information to rebase","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-12-22T18:56:09Z","receivedAt":"2016-12-22T18:56:19Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n\nWhen working on a large feature consisting of lots of commits,\nmy development workflow is to create a lot of very small commits and\nthen reshuffle these via interactive rebase.\n\nSometimes the commit message titles for these very small commits are\nnot as good as I thought they would, such that the interactive rebase\nsession needs to be accompanied by extensive use of gitk in my case.\n\nThis is a small hack that adds the diffstat to the interactive rebase\nhelping me a bit during the rebase, such that:\n\n    $ git rebase -i HEAD^^\n\n    pick 2eaa3f532c Third batch for 2.12\n    # Documentation/RelNotes/2.12.0.txt | 40 +++++++++++++++++++++++++++++++++++++++\n    # 1 file changed, 40 insertions(+)\n    pick 3170a3a57b add information to rebase\n    # git-rebase--interactive.sh | 2 ++\n    # 1 file changed, 2 insertions(+)\n    \n    # Rebase 2eaa3f532c..3170a3a57b onto 2eaa3f532c (1 command)\n    #\n    # Commands:\n    # p, pick = use commit\n    # r, reword = use commit, but edit the commit message\n    # e, edit = use commit, but stop for amending\n\nI am not completely satisfied with the result, as I initially wished these\ninformation would just appear in line after the commit subject, but this\ncomes close. Maybe the last line also needs to be dropped.\n\nThis is not a patch meant for inclusion, as for that we'd want to hide this\nfeature behind an option I'd guess.\n\nStefan\n\n git-rebase--interactive.sh | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 41fd374c72..db73c69674 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -1220,6 +1220,7 @@ do\n \tif test t != \"$preserve_merges\"\n \tthen\n \t\tprintf '%s\\n' \"${comment_out}pick $sha1 $rest\" >>\"$todo\"\n+\t\tgit diff --stat $sha1^..$sha1 |sed s/^/\"$comment_char\"/ >>\"$todo\"\n \telse\n \t\tif test -z \"$rebase_root\"\n \t\tthen\n@@ -1238,6 +1239,7 @@ do\n \t\tthen\n \t\t\ttouch \"$rewritten\"/$sha1\n \t\t\tprintf '%s\\n' \"${comment_out}pick $sha1 $rest\" >>\"$todo\"\n+\t\t\tgit diff --stat $sha1^..$sha1 |sed s/^/\"$comment_char\"/ >>\"$todo\"\n \t\tfi\n \tfi\n done\n-- \n2.11.0.193.g3170a3a57b\n\n"},{"id":"308270","messageId":"alpine.DEB.2.20.1612222239390.155951@virtualbox","threadId":"44756","inReplyTo":"20161222185609.21139-1-sbeller@google.com","subject":"Re: [RFC/PATCH] add diffstat information to rebase","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2016-12-22T21:41:08Z","receivedAt":"2016-12-22T21:41:16Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Stefan,\n\nOn Thu, 22 Dec 2016, Stefan Beller wrote:\n\n> This is a small hack that adds the diffstat to the interactive rebase\n> helping me a bit during the rebase, such that:\n> \n>     $ git rebase -i HEAD^^\n> \n>     pick 2eaa3f532c Third batch for 2.12\n>     # Documentation/RelNotes/2.12.0.txt | 40 +++++++++++++++++++++++++++++++++++++++\n>     # 1 file changed, 40 insertions(+)\n>     pick 3170a3a57b add information to rebase\n>     # git-rebase--interactive.sh | 2 ++\n>     # 1 file changed, 2 insertions(+)\n\nIf it helps you, fine. But please make it opt-in. I would hate to see it\nin all my rebases, I find that information more confusing than helpful.\n\n>  git-rebase--interactive.sh | 2 ++\n>  1 file changed, 2 insertions(+)\n\nOh well. I guess I have to modify sequencer-i yet another time.\n\nCiao,\nDscho\n"},{"id":"308274","messageId":"20161222221327.7354-1-sbeller@google.com","threadId":"44756","inReplyTo":"alpine.DEB.2.20.1612222239390.155951@virtualbox","subject":"Re: [RFC/PATCH] add diffstat information to rebase","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-12-22T22:13:27Z","receivedAt":"2016-12-22T22:13:45Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, Dec 22, 2016 at 1:41 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> Hi Stefan,\n>\n> On Thu, 22 Dec 2016, Stefan Beller wrote:\n>\n>> This is a small hack that adds the diffstat to the interactive rebase\n>> helping me a bit during the rebase, such that:\n>>\n>>     $ git rebase -i HEAD^^\n>>\n>>     pick 2eaa3f532c Third batch for 2.12\n>>     # Documentation/RelNotes/2.12.0.txt | 40 +++++++++++++++++++++++++++++++++++++++\n>>     # 1 file changed, 40 insertions(+)\n>>     pick 3170a3a57b add information to rebase\n>>     # git-rebase--interactive.sh | 2 ++\n>>     # 1 file changed, 2 insertions(+)\n>\n> If it helps you, fine. But please make it opt-in. I would hate to see it\n> in all my rebases, I find that information more confusing than helpful.\n\nThat's what I realized now that I played around with it for a day, because it actually\ncreates more lines than I can fit into my terminal in one screen now.\n\n*Ideally* I would rather have a different formatting, e.g. maybe:\n\n    $ git checkout remotes/origin/js/sequencer-wo-die\n    $ git rebase -i --new-magic v2.10.0-rc2^\n\nwhich produces:\n\n    pick d5cb9cbd64 Git 2.10-rc2                                    | Documentation/RelNo.., GIT-VERSION-GEN -..(+5, -1)\n    ...\n    pick dbfad033d4 sequencer: do not die() in do_pick_commit()     | sequencer.c - do_pick_commit              (+7, -6)\n    pick 4ef3d8f033 sequencer: lib'ify write_message()              | sequencer.c - write_message, do_pick_com..(+11, -9)\n    ...\n    ...\n    pick 88d5a271b0 sequencer: lib'ify save_opts()                  | sequencer.c - save_opts + sequencer_pick..(+20, -20)\n    pick 0e408fc347 sequencer: lib'ify fast_forward_to()            | sequencer.c - fast_forward_to             (+1, -1)\n    pick 55f5704da6 sequencer: lib'ify checkout_fast_forward()      | sequencer.c - checkout_fast_forward       (+6, -3)\n    pick 49fb937e9a sequencer: ensure to release the lock when w... | sequencer.c - read_and_refresh_cache      (+6, -3)\n\n\n\nWhen writing this example, I do notice that some sorts of commits put\nnearly this exact information into the commit message. But that happens\nwhen the commit is already well crafted and often it is refactoring.\n\nA good example for the use case of this new format would be\norigin/js/regexec-buf as there the commit message doesn't give\naway what files and functions are touched.\n\nAnother very good example for the usefulness of the new format\nappears to be origin/js/am-3-merge-recursive-direct, because:\n\n* there are quite a few commits in the series.\n  (This feature seems to only be useful for long reshuffling series'\n  for interactive rebase in my mind.)\n* It is not obvious by the commit title, which parts of the code\n  are touched. (files, functions)\n* With a longer series, you can produce different valid orders for the\n  patches to be applied, e.g. compiling and testing works even if the patches\n  were applied in different orders.\n\nWell actually the best use case are unfinished series,\nwith lots of \"fixup\" commits. :)\n\n>\n>>  git-rebase--interactive.sh | 2 ++\n>>  1 file changed, 2 insertions(+)\n>\n> Oh well. I guess I have to modify sequencer-i yet another time.\n\nI think this feature can wait until the sequencer is in\nand then we can build it on top, time permitting.\n\nThanks,\nStefan\n\n"},{"id":"308279","messageId":"xmqqtw9vegjr.fsf@gitster.mtv.corp.google.com","threadId":"44756","inReplyTo":"20161222185609.21139-1-sbeller@google.com","subject":"Re: [RFC/PATCH] add diffstat information to rebase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-12-22T22:37:44Z","receivedAt":"2016-12-22T22:37:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n>     $ git rebase -i HEAD^^\n>\n>     pick 2eaa3f532c Third batch for 2.12\n>     # Documentation/RelNotes/2.12.0.txt | 40 +++++++++++++++++++++++++++++++++++++++\n>     # 1 file changed, 40 insertions(+)\n>     pick 3170a3a57b add information to rebase\n>     # git-rebase--interactive.sh | 2 ++\n>     # 1 file changed, 2 insertions(+)\n>     \n>     # Rebase 2eaa3f532c..3170a3a57b onto 2eaa3f532c (1 command)\n>     #\n>     # Commands:\n>     # p, pick = use commit\n>     # r, reword = use commit, but edit the commit message\n>     # e, edit = use commit, but stop for amending\n>\n> I am not completely satisfied with the result, as I initially wished these\n> information would just appear in line after the commit subject, but this\n> comes close. Maybe the last line also needs to be dropped.\n\nThis is an interesting and thought-provoking idea ;-).\n\nIn practice, you would probably be touching the same file over and\nover again in the series you are rebasing, when you are doing \"many\nminiscule commits recording experiments and dead ends, with an\nintention to clean it up later\", and by definition, your subject\nlines are useless series of \"oops\", \"fix\", etc.  The subject and\nlist of filenames would probably not make a good \"summary\" of the\nchanges for each commit.\n\nStepping back a bit, right now, when the user asks \"git commit\" to\nsupply material to help writing a good commit message, we punt on\nmechanically generating a good summary and instead just show output\nof \"diff --cached\".  If we can come up with a way to mechanically\ngenerate a concise summary for the purpose of annotating \"rebase -i\"\ninstruction, we probably can reuse that and append it at the end of\nthe log editor \"git commit\" spawns when it is run without \"-v\".\n\nAlso, this makes me wonder if the ideal endgame might be to depend\non the current \"rebase -i\" UI as little as possible.  \n\n\"rebase -i\" is \"interactive\" only to the extent that you can\ninteract in your text editor the order and the fashion in which the\nchanges are applied.  If we instead teach either gitk or tig to\neasily allow you to \"tick\" each commit you see in their UI and\ngenerate the instruction used by the sequencer, and feed that and\nactually drive the sequencer to execute it (perhaps inside a\ntemporary/throwaway working tree) while you are still in gitk or tig\nand reload the UI dynamically to let you view the result, the\noverall user experience would become a lot more \"interactive\".\n\n"},{"id":"308283","messageId":"alpine.DEB.2.20.1612230003470.155951@virtualbox","threadId":"44756","inReplyTo":"20161222221327.7354-1-sbeller@google.com","subject":"Re: [RFC/PATCH] add diffstat information to rebase","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2016-12-22T23:05:46Z","receivedAt":"2016-12-22T23:05:59Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Stefan,\n\nOn Thu, 22 Dec 2016, Stefan Beller wrote:\n\n> *Ideally* I would rather have a different formatting, e.g. maybe:\n> \n>     $ git checkout remotes/origin/js/sequencer-wo-die\n>     $ git rebase -i --new-magic v2.10.0-rc2^\n> \n> which produces:\n> \n>     pick d5cb9cbd64 Git 2.10-rc2                                    | Documentation/RelNo.., GIT-VERSION-GEN -..(+5, -1)\n>     ...\n\nThat sounds more like a patch adding a new placeholder to the user formats\nthan a patch modifying rebase -i; by using rebase.instructionFormat you\ncan implement that \"new magic\", and the new functionality may even benefit\nmore obscure use cases.\n\nCiao,\nDscho\n"},{"id":"308296","messageId":"CA+P7+xr_itve2q=Kr5hrZBWoF2wkVeuqtQP7DLckeOtrdu2S5A@mail.gmail.com","threadId":"44756","inReplyTo":"xmqqtw9vegjr.fsf@gitster.mtv.corp.google.com","subject":"Re: [RFC/PATCH] add diffstat information to rebase","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2016-12-23T08:32:22Z","receivedAt":"2016-12-23T08:32:51Z","isPatch":true,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Thu, Dec 22, 2016 at 2:37 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Stefan Beller <sbeller@google.com> writes:\n>\n>>     $ git rebase -i HEAD^^\n>>\n>>     pick 2eaa3f532c Third batch for 2.12\n>>     # Documentation/RelNotes/2.12.0.txt | 40 +++++++++++++++++++++++++++++++++++++++\n>>     # 1 file changed, 40 insertions(+)\n>>     pick 3170a3a57b add information to rebase\n>>     # git-rebase--interactive.sh | 2 ++\n>>     # 1 file changed, 2 insertions(+)\n>>\n>>     # Rebase 2eaa3f532c..3170a3a57b onto 2eaa3f532c (1 command)\n>>     #\n>>     # Commands:\n>>     # p, pick = use commit\n>>     # r, reword = use commit, but edit the commit message\n>>     # e, edit = use commit, but stop for amending\n>>\n>> I am not completely satisfied with the result, as I initially wished these\n>> information would just appear in line after the commit subject, but this\n>> comes close. Maybe the last line also needs to be dropped.\n>\n> This is an interesting and thought-provoking idea ;-).\n>\n> In practice, you would probably be touching the same file over and\n> over again in the series you are rebasing, when you are doing \"many\n> miniscule commits recording experiments and dead ends, with an\n> intention to clean it up later\", and by definition, your subject\n> lines are useless series of \"oops\", \"fix\", etc.  The subject and\n> list of filenames would probably not make a good \"summary\" of the\n> changes for each commit.\n>\n> Stepping back a bit, right now, when the user asks \"git commit\" to\n> supply material to help writing a good commit message, we punt on\n> mechanically generating a good summary and instead just show output\n> of \"diff --cached\".  If we can come up with a way to mechanically\n> generate a concise summary for the purpose of annotating \"rebase -i\"\n> instruction, we probably can reuse that and append it at the end of\n> the log editor \"git commit\" spawns when it is run without \"-v\".\n>\n\nI really like this idea, though I'm not sure exactly what a good\nheuristic would be? A short summary of all diff \"function headers\"\ncould be valuable, as could file names. It would obviously be a\nheuristic of some kind.\n\n> Also, this makes me wonder if the ideal endgame might be to depend\n> on the current \"rebase -i\" UI as little as possible.\n>\n\nI think this type of short summary could be valuable in lots of places yes.\n\n> \"rebase -i\" is \"interactive\" only to the extent that you can\n> interact in your text editor the order and the fashion in which the\n> changes are applied.  If we instead teach either gitk or tig to\n> easily allow you to \"tick\" each commit you see in their UI and\n> generate the instruction used by the sequencer, and feed that and\n> actually drive the sequencer to execute it (perhaps inside a\n> temporary/throwaway working tree) while you are still in gitk or tig\n> and reload the UI dynamically to let you view the result, the\n> overall user experience would become a lot more \"interactive\".\n>\n\nThanks,\nJake\n"},{"id":"308322","messageId":"CACsJy8B8uaKGqc0MV0v35RT0i0P=Fo8Md0J2BtA25cq5+d4t5g@mail.gmail.com","threadId":"44756","inReplyTo":"20161222221327.7354-1-sbeller@google.com","subject":"Re: [RFC/PATCH] add diffstat information to rebase","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2016-12-25T00:52:26Z","receivedAt":"2016-12-25T00:53:04Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Dec 23, 2016 at 5:13 AM, Stefan Beller <sbeller@google.com> wrote:\n> *Ideally* I would rather have a different formatting, e.g. maybe:\n>\n>     $ git checkout remotes/origin/js/sequencer-wo-die\n>     $ git rebase -i --new-magic v2.10.0-rc2^\n>\n> which produces:\n>\n>     pick d5cb9cbd64 Git 2.10-rc2                                    | Documentation/RelNo.., GIT-VERSION-GEN -..(+5, -1)\n>     ...\n>     pick dbfad033d4 sequencer: do not die() in do_pick_commit()     | sequencer.c - do_pick_commit              (+7, -6)\n>     pick 4ef3d8f033 sequencer: lib'ify write_message()              | sequencer.c - write_message, do_pick_com..(+11, -9)\n>     ...\n>     ...\n>     pick 88d5a271b0 sequencer: lib'ify save_opts()                  | sequencer.c - save_opts + sequencer_pick..(+20, -20)\n>     pick 0e408fc347 sequencer: lib'ify fast_forward_to()            | sequencer.c - fast_forward_to             (+1, -1)\n>     pick 55f5704da6 sequencer: lib'ify checkout_fast_forward()      | sequencer.c - checkout_fast_forward       (+6, -3)\n>     pick 49fb937e9a sequencer: ensure to release the lock when w... | sequencer.c - read_and_refresh_cache      (+6, -3)\n\nInstead of guessing the changes based on diffstat, you could add the\nactual commit message (besides the subject line) after that '|' for\nfixup! and squash! commits (and it's probably should be \"#\" instead of\n\"!\"). Then you could just describe what you have changed in the commit\nmessages. If you don't use autosquash, you'll need some way to mark\n\"to-be-merged\" commits though, so that you don't put all commit\nmessages here.\n-- \nDuy\n"}]}