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

[PATCH] rebase -i: mark commits that begin empty in todo editor

From
Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>
Date
Apr 9, 2020, 23:26 UTC
Message-ID
<pull.757.git.git.1586474800276.gitgitgadget@gmail.com>
From: Elijah Newren <newren@gmail.com>

While many users who intentionally create empty commits do not want them thrown away by a rebase, there are third-party tools that generate empty commits that a user might not want. In the past, users have used rebase to get rid of such commits (a side-effect of the fact that the --apply backend is not currently capable of keeping them). While such users could fire up an interactive rebase and just remove the lines corresponding to empty commits, that might be difficult if the third-party tool generates many of them. Simplify this task for users by marking such lines with a suffix of " # empty" in the todo list.

Suggested-by: Sami Boukortt <sami@boukortt.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
---
    rebase -i: mark commits that begin empty in todo editor
    
    If this isn't enough, we could talk about resurrecting --no-keep-empty
    (and making --keep-empty just exist to countermand an earlier
    --no-keep-empty), but perhaps this is good enough?
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-757%2Fnewren%2Frebase-mark-empty-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-757/newren/rebase-mark-empty-v1
Pull-Request: https://github.com/git/git/pull/757
 Documentation/git-rebase.txt | 3 ++-
 sequencer.c                  | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index f7a6033607f..8ab0558aca2 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -620,7 +620,8 @@ commits that started empty, though these are rare in practice.  It
 also drops commits that become empty and has no option for controlling
 this behavior.
 
-The merge backend keeps intentionally empty commits.  Similar to the
+The merge backend keeps intentionally empty commits (though with -i
+they are marked as empty in the todo list editor).  Similar to the
 apply backend, by default the merge backend drops commits that become
 empty unless -i/--interactive is specified (in which case it stops and
 asks the user what to do).  The merge backend also has an
diff --git a/sequencer.c b/sequencer.c
index e528225e787..ce9fd27a878 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -4656,6 +4656,9 @@ static int make_script_with_merges(struct pretty_print_context *pp,
 			strbuf_addf(&buf, "%s %s %s", cmd_pick,
 				    oid_to_hex(&commit->object.oid),
 				    oneline.buf);
+			if (is_empty)
+				strbuf_addf(&buf, " %c empty",
+					    comment_line_char);
 
 			FLEX_ALLOC_STR(entry, string, buf.buf);
 			oidcpy(&entry->entry.oid, &commit->object.oid);
@@ -4861,6 +4864,8 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
 		strbuf_addf(out, "%s %s ", insn,
 			    oid_to_hex(&commit->object.oid));
 		pretty_print_commit(&pp, commit, out);
+		if (is_empty)
+			strbuf_addf(out, " %c empty", comment_line_char);
 		strbuf_addch(out, '\n');
 	}
 	return 0;

base-commit: 274b9cc25322d9ee79aa8e6d4e86f0ffe5ced925
-- 
gitgitgadget
Next: Junio C Hamano
Message 1 of 27 in “rebase -i: mark commits that begin empty in todo editor”
  1. rebase -i: mark commits that begin empty in todo editorElijah Newren via GitGitGadget, Apr 9, 2020
  2. Junio C HamanoApr 10, 2020
  3. Bryan TurnerApr 10, 2020
  4. Junio C HamanoApr 10, 2020
  5. 0/3 rebase -i: mark commits that begin empty in todo editorElijah Newren via GitGitGadget, Apr 10, 2020
  6. 1/3 rebase -i: mark commits that begin empty in todo editorElijah Newren via GitGitGadget, Apr 10, 2020
  7. 2/3 rebase: reinstate --no-keep-emptyElijah Newren via GitGitGadget, Apr 10, 2020
  8. Junio C HamanoApr 10, 2020
  9. Elijah NewrenApr 10, 2020
  10. 3/3 rebase: fix an incompatible-options error messageElijah Newren via GitGitGadget, Apr 10, 2020
  11. Junio C HamanoApr 10, 2020
  12. Junio C HamanoApr 10, 2020
  13. Junio C HamanoApr 10, 2020
  14. Elijah NewrenApr 10, 2020
  15. Junio C HamanoApr 10, 2020
  16. Elijah NewrenApr 10, 2020
  17. Junio C HamanoApr 10, 2020
  18. Elijah NewrenApr 11, 2020
  19. Junio C HamanoApr 11, 2020
  20. 0/4 rebase -i: mark commits that begin empty in todo editorElijah Newren via GitGitGadget, Apr 11, 2020
  21. 2/4 rebase: reinstate --no-keep-emptyElijah Newren via GitGitGadget, Apr 11, 2020
  22. 1/4 rebase -i: mark commits that begin empty in todo editorElijah Newren via GitGitGadget, Apr 11, 2020
  23. Junio C HamanoApr 15, 2020
  24. 3/4 rebase: fix an incompatible-options error messageElijah Newren via GitGitGadget, Apr 11, 2020
  25. 4/4 rebase --merge: optionally skip upstreamed commitsJonathan Tan via GitGitGadget, Apr 11, 2020
  26. Jonathan TanApr 11, 2020
  27. Phillip WoodApr 14, 2020

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.