Skip to content

Commit d892bee

Browse files
committed
Merge branch 'pw/rebase-keep-empty-fixes'
"git rebase --keep-empty" still removed an empty commit if the other side contained an empty commit (due to the "does an equivalent patch exist already?" check), which has been corrected. * pw/rebase-keep-empty-fixes: rebase: respect --no-keep-empty rebase -i --keep-empty: don't prune empty commits rebase --root: stop assuming squash_onto is unset
2 parents 18a6a85 + 3d94616 commit d892bee

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

git-rebase.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ $(gettext 'Resolve all conflicts manually, mark them as resolved with
6262
You can instead skip this commit: run "git rebase --skip".
6363
To abort and get back to the state before "git rebase", run "git rebase --abort".')
6464
"
65+
squash_onto=
6566
unset onto
6667
unset restrict_revision
6768
cmd=
@@ -270,6 +271,9 @@ do
270271
--allow-empty-message)
271272
allow_empty_message=--allow-empty-message
272273
;;
274+
--no-keep-empty)
275+
keep_empty=
276+
;;
273277
--preserve-merges)
274278
preserve_merges=t
275279
test -z "$interactive_rebase" && interactive_rebase=implied

sequencer.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3001,7 +3001,7 @@ int sequencer_make_script(FILE *out, int argc, const char **argv,
30013001
init_revisions(&revs, NULL);
30023002
revs.verbose_header = 1;
30033003
revs.max_parents = 1;
3004-
revs.cherry_pick = 1;
3004+
revs.cherry_mark = 1;
30053005
revs.limited = 1;
30063006
revs.reverse = 1;
30073007
revs.right_only = 1;
@@ -3026,8 +3026,12 @@ int sequencer_make_script(FILE *out, int argc, const char **argv,
30263026
return error(_("make_script: error preparing revisions"));
30273027

30283028
while ((commit = get_revision(&revs))) {
3029+
int is_empty = is_original_commit_empty(commit);
3030+
3031+
if (!is_empty && (commit->object.flags & PATCHSAME))
3032+
continue;
30293033
strbuf_reset(&buf);
3030-
if (!keep_empty && is_original_commit_empty(commit))
3034+
if (!keep_empty && is_empty)
30313035
strbuf_addf(&buf, "%c ", comment_line_char);
30323036
strbuf_addf(&buf, "%s %s ", insn,
30333037
oid_to_hex(&commit->object.oid));

t/t3421-rebase-topology-linear.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ test_run_rebase () {
215215
}
216216
test_run_rebase success ''
217217
test_run_rebase failure -m
218-
test_run_rebase failure -i
218+
test_run_rebase success -i
219219
test_run_rebase failure -p
220220

221221
# m

0 commit comments

Comments
 (0)