summaryrefslogtreecommitdiff
path: root/git-rebase--interactive.sh
diff options
context:
space:
mode:
authorLibravatar Alban Gruin <alban.gruin@gmail.com>2018-08-28 14:10:36 +0200
committerLibravatar Junio C Hamano <gitster@pobox.com>2018-08-29 13:38:18 -0700
commitb97e187364990fb8410355ff8b4365d0e37bbbbe (patch)
tree73e0346e20435cb289e56cf2c59e269339c74b43 /git-rebase--interactive.sh
parentt3404: todo list with commented-out commands only aborts (diff)
downloadtgif-b97e187364990fb8410355ff8b4365d0e37bbbbe.tar.xz
rebase -i: rewrite complete_action() in C
This rewrites complete_action() from shell to C. A new mode is added to rebase--helper (`--complete-action`), as well as a new flag (`--autosquash`). Finally, complete_action() is stripped from git-rebase--interactive.sh. The original complete_action() would return the code 2 when the todo list contained no actions. This was a special case for rebase -i and -p; git-rebase.sh would then apply the autostash, delete the state directory, and die with the message "Nothing to do". This cleanup is rewritten in C instead of returning 2. As rebase -i no longer returns 2, the comment describing this behaviour in git-rebase.sh is updated to reflect this change. The message "Nothing to do" is now printed with error(), and so becomes "error: nothing to do". Some tests in t3404 check this value, so they are updated to fit this change. The first check might seem useless as we write "noop" to the todo list if it is empty. Actually, the todo list might contain commented commands (ie. empty commits). In this case, complete_action() won’t write "noop", and will abort without starting the editor. Signed-off-by: Alban Gruin <alban.gruin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-rebase--interactive.sh')
-rw-r--r--git-rebase--interactive.sh53
1 files changed, 4 insertions, 49 deletions
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index b68f108f28..59dc4888a6 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -127,54 +127,6 @@ init_revisions_and_shortrevisions () {
fi
}
-complete_action() {
- test -s "$todo" || echo noop >> "$todo"
- test -z "$autosquash" || git rebase--helper --rearrange-squash || exit
- test -n "$cmd" && git rebase--helper --add-exec-commands "$cmd"
-
- todocount=$(git stripspace --strip-comments <"$todo" | wc -l)
- todocount=${todocount##* }
-
-cat >>"$todo" <<EOF
-
-$comment_char $(eval_ngettext \
- "Rebase \$shortrevisions onto \$shortonto (\$todocount command)" \
- "Rebase \$shortrevisions onto \$shortonto (\$todocount commands)" \
- "$todocount")
-EOF
- git rebase--helper --append-todo-help ${keep_empty:+--keep-empty}
-
- has_action "$todo" ||
- return 2
-
- cp "$todo" "$todo".backup
- collapse_todo_ids
- git_sequence_editor "$todo" ||
- die_abort "$(gettext "Could not execute editor")"
-
- has_action "$todo" ||
- return 2
-
- git rebase--helper --check-todo-list || {
- ret=$?
- git rebase--helper --checkout-onto "$onto_name" "$onto" \
- "$orig_head" ${verbose:+--verbose}
- exit $ret
- }
-
- expand_todo_ids
-
- test -n "$force_rebase" ||
- onto="$(git rebase--helper --skip-unnecessary-picks)" ||
- die "Could not skip unnecessary pick commands"
-
- git rebase--helper --checkout-onto "$onto_name" "$onto" "$orig_head" \
- ${verbose:+--verbose}
- require_clean_work_tree "rebase"
- exec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \
- --continue
-}
-
git_rebase__interactive () {
initiate_action "$action"
ret=$?
@@ -193,5 +145,8 @@ git_rebase__interactive () {
$revisions ${restrict_revision+^$restrict_revision} >"$todo" ||
die "$(gettext "Could not generate todo list")"
- complete_action
+ exec git rebase--helper --complete-action "$shortrevisions" "$onto_name" \
+ "$shortonto" "$orig_head" "$cmd" $allow_empty_message \
+ ${autosquash:+--autosquash} ${keep_empty:+--keep-empty} \
+ ${verbose:+--verbose} ${force_rebase:+--no-ff}
}