git-rebase -i: add command "drop" to remove a commit
Instead of removing a line to remove the commit, you can use the command "drop" (just like "pick" or "edit"). It has the same effect as deleting the line (removing the commit) except that you keep a visual trace of your actions, allowing a better control and reducing the possibility of removing a commit by mistake. Signed-off-by: Galan Rémi <remi.galan-alfonso@ensimag.grenoble-inp.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Galan Rémi committed
Jun 29, 2015 at 22:20 UTC
c9266d589482544d588ccfd95f54d0bfdb277aee
4 files changed
+25
-3
Documentation/git-rebase.txt
+3
@@ -514,6 +514,9 @@ rebasing.
514
If you just want to edit the commit message for a commit, replace the
515
command "pick" with the command "reword".
516
517
+To drop a commit, replace the command "pick" with "drop", or just
518
+delete the matching line.
519
+
520
If you want to fold two or more commits into one, replace the command
521
"pick" for the second and subsequent commits with "squash" or "fixup".
522
If the commits had different authors, the folded commit will be
git-rebase--interactive.sh
+2
-1
@@ -152,6 +152,7 @@ Commands:
152
s, squash = use commit, but meld into previous commit
153
f, fixup = like "squash", but discard this commit's log message
154
x, exec = run command (the rest of the line) using shell
155
+ d, drop = remove commit
156
157
These lines can be re-ordered; they are executed from top to bottom.
158
@@ -505,7 +506,7 @@ do_next () {
506
rm -f "$msg" "$author_script" "$amend" || exit
507
read -r command sha1 rest < "$todo"
508
case "$command" in
508
- "$comment_char"*|''|noop)
509
+ "$comment_char"*|''|noop|drop|d)
510
mark_action_done
511
;;
512
pick|p)
t/lib-rebase.sh
+2
-2
@@ -14,7 +14,7 @@
14
# specified line.
15
#
16
# "<cmd> <lineno>" -- add a line with the specified command
17
-# ("squash", "fixup", "edit", or "reword") and the SHA1 taken
17
+# ("squash", "fixup", "edit", "reword" or "drop") and the SHA1 taken
18
# from the specified line.
19
#
20
# "exec_cmd_with_args" -- add an "exec cmd with args" line.
@@ -46,7 +46,7 @@ set_fake_editor () {
46
action=pick
47
for line in $FAKE_LINES; do
48
case $line in
49
- squash|fixup|edit|reword)
49
+ squash|fixup|edit|reword|drop)
50
action="$line";;
51
exec*)
52
echo "$line" | sed 's/_/ /g' >> "$1";;
t/t3404-rebase-interactive.sh
+18
@@ -1102,4 +1102,22 @@ test_expect_success 'rebase -i commits that overwrite untracked files (no ff)' '
1102
test $(git cat-file commit HEAD | sed -ne \$p) = I
1103
'
1104
1105
+rebase_setup_and_clean () {
1106
+ test_when_finished "
1107
+ git checkout master &&
1108
+ test_might_fail git branch -D $1 &&
1109
+ test_might_fail git rebase --abort
1110
+ " &&
1111
+ git checkout -b $1 master
1112
+}
1113
+
1114
+test_expect_success 'drop' '
1115
+ rebase_setup_and_clean drop-test &&
1116
+ set_fake_editor &&
1117
+ FAKE_LINES="1 drop 2 3 drop 4 5" git rebase -i --root &&
1118
+ test E = $(git cat-file commit HEAD | sed -ne \$p) &&
1119
+ test C = $(git cat-file commit HEAD^ | sed -ne \$p) &&
1120
+ test A = $(git cat-file commit HEAD^^ | sed -ne \$p)
1121
+'
1122
+
1123
test_done