{"thread":{"id":"30432","subject":"Feature idea: git rebase --exec $CMD","startedAt":"2012-05-05T11:26:50Z","lastAt":"2012-05-23T15:50:20Z","messageCount":9,"participants":["Antonio Ospite","Felipe Contreras","Matthieu Moy","Jeff King","dag@cray.com"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"190833","messageId":"20120505132650.637c4e06086654e0dbf641fc@studenti.unina.it","threadId":"30432","inReplyTo":null,"subject":"Feature idea: git rebase --exec $CMD","fromName":"Antonio Ospite","fromEmail":"ospite@studenti.unina.it","sentAt":"2012-05-05T11:26:50Z","receivedAt":"2012-05-05T11:26:50Z","isPatch":false,"sender":{"key":"ospite@studenti.unina.it","avatar":"https://gravatar.com/avatar/ea788baa2a3a207a84097c6f4f7b11d4201a80060933ef67584f648f17005552?d=mp&s=160"},"body":"Hi,\n\nI find the x/exec function in \"git rebase -i\" very useful, but it may\nbe tedious to edit the commit list to add something like \"make test\"\nafter each commit.\n\nCan this functionality be exposed from the command line as well?\nI am thinking to a [-x|--exec <command>] options which accepts a command\nas an argument, and executes such command after each commit in the list\nof commits which are going to be rebased, and stops the rebasing if the\ncommand returns a non-0 value.\n\nMaybe this -x option should conflict with -i to simplify its \"execute\nthe command after each commit\" semantics (what if it is combined with -i\nand 'x/exec' lines?).\n\nI can draft the man page section for it, but I doubt I can work on the\ncode for now, so I wanted to throw the idea here and see if anyone else\nwants to pick it up.\n\nI read that calling a \"make test\" command after each commit could be\ndone using \"git rev-list\" like in\nhttp://sethrobertson.github.com/GitPostProduction/gpp.html#post-post-production\nbut a more friendly way to do that from CLI would be great.\n\nThanks,\n   Antonio\n\nP.S. I am not subscribed to the list, please CC me.\n\n-- \nAntonio Ospite\nhttp://ao2.it\n\nA: Because it messes up the order in which people normally read text.\n   See http://en.wikipedia.org/wiki/Posting_style\nQ: Why is top-posting such a bad thing?\n"},{"id":"190835","messageId":"CAMP44s2pj2dVeOp39d8TgaTv5a5ox74k29QpxB_YStWtQ6HPVw@mail.gmail.com","threadId":"30432","inReplyTo":"20120505132650.637c4e06086654e0dbf641fc@studenti.unina.it","subject":"Re: Feature idea: git rebase --exec $CMD","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-05-05T11:54:13Z","receivedAt":"2012-05-05T11:54:13Z","isPatch":false,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Sat, May 5, 2012 at 1:26 PM, Antonio Ospite <ospite@studenti.unina.it> wrote:\n> I find the x/exec function in \"git rebase -i\" very useful, but it may\n> be tedious to edit the commit list to add something like \"make test\"\n> after each commit.\n\nFWIW I have had the need for this, I think it's a good idea.\n\n> P.S. I am not subscribed to the list, please CC me.\n\nNo need for this; this is a sane mailing list that doesn't munge\nReply-To, so everybody has to 'reply to all'. To be sure you can add\nyourself in the CC list, but I think most clients would do the right\nthing regardless.\n\nCheers.\n\n[1] http://felipec.wordpress.com/2010/08/03/avoid-reply-to-munging-mail-as-mail-was-meant-to-be/\n\n-- \nFelipe Contreras\n"},{"id":"190887","messageId":"vpqobq1mxru.fsf@bauges.imag.fr","threadId":"30432","inReplyTo":"20120505132650.637c4e06086654e0dbf641fc@studenti.unina.it","subject":"Re: Feature idea: git rebase --exec $CMD","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-05-06T10:03:49Z","receivedAt":"2012-05-06T10:03:49Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Antonio Ospite <ospite@studenti.unina.it> writes:\n\n> Maybe this -x option should conflict with -i to simplify its \"execute\n> the command after each commit\" semantics (what if it is combined with -i\n> and 'x/exec' lines?).\n\nActually, implementation-wise, it's simpler to have '-x' imply '-i', and\nsuggest a todo-list containing 'x' lines. Then, the code would simply\nhave to add these \"x whatever\" lines, and let the\n\"git-rebase--interactive.sh\" mechanics do the job. That would show the\n\"x whatever\" lines to the user, but that can be seen as added value,\nsince it gives an opportunity to the user to remove or edit some of them\nif needed.\n\nI'm not familiar with the code behind non-interactive rebase, but it\ndoesn't seem to use the same todo-list at all. Maybe the sequencer would\nhelp, I don't know.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"190893","messageId":"20120506124420.bc796b6e2852e6aec5da36d8@studenti.unina.it","threadId":"30432","inReplyTo":"vpqobq1mxru.fsf@bauges.imag.fr","subject":"Re: Feature idea: git rebase --exec $CMD","fromName":"Antonio Ospite","fromEmail":"ospite@studenti.unina.it","sentAt":"2012-05-06T10:44:20Z","receivedAt":"2012-05-06T10:44:20Z","isPatch":false,"sender":{"key":"ospite@studenti.unina.it","avatar":"https://gravatar.com/avatar/ea788baa2a3a207a84097c6f4f7b11d4201a80060933ef67584f648f17005552?d=mp&s=160"},"body":"On Sun, 06 May 2012 12:03:49 +0200\nMatthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:\n\n> Antonio Ospite <ospite@studenti.unina.it> writes:\n> \n> > Maybe this -x option should conflict with -i to simplify its \"execute\n> > the command after each commit\" semantics (what if it is combined with -i\n> > and 'x/exec' lines?).\n> \n> Actually, implementation-wise, it's simpler to have '-x' imply '-i', and\n> suggest a todo-list containing 'x' lines. Then, the code would simply\n> have to add these \"x whatever\" lines, and let the\n> \"git-rebase--interactive.sh\" mechanics do the job. That would show the\n> \"x whatever\" lines to the user, but that can be seen as added value,\n> since it gives an opportunity to the user to remove or edit some of them\n> if needed.\n>\n\nThanks Matthieu,\n\nthis sounds like a reasonable default behavior for the case of '-x' and\n'-i' _combined_, but I still think '-x' with no invocation of $EDITOR\ncan have its use case (e.g. a \"make validate-commits\" calling 'git\nrebase -x \"make test\" master').\n\nBut I'd like to hear other opinions about that.\n\nThanks,\n   Antonio\n\n-- \nAntonio Ospite\nhttp://ao2.it\n\nA: Because it messes up the order in which people normally read text.\n   See http://en.wikipedia.org/wiki/Posting_style\nQ: Why is top-posting such a bad thing?\n"},{"id":"190899","messageId":"20120506122649.GB26194@sigill.intra.peff.net","threadId":"30432","inReplyTo":"vpqobq1mxru.fsf@bauges.imag.fr","subject":"Re: Feature idea: git rebase --exec $CMD","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-05-06T12:26:49Z","receivedAt":"2012-05-06T12:26:49Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, May 06, 2012 at 12:03:49PM +0200, Matthieu Moy wrote:\n\n> > Maybe this -x option should conflict with -i to simplify its \"execute\n> > the command after each commit\" semantics (what if it is combined with -i\n> > and 'x/exec' lines?).\n> \n> Actually, implementation-wise, it's simpler to have '-x' imply '-i', and\n> suggest a todo-list containing 'x' lines. Then, the code would simply\n> have to add these \"x whatever\" lines, and let the\n> \"git-rebase--interactive.sh\" mechanics do the job. That would show the\n> \"x whatever\" lines to the user, but that can be seen as added value,\n> since it gives an opportunity to the user to remove or edit some of them\n> if needed.\n\nYeah, that makes a lot of sense to me. FWIW, I use this trick now:\n\n  GIT_EDITOR='sed -i \"/^pick .*/aexec $test\"' \\\n  git rebase -i \"$@\"\n\nto test individual commits on a topic before publishing it. But it would\nbe awesome to do:\n\n  git rebase -ix \"$test\" \"$@\"\n\ninstead (and clean up the quoting disaster waiting to happen in my sed\ninvocation). We should perhaps start slow and call this \"--exec\" instead\nof stealing the short-and-sweet \"-x\" until the feature is more proven,\nthough.\n\n> I'm not familiar with the code behind non-interactive rebase, but it\n> doesn't seem to use the same todo-list at all. Maybe the sequencer would\n> help, I don't know.\n\nWith \"-m\", it's basically just a for loop over the commits, so I don't\nknow that it would be too hard, but there may be bad interactions. With\nstock rebase using the \"git-rebase--am\" backend, it's a bit harder, as\nwe are just bulk-feeding the contents between format-patch and am.\n\nHowever, I like that the \"-i\" case already has a concept of\nexecute-and-stop-if-fail, and that we can just build on that. I hope one\nday that it will all be unified via the sequencer code, but for now,\nit's not. Having the option mean \"just add some exec lines to the todo\nfile\" is very simple and not likely to cause bugs.\n\nAs tempting as it would be to have \"-x\" imply \"-i\", I think it makes\nsense for it to simply fail in the non-interactive case (and say \"sorry,\nnot supported yet\"). Then people can experiment with making it work for\nthe non-interactive case (or when the non-interactive case eventually\njust uses the same code without the editor invocation), we won't be\ntrapped into always having \"-x\" start the editor.\n\n-Peff\n"},{"id":"191276","messageId":"vpqy5p08mom.fsf@bauges.imag.fr","threadId":"30432","inReplyTo":"20120505132650.637c4e06086654e0dbf641fc@studenti.unina.it","subject":"Re: Feature idea: git rebase --exec $CMD","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-05-10T08:28:25Z","receivedAt":"2012-05-10T08:28:25Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Antonio Ospite <ospite@studenti.unina.it> writes:\n\n> I find the x/exec function in \"git rebase -i\" very useful, [...]\n> Can this functionality be exposed from the command line as well?\n\nI've added this idea here:\n\n  https://git.wiki.kernel.org/index.php/SmallProjectsIdeas#git_rebase_-i_--exec_CMD\n\nmaybe I'll get on of my students to code it soon :-).\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"191990","messageId":"nngfwar3p9z.fsf@transit.us.cray.com","threadId":"30432","inReplyTo":"20120505132650.637c4e06086654e0dbf641fc@studenti.unina.it","subject":"Re: Feature idea: git rebase --exec $CMD","fromName":"","fromEmail":"dag@cray.com","sentAt":"2012-05-23T15:12:08Z","receivedAt":"2012-05-23T15:12:08Z","isPatch":false,"sender":{"key":"dag@cray.com","avatar":null},"body":"Antonio Ospite <ospite@studenti.unina.it> writes:\n\n> I find the x/exec function in \"git rebase -i\" very useful, but it may\n> be tedious to edit the commit list to add something like \"make test\"\n> after each commit.\n\nI've taken a more general approach inspired by\nrun-command-on-git-revisions at\nhttps://github.com/garybernhardt/dotfiles/tree/master/bin\n\nI took that and turned it into a git-run-command subcommand.  It will\ntake an arbitrary command and run it on each revision specified by a\nrevlist.\n\nI think that's a more flexible approach than tying it to rebase.\n\nThoughts?\n\n                          -Dave\n"},{"id":"191995","messageId":"vpqd35udhwq.fsf@bauges.imag.fr","threadId":"30432","inReplyTo":"nngfwar3p9z.fsf@transit.us.cray.com","subject":"Re: Feature idea: git rebase --exec $CMD","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-05-23T15:41:09Z","receivedAt":"2012-05-23T15:41:09Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"<dag@cray.com> writes:\n\n> Antonio Ospite <ospite@studenti.unina.it> writes:\n>\n>> I find the x/exec function in \"git rebase -i\" very useful, but it may\n>> be tedious to edit the commit list to add something like \"make test\"\n>> after each commit.\n>\n> I've taken a more general approach inspired by\n> run-command-on-git-revisions at\n> https://github.com/garybernhardt/dotfiles/tree/master/bin\n>\n> I took that and turned it into a git-run-command subcommand.  It will\n> take an arbitrary command and run it on each revision specified by a\n> revlist.\n\nThat's sensible too. The nice things with running commands in \"git\nrebase\" are:\n\n* It's likely to be the place where you want to run some tests. The\n  typical use-case is that you have a patch serie whose last revision\n  passes tests, and you want to check that intermediate commits also do.\n  At that point, you probably want to rebase against upstream too, to\n  make sure you're developping against the latest revision, before\n  sening a patch serie or pushing.\n\n* if the \"exec\" command fails, you're likely to be exactly in the right\n  place to fix it: fix the bug, run \"git commit --amend\", and \"git\n  rebase --continue\".\n\nThe nice thing with your approach (as I understand it) is that it\ndoesn't require rewritting history, and may apply to all commits in\nnon-linear history.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"191996","messageId":"nngliki3nib.fsf@transit.us.cray.com","threadId":"30432","inReplyTo":"vpqd35udhwq.fsf@bauges.imag.fr","subject":"Re: Feature idea: git rebase --exec $CMD","fromName":"","fromEmail":"dag@cray.com","sentAt":"2012-05-23T15:50:20Z","receivedAt":"2012-05-23T15:50:20Z","isPatch":false,"sender":{"key":"dag@cray.com","avatar":null},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n>> I took that and turned it into a git-run-command subcommand.  It will\n>> take an arbitrary command and run it on each revision specified by a\n>> revlist.\n>\n> That's sensible too. The nice things with running commands in \"git\n> rebase\" are:\n>\n> * It's likely to be the place where you want to run some tests. The\n>   typical use-case is that you have a patch serie whose last revision\n>   passes tests, and you want to check that intermediate commits also do.\n\nYep, I have done that many times using the above-mentioned script\n(obviously not during rebase).\n\n> * if the \"exec\" command fails, you're likely to be exactly in the right\n>   place to fix it: fix the bug, run \"git commit --amend\", and \"git\n>   rebase --continue\".\n\nThat's a good point.\n\n> The nice thing with your approach (as I understand it) is that it\n> doesn't require rewritting history, and may apply to all commits in\n> non-linear history.\n\nExactly.  I think there is room for both.  The downside to\ngit-run-command (besides the name) is that it forcibly checks out\nrevisions in the current workarea so one has to be careful about\nunstaged and/or uncommitted changes.  I could change the behavior to\ncheckout in some /tmp workarea or something.\n\n                                -Dave\n"}]}