From 342623224823cbadf61370a43df6941fba477b59 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 6 Feb 2011 13:43:35 -0500 Subject: rebase: act on command line outside parsing loop To later be able to use the command line processing in git-rebase.sh for both interactive and non-interactive rebases, move anything that is specific to non-interactive rebase outside of the parsing loop. Keep only parsing and validation of command line options in the loop. Signed-off-by: Martin von Zweigbergk Signed-off-by: Junio C Hamano --- git-rebase.sh | 126 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 66 insertions(+), 60 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 1d34d4344..e3fd001f7 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -62,6 +62,8 @@ in_progress= type= # One of {"$GIT_DIR"/rebase-apply, "$GIT_DIR"/rebase-merge} state_dir= +# One of {'', continue, skip, abort}, as parsed from command line +action= read_state () { if test "$type" = merge @@ -236,66 +238,10 @@ do --verify) OK_TO_SKIP_PRE_REBASE= ;; - --continue) - test -z "$in_progress" && die "No rebase in progress?" - - git update-index --ignore-submodules --refresh && - git diff-files --quiet --ignore-submodules || { - echo "You must edit all merge conflicts and then" - echo "mark them as resolved using git add" - exit 1 - } - read_state - if test -d "$merge_dir" - then - continue_merge - while test "$msgnum" -le "$end" - do - call_merge "$msgnum" - continue_merge - done - finish_rb_merge - exit - fi - git am --resolved --3way --resolvemsg="$RESOLVEMSG" && - move_to_original_branch - exit - ;; - --skip) - test -z "$in_progress" && die "No rebase in progress?" - - git reset --hard HEAD || exit $? - read_state - if test -d "$merge_dir" - then - git rerere clear - msgnum=$(($msgnum + 1)) - while test "$msgnum" -le "$end" - do - call_merge "$msgnum" - continue_merge - done - finish_rb_merge - exit - fi - git am -3 --skip --resolvemsg="$RESOLVEMSG" && - move_to_original_branch - exit - ;; - --abort) - test -z "$in_progress" && die "No rebase in progress?" - - git rerere clear - read_state - case "$head_name" in - refs/*) - git symbolic-ref HEAD $head_name || - die "Could not move back to $head_name" - ;; - esac - git reset --hard $orig_head - rm -r "$state_dir" - exit + --continue|--skip|--abort) + action=${1##--} + shift + break ;; --onto) test 2 -le "$#" || usage @@ -391,6 +337,66 @@ do done test $# -gt 2 && usage +test -n "$action" && test -z "$in_progress" && die "No rebase in progress?" + +case "$action" in +continue) + git update-index --ignore-submodules --refresh && + git diff-files --quiet --ignore-submodules || { + echo "You must edit all merge conflicts and then" + echo "mark them as resolved using git add" + exit 1 + } + read_state + if test -d "$merge_dir" + then + continue_merge + while test "$msgnum" -le "$end" + do + call_merge "$msgnum" + continue_merge + done + finish_rb_merge + exit + fi + git am --resolved --3way --resolvemsg="$RESOLVEMSG" && + move_to_original_branch + exit + ;; +skip) + git reset --hard HEAD || exit $? + read_state + if test -d "$merge_dir" + then + git rerere clear + msgnum=$(($msgnum + 1)) + while test "$msgnum" -le "$end" + do + call_merge "$msgnum" + continue_merge + done + finish_rb_merge + exit + fi + git am -3 --skip --resolvemsg="$RESOLVEMSG" && + move_to_original_branch + exit + ;; +abort) + git rerere clear + read_state + case "$head_name" in + refs/*) + git symbolic-ref HEAD $head_name || + die "Could not move back to $head_name" + ;; + esac + git reset --hard $orig_head + rm -r "$state_dir" + exit + ;; +esac + # Make sure no rebase is in progress if test -n "$in_progress" then -- cgit v1.2.1