summaryrefslogtreecommitdiff
path: root/git-rebase.sh
diff options
context:
space:
mode:
authorMartin von Zweigbergk <martin.von.zweigbergk@gmail.com>2011-02-06 13:43:35 -0500
committerJunio C Hamano <gitster@pobox.com>2011-02-10 14:08:08 -0800
commit342623224823cbadf61370a43df6941fba477b59 (patch)
tree568597aeb6d1fbaf35ef9ecf5571c71bca1396df /git-rebase.sh
parent99de0640f2837d31f84d2889a770d936ae4394be (diff)
downloadgit-342623224823cbadf61370a43df6941fba477b59.tar.gz
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>
Diffstat (limited to 'git-rebase.sh')
-rwxr-xr-xgit-rebase.sh126
1 files changed, 66 insertions, 60 deletions
diff --git a/git-rebase.sh b/git-rebase.sh
index 1d34d43440..e3fd001f7b 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