From: Junio C Hamano Date: Mon, 3 Aug 2015 18:01:22 +0000 (-0700) Subject: Merge branch 'gr/rebase-i-drop-warn' X-Git-Tag: v2.6.0-rc0~99 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/3a760cad7952ce5d17ff77a8f376aaa35299dfa7 Merge branch 'gr/rebase-i-drop-warn' Add "drop commit-object-name subject" command as another way to skip replaying of a commit in "rebase -i", and then punish those who do not use it (and instead just remove the lines) by throwing a warning. * gr/rebase-i-drop-warn: git rebase -i: add static check for commands and SHA-1 git rebase -i: warn about removed commits git-rebase -i: add command "drop" to remove a commit --- 3a760cad7952ce5d17ff77a8f376aaa35299dfa7 diff --cc Documentation/config.txt index 9358f4c16b,8169308aad..315f2710af --- a/Documentation/config.txt +++ b/Documentation/config.txt @@@ -2180,11 -2160,17 +2180,22 @@@ rebase.autoStash: successful rebase might result in non-trivial conflicts. Defaults to false. + rebase.missingCommitsCheck:: + If set to "warn", git rebase -i will print a warning if some + commits are removed (e.g. a line was deleted), however the + rebase will still proceed. If set to "error", it will print + the previous warning and stop the rebase, 'git rebase + --edit-todo' can then be used to correct the error. If set to + "ignore", no checking is done. + To drop a commit without warning or error, use the `drop` + command in the todo-list. + Defaults to "ignore". + +rebase.instructionFormat + A format string, as specified in linkgit:git-log[1], to be used for + the instruction list during an interactive rebase. The format will automatically + have the long commit hash prepended to the format. + receive.advertiseAtomic:: By default, git-receive-pack will advertise the atomic push capability to its clients. If you don't want to this capability diff --cc Documentation/git-rebase.txt index 7dc613cf3e,2ca3b8d599..ca039546a4 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@@ -213,9 -213,12 +213,15 @@@ rebase.autoSquash: rebase.autoStash:: If set to true enable '--autostash' option by default. + rebase.missingCommitsCheck:: + If set to "warn", print warnings about removed commits in + interactive mode. If set to "error", print the warnings and + stop the rebase. If set to "ignore", no checking is + done. "ignore" by default. + +rebase.instructionFormat:: + Custom commit list format to use during an '--interactive' rebase. + OPTIONS ------- --onto :: diff --cc git-rebase--interactive.sh index 2f6ce55b58,dcc3401b5a..f01637b1fd --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@@ -502,10 -512,10 +512,10 @@@ do_pick () } do_next () { - rm -f "$msg" "$author_script" "$amend" || exit + rm -f "$msg" "$author_script" "$amend" "$state_dir"/stopped-sha || exit read -r command sha1 rest < "$todo" case "$command" in - "$comment_char"*|''|noop) + "$comment_char"*|''|noop|drop|d) mark_action_done ;; pick|p) diff --cc t/t3404-rebase-interactive.sh index 467e6c1ed5,ebdab4b95d..9d26064aba --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@@ -1102,25 -1102,127 +1102,148 @@@ test_expect_success 'rebase -i commits test $(git cat-file commit HEAD | sed -ne \$p) = I ' +test_expect_success 'rebase --continue removes CHERRY_PICK_HEAD' ' + git checkout -b commit-to-skip && + for double in X 3 1 + do + test_seq 5 | sed "s/$double/&&/" >seq && + git add seq && + test_tick && + git commit -m seq-$double + done && + git tag seq-onto && + git reset --hard HEAD~2 && + git cherry-pick seq-onto && + set_fake_editor && + test_must_fail env FAKE_LINES= git rebase -i seq-onto && + test -d .git/rebase-merge && + git rebase --continue && + git diff --exit-code seq-onto && + test ! -d .git/rebase-merge && + test ! -f .git/CHERRY_PICK_HEAD +' + + rebase_setup_and_clean () { + test_when_finished " + git checkout master && + test_might_fail git branch -D $1 && + test_might_fail git rebase --abort + " && + git checkout -b $1 master + } + + test_expect_success 'drop' ' + rebase_setup_and_clean drop-test && + set_fake_editor && + FAKE_LINES="1 drop 2 3 drop 4 5" git rebase -i --root && + test E = $(git cat-file commit HEAD | sed -ne \$p) && + test C = $(git cat-file commit HEAD^ | sed -ne \$p) && + test A = $(git cat-file commit HEAD^^ | sed -ne \$p) + ' + + cat >expect <actual && + test D = $(git cat-file commit HEAD | sed -ne \$p) && + test_cmp expect actual + ' + + cat >expect <actual && + test_cmp expect actual && + test D = $(git cat-file commit HEAD | sed -ne \$p) + ' + + cat >expect <actual && + test_cmp expect actual && + cp .git/rebase-merge/git-rebase-todo.backup \ + .git/rebase-merge/git-rebase-todo && + FAKE_LINES="1 2 drop 3 4 drop 5" \ + git rebase --edit-todo && + git rebase --continue && + test D = $(git cat-file commit HEAD | sed -ne \$p) && + test B = $(git cat-file commit HEAD^ | sed -ne \$p) + ' + + cat >expect <actual && + test_cmp expect actual && + FAKE_LINES="1 2 3 drop 4 5" git rebase --edit-todo && + git rebase --continue && + test E = $(git cat-file commit HEAD | sed -ne \$p) && + test C = $(git cat-file commit HEAD^ | sed -ne \$p) + ' + + cat >expect <actual && + test_cmp expect actual && + FAKE_LINES="1 2 4 5 6" git rebase --edit-todo && + git rebase --continue && + test E = $(git cat-file commit HEAD | sed -ne \$p) + ' + test_done