mirror of
https://github.com/git/git
synced 2024-08-24 18:26:02 +00:00
Merge branch 'mm/rebase-i-post-rewrite-exec'
"git rebase -i" fired post-rewrite hook when it shouldn't (namely, when it was told to stop sequencing with 'exec' insn). * mm/rebase-i-post-rewrite-exec: t5407: use <<- to align the expected output rebase -i: fix post-rewrite hook with failed exec command rebase -i: demonstrate incorrect behavior of post-rewrite
This commit is contained in:
commit
a6be52e239
|
@ -502,7 +502,7 @@ do_pick () {
|
||||||
}
|
}
|
||||||
|
|
||||||
do_next () {
|
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"
|
read -r command sha1 rest < "$todo"
|
||||||
case "$command" in
|
case "$command" in
|
||||||
"$comment_char"*|''|noop)
|
"$comment_char"*|''|noop)
|
||||||
|
@ -592,9 +592,6 @@ do_next () {
|
||||||
read -r command rest < "$todo"
|
read -r command rest < "$todo"
|
||||||
mark_action_done
|
mark_action_done
|
||||||
printf 'Executing: %s\n' "$rest"
|
printf 'Executing: %s\n' "$rest"
|
||||||
# "exec" command doesn't take a sha1 in the todo-list.
|
|
||||||
# => can't just use $sha1 here.
|
|
||||||
git rev-parse --verify HEAD > "$state_dir"/stopped-sha
|
|
||||||
${SHELL:-@SHELL_PATH@} -c "$rest" # Actual execution
|
${SHELL:-@SHELL_PATH@} -c "$rest" # Actual execution
|
||||||
status=$?
|
status=$?
|
||||||
# Run in subshell because require_clean_work_tree can die.
|
# Run in subshell because require_clean_work_tree can die.
|
||||||
|
@ -890,7 +887,10 @@ first and then run 'git rebase --continue' again."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test -r "$state_dir"/stopped-sha
|
||||||
|
then
|
||||||
record_in_rewritten "$(cat "$state_dir"/stopped-sha)"
|
record_in_rewritten "$(cat "$state_dir"/stopped-sha)"
|
||||||
|
fi
|
||||||
|
|
||||||
require_clean_work_tree "rebase"
|
require_clean_work_tree "rebase"
|
||||||
do_rest
|
do_rest
|
||||||
|
|
|
@ -61,7 +61,7 @@ test_expect_success 'git rebase' '
|
||||||
git add foo &&
|
git add foo &&
|
||||||
git rebase --continue &&
|
git rebase --continue &&
|
||||||
echo rebase >expected.args &&
|
echo rebase >expected.args &&
|
||||||
cat >expected.data <<EOF &&
|
cat >expected.data <<-EOF &&
|
||||||
$(git rev-parse C) $(git rev-parse HEAD^)
|
$(git rev-parse C) $(git rev-parse HEAD^)
|
||||||
$(git rev-parse D) $(git rev-parse HEAD)
|
$(git rev-parse D) $(git rev-parse HEAD)
|
||||||
EOF
|
EOF
|
||||||
|
@ -77,7 +77,7 @@ test_expect_success 'git rebase --skip' '
|
||||||
git add foo &&
|
git add foo &&
|
||||||
git rebase --continue &&
|
git rebase --continue &&
|
||||||
echo rebase >expected.args &&
|
echo rebase >expected.args &&
|
||||||
cat >expected.data <<EOF &&
|
cat >expected.data <<-EOF &&
|
||||||
$(git rev-parse D) $(git rev-parse HEAD)
|
$(git rev-parse D) $(git rev-parse HEAD)
|
||||||
EOF
|
EOF
|
||||||
verify_hook_input
|
verify_hook_input
|
||||||
|
@ -89,7 +89,7 @@ test_expect_success 'git rebase --skip the last one' '
|
||||||
test_must_fail git rebase --onto D A &&
|
test_must_fail git rebase --onto D A &&
|
||||||
git rebase --skip &&
|
git rebase --skip &&
|
||||||
echo rebase >expected.args &&
|
echo rebase >expected.args &&
|
||||||
cat >expected.data <<EOF &&
|
cat >expected.data <<-EOF &&
|
||||||
$(git rev-parse E) $(git rev-parse HEAD)
|
$(git rev-parse E) $(git rev-parse HEAD)
|
||||||
EOF
|
EOF
|
||||||
verify_hook_input
|
verify_hook_input
|
||||||
|
@ -103,7 +103,7 @@ test_expect_success 'git rebase -m' '
|
||||||
git add foo &&
|
git add foo &&
|
||||||
git rebase --continue &&
|
git rebase --continue &&
|
||||||
echo rebase >expected.args &&
|
echo rebase >expected.args &&
|
||||||
cat >expected.data <<EOF &&
|
cat >expected.data <<-EOF &&
|
||||||
$(git rev-parse C) $(git rev-parse HEAD^)
|
$(git rev-parse C) $(git rev-parse HEAD^)
|
||||||
$(git rev-parse D) $(git rev-parse HEAD)
|
$(git rev-parse D) $(git rev-parse HEAD)
|
||||||
EOF
|
EOF
|
||||||
|
@ -119,7 +119,7 @@ test_expect_success 'git rebase -m --skip' '
|
||||||
git add foo &&
|
git add foo &&
|
||||||
git rebase --continue &&
|
git rebase --continue &&
|
||||||
echo rebase >expected.args &&
|
echo rebase >expected.args &&
|
||||||
cat >expected.data <<EOF &&
|
cat >expected.data <<-EOF &&
|
||||||
$(git rev-parse D) $(git rev-parse HEAD)
|
$(git rev-parse D) $(git rev-parse HEAD)
|
||||||
EOF
|
EOF
|
||||||
verify_hook_input
|
verify_hook_input
|
||||||
|
@ -148,7 +148,7 @@ test_expect_success 'git rebase -i (unchanged)' '
|
||||||
git add foo &&
|
git add foo &&
|
||||||
git rebase --continue &&
|
git rebase --continue &&
|
||||||
echo rebase >expected.args &&
|
echo rebase >expected.args &&
|
||||||
cat >expected.data <<EOF &&
|
cat >expected.data <<-EOF &&
|
||||||
$(git rev-parse C) $(git rev-parse HEAD^)
|
$(git rev-parse C) $(git rev-parse HEAD^)
|
||||||
$(git rev-parse D) $(git rev-parse HEAD)
|
$(git rev-parse D) $(git rev-parse HEAD)
|
||||||
EOF
|
EOF
|
||||||
|
@ -163,7 +163,7 @@ test_expect_success 'git rebase -i (skip)' '
|
||||||
git add foo &&
|
git add foo &&
|
||||||
git rebase --continue &&
|
git rebase --continue &&
|
||||||
echo rebase >expected.args &&
|
echo rebase >expected.args &&
|
||||||
cat >expected.data <<EOF &&
|
cat >expected.data <<-EOF &&
|
||||||
$(git rev-parse D) $(git rev-parse HEAD)
|
$(git rev-parse D) $(git rev-parse HEAD)
|
||||||
EOF
|
EOF
|
||||||
verify_hook_input
|
verify_hook_input
|
||||||
|
@ -177,7 +177,7 @@ test_expect_success 'git rebase -i (squash)' '
|
||||||
git add foo &&
|
git add foo &&
|
||||||
git rebase --continue &&
|
git rebase --continue &&
|
||||||
echo rebase >expected.args &&
|
echo rebase >expected.args &&
|
||||||
cat >expected.data <<EOF &&
|
cat >expected.data <<-EOF &&
|
||||||
$(git rev-parse C) $(git rev-parse HEAD)
|
$(git rev-parse C) $(git rev-parse HEAD)
|
||||||
$(git rev-parse D) $(git rev-parse HEAD)
|
$(git rev-parse D) $(git rev-parse HEAD)
|
||||||
EOF
|
EOF
|
||||||
|
@ -189,7 +189,7 @@ test_expect_success 'git rebase -i (fixup without conflict)' '
|
||||||
clear_hook_input &&
|
clear_hook_input &&
|
||||||
FAKE_LINES="1 fixup 2" git rebase -i B &&
|
FAKE_LINES="1 fixup 2" git rebase -i B &&
|
||||||
echo rebase >expected.args &&
|
echo rebase >expected.args &&
|
||||||
cat >expected.data <<EOF &&
|
cat >expected.data <<-EOF &&
|
||||||
$(git rev-parse C) $(git rev-parse HEAD)
|
$(git rev-parse C) $(git rev-parse HEAD)
|
||||||
$(git rev-parse D) $(git rev-parse HEAD)
|
$(git rev-parse D) $(git rev-parse HEAD)
|
||||||
EOF
|
EOF
|
||||||
|
@ -205,7 +205,24 @@ test_expect_success 'git rebase -i (double edit)' '
|
||||||
git add foo &&
|
git add foo &&
|
||||||
git rebase --continue &&
|
git rebase --continue &&
|
||||||
echo rebase >expected.args &&
|
echo rebase >expected.args &&
|
||||||
cat >expected.data <<EOF &&
|
cat >expected.data <<-EOF &&
|
||||||
|
$(git rev-parse C) $(git rev-parse HEAD^)
|
||||||
|
$(git rev-parse D) $(git rev-parse HEAD)
|
||||||
|
EOF
|
||||||
|
verify_hook_input
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'git rebase -i (exec)' '
|
||||||
|
git reset --hard D &&
|
||||||
|
clear_hook_input &&
|
||||||
|
FAKE_LINES="edit 1 exec_false 2" git rebase -i B &&
|
||||||
|
echo something >bar &&
|
||||||
|
git add bar &&
|
||||||
|
# Fails because of exec false
|
||||||
|
test_must_fail git rebase --continue &&
|
||||||
|
git rebase --continue &&
|
||||||
|
echo rebase >expected.args &&
|
||||||
|
cat >expected.data <<-EOF &&
|
||||||
$(git rev-parse C) $(git rev-parse HEAD^)
|
$(git rev-parse C) $(git rev-parse HEAD^)
|
||||||
$(git rev-parse D) $(git rev-parse HEAD)
|
$(git rev-parse D) $(git rev-parse HEAD)
|
||||||
EOF
|
EOF
|
||||||
|
|
Loading…
Reference in a new issue