Merge branch 'pw/rebase-keep-empty-fixes'
authorJunio C Hamano <gitster@pobox.com>
Wed, 25 Apr 2018 04:28:49 +0000 (13:28 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Apr 2018 04:28:49 +0000 (13:28 +0900)
"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

git-rebase.sh
sequencer.c
t/t3421-rebase-topology-linear.sh
index fb64ee1fe42e801a57f1709c15617ddbc27f05af..548c15e4a16160e15a7f32cee8ace37284dbb850 100755 (executable)
@@ -62,6 +62,7 @@ $(gettext 'Resolve all conflicts manually, mark them as resolved with
 You can instead skip this commit: run "git rebase --skip".
 To abort and get back to the state before "git rebase", run "git rebase --abort".')
 "
+squash_onto=
 unset onto
 unset restrict_revision
 cmd=
@@ -270,6 +271,9 @@ do
        --allow-empty-message)
                allow_empty_message=--allow-empty-message
                ;;
+       --no-keep-empty)
+               keep_empty=
+               ;;
        --preserve-merges)
                preserve_merges=t
                test -z "$interactive_rebase" && interactive_rebase=implied
index 667f35ebdffbc1ef730e310cbea9b3dbce786e21..eedd45ef8327e97c167504806580fe43522deddf 100644 (file)
@@ -3001,7 +3001,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;
@@ -3026,8 +3026,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