rebase -i: skip unnecessary picks using the rebase--helper
In particular on Windows, where shell scripts are even more expensive than on MacOSX or Linux, it makes sense to move a loop that forks Git at least once for every line in the todo list into a builtin. Note: The original code did not try to skip unnecessary picks of root commits but punts instead (probably --root was not considered common enough of a use case to bother optimizing). We do the same, for now. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
943999493f
commit
cdac2b01ff
@ -713,43 +713,6 @@ do_rest () {
|
||||
done
|
||||
}
|
||||
|
||||
# skip picking commits whose parents are unchanged
|
||||
skip_unnecessary_picks () {
|
||||
fd=3
|
||||
while read -r command rest
|
||||
do
|
||||
# fd=3 means we skip the command
|
||||
case "$fd,$command" in
|
||||
3,pick|3,p)
|
||||
# pick a commit whose parent is current $onto -> skip
|
||||
sha1=${rest%% *}
|
||||
case "$(git rev-parse --verify --quiet "$sha1"^)" in
|
||||
"$onto"*)
|
||||
onto=$sha1
|
||||
;;
|
||||
*)
|
||||
fd=1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
3,"$comment_char"*|3,)
|
||||
# copy comments
|
||||
;;
|
||||
*)
|
||||
fd=1
|
||||
;;
|
||||
esac
|
||||
printf '%s\n' "$command${rest:+ }$rest" >&$fd
|
||||
done <"$todo" >"$todo.new" 3>>"$done" &&
|
||||
mv -f "$todo".new "$todo" &&
|
||||
case "$(peek_next_command)" in
|
||||
squash|s|fixup|f)
|
||||
record_in_rewritten "$onto"
|
||||
;;
|
||||
esac ||
|
||||
die "$(gettext "Could not skip unnecessary pick commands")"
|
||||
}
|
||||
|
||||
expand_todo_ids() {
|
||||
git rebase--helper --expand-ids
|
||||
}
|
||||
@ -1149,7 +1112,9 @@ git rebase--helper --check-todo-list || {
|
||||
|
||||
expand_todo_ids
|
||||
|
||||
test -d "$rewritten" || test -n "$force_rebase" || skip_unnecessary_picks
|
||||
test -d "$rewritten" || test -n "$force_rebase" ||
|
||||
onto="$(git rebase--helper --skip-unnecessary-picks)" ||
|
||||
die "Could not skip unnecessary pick commands"
|
||||
|
||||
checkout_onto
|
||||
if test -z "$rebase_root" && test ! -d "$rewritten"
|
||||
|
Reference in New Issue
Block a user