]> granicus.if.org Git - git/commitdiff
rebase -i --keep-empty: don't prune empty commits
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Tue, 20 Mar 2018 10:03:14 +0000 (10:03 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 29 Mar 2018 17:46:48 +0000 (10:46 -0700)
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>
sequencer.c
t/t3421-rebase-topology-linear.sh

index 4d3f60594cbf0e9ddf2ea78e8c58eca312b4cac0..1a10766492e8772e59b8fd569e4d36bfafeee03d 100644 (file)
@@ -2470,7 +2470,7 @@ int sequencer_make_script(FILE *out, int argc, const char **argv,
        init_revisions(&revs, NULL);
        revs.verbose_header = 1;
        revs.max_parents = 1;
-       revs.cherry_pick = 1;
+       revs.cherry_mark = 1;
        revs.limited = 1;
        revs.reverse = 1;
        revs.right_only = 1;
@@ -2495,8 +2495,12 @@ int sequencer_make_script(FILE *out, int argc, const char **argv,
                return error(_("make_script: error preparing revisions"));
 
        while ((commit = get_revision(&revs))) {
+               int is_empty  = is_original_commit_empty(commit);
+
+               if (!is_empty && (commit->object.flags & PATCHSAME))
+                       continue;
                strbuf_reset(&buf);
-               if (!keep_empty && is_original_commit_empty(commit))
+               if (!keep_empty && is_empty)
                        strbuf_addf(&buf, "%c ", comment_line_char);
                strbuf_addf(&buf, "%s %s ", insn,
                            oid_to_hex(&commit->object.oid));
index 68fe2003ef5f74073cafa4741bee31ade85cf5c0..52fc6885e5496ea53c74055af06827344ceed1ce 100755 (executable)
@@ -215,7 +215,7 @@ test_run_rebase () {
 }
 test_run_rebase success ''
 test_run_rebase failure -m
-test_run_rebase failure -i
+test_run_rebase success -i
 test_run_rebase failure -p
 
 #       m