diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2017-07-14 16:45:25 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-07-27 15:35:05 -0700 |
commit | cdac2b01ff77d32305610aeb26396e25bffa9dba (patch) | |
tree | 60a0a154b2155f1b608714de2e314dc03127b39c /git-rebase--interactive.sh | |
parent | 943999493fd4084d00bd5b5decc85b68eb64785f (diff) | |
download | git-cdac2b01ff77d32305610aeb26396e25bffa9dba.tar.gz |
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>
Diffstat (limited to 'git-rebase--interactive.sh')
-rw-r--r-- | git-rebase--interactive.sh | 41 |
1 files changed, 3 insertions, 38 deletions
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index c8cad318fa..af8d7bd77f 100644 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -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" |