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 <martin.von.zweigbergk@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Martin von Zweigbergk 2011-02-06 13:43:35 -05:00 committed by Junio C Hamano
parent 99de0640f2
commit 3426232248
2 changed files with 213 additions and 205 deletions

View file

@ -866,6 +866,12 @@ first and then run 'git rebase --continue' again."
;;
--)
shift
break
;;
esac
shift
done
test -z "$REBASE_ROOT" -a $# -ge 1 -a $# -le 2 ||
test ! -z "$REBASE_ROOT" -a $# -le 1 || usage
test -d "$DOTEST" &&
@ -1043,7 +1049,3 @@ EOF
output git checkout $ONTO || die_abort "could not detach HEAD"
git update-ref ORIG_HEAD $HEAD
do_rest
;;
esac
shift
done

View file

@ -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