Skip to content

Commit 1b5735f

Browse files
newrengitster
authored andcommitted
rebase -i: mark commits that begin empty in todo editor
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 <[email protected]> Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 274b9cc commit 1b5735f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Documentation/git-rebase.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,8 @@ commits that started empty, though these are rare in practice. It
620620
also drops commits that become empty and has no option for controlling
621621
this behavior.
622622

623-
The merge backend keeps intentionally empty commits. Similar to the
623+
The merge backend keeps intentionally empty commits (though with -i
624+
they are marked as empty in the todo list editor). Similar to the
624625
apply backend, by default the merge backend drops commits that become
625626
empty unless -i/--interactive is specified (in which case it stops and
626627
asks the user what to do). The merge backend also has an

sequencer.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4656,6 +4656,9 @@ static int make_script_with_merges(struct pretty_print_context *pp,
46564656
strbuf_addf(&buf, "%s %s %s", cmd_pick,
46574657
oid_to_hex(&commit->object.oid),
46584658
oneline.buf);
4659+
if (is_empty)
4660+
strbuf_addf(&buf, " %c empty",
4661+
comment_line_char);
46594662

46604663
FLEX_ALLOC_STR(entry, string, buf.buf);
46614664
oidcpy(&entry->entry.oid, &commit->object.oid);
@@ -4861,6 +4864,8 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
48614864
strbuf_addf(out, "%s %s ", insn,
48624865
oid_to_hex(&commit->object.oid));
48634866
pretty_print_commit(&pp, commit, out);
4867+
if (is_empty)
4868+
strbuf_addf(out, " %c empty", comment_line_char);
48644869
strbuf_addch(out, '\n');
48654870
}
48664871
return 0;

0 commit comments

Comments
 (0)