{"thread":{"id":"60726","subject":"Add support for `git rebase -no-edit`","startedAt":"2024-01-11T17:26:00Z","lastAt":"2024-01-11T21:46:45Z","messageCount":6,"participants":["Chaitanya Tata","Taylor Blau","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"486639","messageId":"CADA7-FOE_81ze8hdaRGLPbipihnvFcEYfp9uwnPxPVxDepG4nA@mail.gmail.com","threadId":"60726","inReplyTo":null,"subject":"Add support for `git rebase -no-edit`","fromName":"Chaitanya Tata","fromEmail":"chaitanya.tk17@gmail.com","sentAt":"2024-01-11T17:25:47Z","receivedAt":"2024-01-11T17:26:00Z","isPatch":false,"sender":{"key":"chaitanya.tk17@gmail.com","avatar":null},"body":"Hi,\n\nI have a feature request to add `--no-edit` option to `git rebase`\nlike we do for `git commit`.\nThe workflow I typically follow is:\n\n* `git commit -a --fixup=XXX`\n* `git rebase  -i HEAD~15 --autosquash`\n\nBut it requires closing the editor without any changes. I can\nworkaround this using the `GIT_EDITOR` option, see [1]. But it would\nbe good to have this built-in.\n\nThoughts?\n\n[1] - https://stackoverflow.com/a/45783848\n\nCheers,\nChaitanya.\n"},{"id":"486645","messageId":"ZaBHooq6ORZ3TTkL@nand.local","threadId":"60726","inReplyTo":"CADA7-FOE_81ze8hdaRGLPbipihnvFcEYfp9uwnPxPVxDepG4nA@mail.gmail.com","subject":"Re: Add support for `git rebase -no-edit`","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2024-01-11T19:55:14Z","receivedAt":"2024-01-11T19:55:25Z","isPatch":false,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"Hi Chaitanya,\n\nOn Thu, Jan 11, 2024 at 10:55:47PM +0530, Chaitanya Tata wrote:\n> Hi,\n>\n> I have a feature request to add `--no-edit` option to `git rebase`\n> like we do for `git commit`.\n> The workflow I typically follow is:\n>\n> * `git commit -a --fixup=XXX`\n> * `git rebase  -i HEAD~15 --autosquash`\n>\n> But it requires closing the editor without any changes. I can\n> workaround this using the `GIT_EDITOR` option, see [1]. But it would\n> be good to have this built-in.\n\nThe easiest workaround would be setting GIT_EDITOR=true, which matches\nthe recommendation in [1].\n\nShort of that, you can't do a non-interactive rebase, since we rely on\nthe todo list generated by interactive rebases in order for\n`--autosquash` to work.\n\nPresumably plumbing in a new `--[no-]edit` option would be fairly\nstraightforward, and once that is done, the change boils down to just:\n\nindex 3cc88d8a80..5235a003f2 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -6169,7 +6169,7 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla\n \tstruct todo_list new_todo = TODO_LIST_INIT;\n \tstruct strbuf *buf = &todo_list->buf, buf2 = STRBUF_INIT;\n \tstruct object_id oid = onto->object.oid;\n-\tint res;\n+\tint res = 0;\n\n \trepo_find_unique_abbrev_r(r, shortonto, &oid,\n \t\t\t\t  DEFAULT_ABBREV);\n@@ -6197,8 +6197,9 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla\n \t\treturn error(_(\"nothing to do\"));\n \t}\n\n-\tres = edit_todo_list(r, todo_list, &new_todo, shortrevisions,\n-\t\t\t     shortonto, flags);\n+\tif (!opts->edit)\n+\t\tres = edit_todo_list(r, todo_list, &new_todo, shortrevisions,\n+\t\t\t\t     shortonto, flags);\n \tif (res == -1)\n \t\treturn -1;\n \telse if (res == -2) {\n\n> [1] - https://stackoverflow.com/a/45783848\n\nThanks,\nTaylor\n"},{"id":"486647","messageId":"CADA7-FNh_7OrFFb7qmYFf4i2t_VsjRSjtVngtRKS6HkADKrGYw@mail.gmail.com","threadId":"60726","inReplyTo":"ZaBHooq6ORZ3TTkL@nand.local","subject":"Re: Add support for `git rebase -no-edit`","fromName":"Chaitanya Tata","fromEmail":"chaitanya.tk17@gmail.com","sentAt":"2024-01-11T20:07:35Z","receivedAt":"2024-01-11T20:07:50Z","isPatch":false,"sender":{"key":"chaitanya.tk17@gmail.com","avatar":null},"body":"Cheers,\nChaitanya.\n\nOn Fri, Jan 12, 2024 at 1:25 AM Taylor Blau <me@ttaylorr.com> wrote:\n>\n> Hi Chaitanya,\n>\n> On Thu, Jan 11, 2024 at 10:55:47PM +0530, Chaitanya Tata wrote:\n> > Hi,\n> >\n> > I have a feature request to add `--no-edit` option to `git rebase`\n> > like we do for `git commit`.\n> > The workflow I typically follow is:\n> >\n> > * `git commit -a --fixup=XXX`\n> > * `git rebase  -i HEAD~15 --autosquash`\n> >\n> > But it requires closing the editor without any changes. I can\n> > workaround this using the `GIT_EDITOR` option, see [1]. But it would\n> > be good to have this built-in.\n>\n> The easiest workaround would be setting GIT_EDITOR=true, which matches\n> the recommendation in [1].\nThanks for the quick response.\n>\n> Short of that, you can't do a non-interactive rebase, since we rely on\n> the todo list generated by interactive rebases in order for\n> `--autosquash` to work.\nIIUC, creating a todo list needs access to the file used in interactive\nrebase?\n\n> Presumably plumbing in a new `--[no-]edit` option would be fairly\n> straightforward, and once that is done, the change boils down to just:\nI am bit confused by this as this seems to contradict above statement,\nI guess the below patch will only work without `--autosquash`? Sorry, not\nfamiliar with git internals.\n>\n> index 3cc88d8a80..5235a003f2 100644\n> --- a/sequencer.c\n> +++ b/sequencer.c\n> @@ -6169,7 +6169,7 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla\n>         struct todo_list new_todo = TODO_LIST_INIT;\n>         struct strbuf *buf = &todo_list->buf, buf2 = STRBUF_INIT;\n>         struct object_id oid = onto->object.oid;\n> -       int res;\n> +       int res = 0;\n>\n>         repo_find_unique_abbrev_r(r, shortonto, &oid,\n>                                   DEFAULT_ABBREV);\n> @@ -6197,8 +6197,9 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla\n>                 return error(_(\"nothing to do\"));\n>         }\n>\n> -       res = edit_todo_list(r, todo_list, &new_todo, shortrevisions,\n> -                            shortonto, flags);\n> +       if (!opts->edit)\n> +               res = edit_todo_list(r, todo_list, &new_todo, shortrevisions,\n> +                                    shortonto, flags);\n>         if (res == -1)\n>                 return -1;\n>         else if (res == -2) {\n>\n> > [1] - https://stackoverflow.com/a/45783848\n>\n> Thanks,\n> Taylor\n"},{"id":"486661","messageId":"xmqq4jfjftgw.fsf@gitster.g","threadId":"60726","inReplyTo":"CADA7-FOE_81ze8hdaRGLPbipihnvFcEYfp9uwnPxPVxDepG4nA@mail.gmail.com","subject":"Re: Add support for `git rebase -no-edit`","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-01-11T21:30:55Z","receivedAt":"2024-01-11T21:30:58Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Chaitanya Tata <chaitanya.tk17@gmail.com> writes:\n\n> Hi,\n>\n> I have a feature request to add `--no-edit` option to `git rebase`\n> like we do for `git commit`.\n> The workflow I typically follow is:\n>\n> * `git commit -a --fixup=XXX`\n> * `git rebase  -i HEAD~15 --autosquash`\n>\n> But it requires closing the editor without any changes. I can\n> workaround this using the `GIT_EDITOR` option, see [1]. But it would\n> be good to have this built-in.\n>\n> Thoughts?\n\nWith what is in the 'master' branch, you do not have to say\ninteractive when you do not want to go interactive.  I.e.\n\n    $ git rebase --autosquash HEAD~15\n\nshould work fine.  Building Git from the source should not be too\nhard.\n\nBy the way, make it a habit to pass non-option argument after dashed\noptions.  It is easier for your readers to understand your command\nline that way.\n\nThanks.\n"},{"id":"486662","messageId":"ZaBgqlR5F1dv9ttg@nand.local","threadId":"60726","inReplyTo":"xmqq4jfjftgw.fsf@gitster.g","subject":"Re: Add support for `git rebase -no-edit`","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2024-01-11T21:42:02Z","receivedAt":"2024-01-11T21:42:05Z","isPatch":false,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Thu, Jan 11, 2024 at 01:30:55PM -0800, Junio C Hamano wrote:\n> Chaitanya Tata <chaitanya.tk17@gmail.com> writes:\n>\n> > Hi,\n> >\n> > I have a feature request to add `--no-edit` option to `git rebase`\n> > like we do for `git commit`.\n> > The workflow I typically follow is:\n> >\n> > * `git commit -a --fixup=XXX`\n> > * `git rebase  -i HEAD~15 --autosquash`\n> >\n> > But it requires closing the editor without any changes. I can\n> > workaround this using the `GIT_EDITOR` option, see [1]. But it would\n> > be good to have this built-in.\n> >\n> > Thoughts?\n>\n> With what is in the 'master' branch, you do not have to say\n> interactive when you do not want to go interactive.  I.e.\n>\n>     $ git rebase --autosquash HEAD~15\n>\n> should work fine.  Building Git from the source should not be too\n> hard.\n\nOh, duh. Indeed, 297be59456 (rebase: support --autosquash without -i,\n2023-11-14) will do what Chaitanya is looking for. I'll give myself pass\non remembering that patch since it is from last year ;-).\n\nThanks,\nTaylor\n"},{"id":"486668","messageId":"CADA7-FPFb5vmcT+9drdo=bYnixisvMiBqC5x8dPvFt61+FjsVw@mail.gmail.com","threadId":"60726","inReplyTo":"ZaBgqlR5F1dv9ttg@nand.local","subject":"Re: Add support for `git rebase -no-edit`","fromName":"Chaitanya Tata","fromEmail":"chaitanya.tk17@gmail.com","sentAt":"2024-01-11T21:46:29Z","receivedAt":"2024-01-11T21:46:45Z","isPatch":false,"sender":{"key":"chaitanya.tk17@gmail.com","avatar":null},"body":"On Fri, Jan 12, 2024 at 3:12 AM Taylor Blau <me@ttaylorr.com> wrote:\n>\n> On Thu, Jan 11, 2024 at 01:30:55PM -0800, Junio C Hamano wrote:\n> > Chaitanya Tata <chaitanya.tk17@gmail.com> writes:\n> >\n> > > Hi,\n> > >\n> > > I have a feature request to add `--no-edit` option to `git rebase`\n> > > like we do for `git commit`.\n> > > The workflow I typically follow is:\n> > >\n> > > * `git commit -a --fixup=XXX`\n> > > * `git rebase  -i HEAD~15 --autosquash`\n> > >\n> > > But it requires closing the editor without any changes. I can\n> > > workaround this using the `GIT_EDITOR` option, see [1]. But it would\n> > > be good to have this built-in.\n> > >\n> > > Thoughts?\n> >\n> > With what is in the 'master' branch, you do not have to say\n> > interactive when you do not want to go interactive.  I.e.\n> >\n> >     $ git rebase --autosquash HEAD~15\n> >\n> > should work fine.  Building Git from the source should not be too\n> > hard.\nAmazing, exactly what I need. And or arg order, I just typed in the command,\nI typically use aliases that are in the proper order, but thanks.\n>\n> Oh, duh. Indeed, 297be59456 (rebase: support --autosquash without -i,\n> 2023-11-14) will do what Chaitanya is looking for. I'll give myself pass\n> on remembering that patch since it is from last year ;-).\n:).\n\nThanks both for prompt support, I will compile and test this.\n"}]}