rebase -i --keep-empty: don't prune empty commits
If there are empty commits on the left hand side of $upstream...HEAD then the empty commits on the right hand side that we want to keep are pruned by --cherry-pick. Fix this by using --cherry-mark instead of --cherry-pick and keeping the commits that are empty or are not marked as cherry-picks. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood committed
Mar 20, 2018 at 10:03 UTC
76ea235891c08e43226391cceaca8be056a1f803
2 files changed
+7
-3
sequencer.c
+6
-2
@@ -2470,7 +2470,7 @@ int sequencer_make_script(FILE *out, int argc, const char **argv,
2470
init_revisions(&revs, NULL);
2471
revs.verbose_header = 1;
2472
revs.max_parents = 1;
2473
- revs.cherry_pick = 1;
2473
+ revs.cherry_mark = 1;
2474
revs.limited = 1;
2475
revs.reverse = 1;
2476
revs.right_only = 1;
@@ -2495,8 +2495,12 @@ int sequencer_make_script(FILE *out, int argc, const char **argv,
2495
return error(_("make_script: error preparing revisions"));
2496
2497
while ((commit = get_revision(&revs))) {
2498
+ int is_empty = is_original_commit_empty(commit);
2499
+
2500
+ if (!is_empty && (commit->object.flags & PATCHSAME))
2501
+ continue;
2502
strbuf_reset(&buf);
2499
- if (!keep_empty && is_original_commit_empty(commit))
2503
+ if (!keep_empty && is_empty)
2504
strbuf_addf(&buf, "%c ", comment_line_char);
2505
strbuf_addf(&buf, "%s %s ", insn,
2506
oid_to_hex(&commit->object.oid));
t/t3421-rebase-topology-linear.sh
+1
-1
@@ -215,7 +215,7 @@ test_run_rebase () {
215
}
216
test_run_rebase success ''
217
test_run_rebase failure -m
218
-test_run_rebase failure -i
218
+test_run_rebase success -i
219
test_run_rebase failure -p
220
221
# m