git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Add support for `git rebase -no-edit`

From
Taylor Blau <me@ttaylorr.com>
Date
Jan 11, 2024, 19:55 UTC
Message-ID
<ZaBHooq6ORZ3TTkL@nand.local>
In-Reply-To
<CADA7-FOE_81ze8hdaRGLPbipihnvFcEYfp9uwnPxPVxDepG4nA@mail.gmail.com>
Hi Chaitanya,
On Thu, Jan 11, 2024 at 10:55:47PM +0530, Chaitanya Tata wrote:
Show 12 quoted lines
> Hi,
>
> I have a feature request to add `--no-edit` option to `git rebase`
> like we do for `git commit`.
> The workflow I typically follow is:
>
> * `git commit -a --fixup=XXX`
> * `git rebase  -i HEAD~15 --autosquash`
>
> But it requires closing the editor without any changes. I can
> workaround this using the `GIT_EDITOR` option, see [1]. But it would
> be good to have this built-in.

The easiest workaround would be setting GIT_EDITOR=true, which matches the recommendation in [1].

Short of that, you can't do a non-interactive rebase, since we rely on the todo list generated by interactive rebases in order for `--autosquash` to work.

Presumably plumbing in a new `--[no-]edit` option would be fairly straightforward, and once that is done, the change boils down to just:

index 3cc88d8a80..5235a003f2 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -6169,7 +6169,7 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
 	struct todo_list new_todo = TODO_LIST_INIT;
 	struct strbuf *buf = &todo_list->buf, buf2 = STRBUF_INIT;
 	struct object_id oid = onto->object.oid;
-	int res;
+	int res = 0;

 	repo_find_unique_abbrev_r(r, shortonto, &oid,
 				  DEFAULT_ABBREV);
@@ -6197,8 +6197,9 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
 		return error(_("nothing to do"));
 	}

-	res = edit_todo_list(r, todo_list, &new_todo, shortrevisions,
-			     shortonto, flags);
+	if (!opts->edit)
+		res = edit_todo_list(r, todo_list, &new_todo, shortrevisions,
+				     shortonto, flags);
 	if (res == -1)
 		return -1;
 	else if (res == -2) {

> [1] - https://stackoverflow.com/a/45783848

Thanks,
Taylor
Previous: Chaitanya TataNext: Chaitanya Tata
Message 2 of 6 in “Add support for `git rebase -no-edit`”
  1. Chaitanya TataJan 11, 2024
  2. Taylor BlauJan 11, 2024
  3. Chaitanya TataJan 11, 2024
  4. Junio C HamanoJan 11, 2024
  5. Taylor BlauJan 11, 2024
  6. Chaitanya TataJan 11, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.