summaryrefslogtreecommitdiff
path: root/git-rebase.sh
diff options
context:
space:
mode:
authorMartin von Zweigbergk <martin.von.zweigbergk@gmail.com>2011-02-06 13:43:39 -0500
committerJunio C Hamano <gitster@pobox.com>2011-02-10 14:08:08 -0800
commitcf432ca0512d68afa603941ecddbb45bb7ded01d (patch)
tree2ea8d82f904ae4e8faceb0dc558b5759c7283c76 /git-rebase.sh
parent9765b6abeb00145df18cde6b76a9b1fa97eeef53 (diff)
downloadgit-cf432ca0512d68afa603941ecddbb45bb7ded01d.tar.gz
rebase: factor out command line option processing
Factor out the command line processing in git-rebase--interactive.sh to git-rebase.sh. Store the options in variables in git-rebase.sh and then source git-rebase--interactive.sh. Suggested-by: Johannes Sixt <j6t@kdbg.org> 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.sh58
1 files changed, 38 insertions, 20 deletions
diff --git a/git-rebase.sh b/git-rebase.sh
index 3eac5a48b6..aa1bcaf07f 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -64,6 +64,9 @@ type=
state_dir=
# One of {'', continue, skip, abort}, as parsed from command line
action=
+preserve_merges=
+autosquash=
+test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t
read_state () {
if test "$type" = merge
@@ -176,27 +179,12 @@ finish_rb_merge () {
say All done.
}
-is_interactive () {
- while test $# != 0
- do
- case "$1" in
- -i|--interactive)
- interactive_rebase=explicit
- break
- ;;
- -p|--preserve-merges)
- interactive_rebase=implied
- ;;
- esac
- shift
- done
-
+run_interactive_rebase () {
if [ "$interactive_rebase" = implied ]; then
GIT_EDITOR=:
export GIT_EDITOR
fi
-
- test -n "$interactive_rebase" || test -f "$merge_dir"/interactive
+ . git-rebase--interactive "$@"
}
run_pre_rebase_hook () {
@@ -211,8 +199,6 @@ run_pre_rebase_hook () {
test -f "$apply_dir"/applying &&
die 'It looks like git-am is in progress. Cannot rebase.'
-is_interactive "$@" && exec git-rebase--interactive "$@"
-
if test -d "$apply_dir"
then
type=am
@@ -249,6 +235,19 @@ do
onto="$2"
shift
;;
+ -i|--interactive)
+ interactive_rebase=explicit
+ ;;
+ -p|--preserve-merges)
+ preserve_merges=t
+ test -z "$interactive_rebase" && interactive_rebase=implied
+ ;;
+ --autosquash)
+ autosquash=t
+ ;;
+ --no-autosquash)
+ autosquash=
+ ;;
-M|-m|--m|--me|--mer|--merg|--merge)
do_merge=t
;;
@@ -339,7 +338,11 @@ do
done
test $# -gt 2 && usage
-test -n "$action" && test -z "$in_progress" && die "No rebase in progress?"
+if test -n "$action"
+then
+ test -z "$in_progress" && die "No rebase in progress?"
+ test "$type" = interactive && run_interactive_rebase
+fi
case "$action" in
continue)
@@ -415,6 +418,21 @@ fi
test $# -eq 0 && test -z "$rebase_root" && usage
+if test -n "$interactive_rebase"
+then
+ type=interactive
+ state_dir="$merge_dir"
+elif test -n "$do_merge"
+then
+ type=merge
+ state_dir="$merge_dir"
+else
+ type=am
+ state_dir="$apply_dir"
+fi
+
+test "$type" = interactive && run_interactive_rebase "$@"
+
require_clean_work_tree "rebase" "Please commit or stash them."
if test -z "$rebase_root"