Imported Upstream version 2.13.3
[platform/upstream/git.git] / git-rebase.sh
index af7ba5f..2cf73b8 100755 (executable)
@@ -34,6 +34,7 @@ root!              rebase all reachable commits up to the root(s)
 autosquash         move commits that begin with squash!/fixup! under -i
 committer-date-is-author-date! passed to 'git am'
 ignore-date!       passed to 'git am'
+signoff            passed to 'git am'
 whitespace=!       passed to 'git apply'
 ignore-whitespace! passed to 'git apply'
 C=!                passed to 'git apply'
@@ -43,9 +44,9 @@ continue!          continue
 abort!             abort and check out the original branch
 skip!              skip current patch and continue
 edit-todo!         edit the todo list during an interactive rebase
+quit!              abort but keep HEAD where it is
 "
 . git-sh-setup
-. git-sh-i18n
 set_reflog_action rebase
 require_work_tree_exists
 cd_to_toplevel
@@ -87,7 +88,10 @@ preserve_merges=
 autosquash=
 keep_empty=
 test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t
-gpg_sign_opt=
+case "$(git config --bool commit.gpgsign)" in
+true)  gpg_sign_opt=-S ;;
+*)     gpg_sign_opt= ;;
+esac
 
 read_basic_state () {
        test -f "$state_dir/head-name" &&
@@ -151,7 +155,7 @@ move_to_original_branch () {
                git symbolic-ref \
                        -m "rebase finished: returning to $head_name" \
                        HEAD $head_name ||
-               die "$(gettext "Could not move back to $head_name")"
+               die "$(eval_gettext "Could not move back to \$head_name")"
                ;;
        esac
 }
@@ -162,21 +166,21 @@ apply_autostash () {
                stash_sha1=$(cat "$state_dir/autostash")
                if git stash apply $stash_sha1 2>&1 >/dev/null
                then
-                       echo "$(gettext 'Applied autostash.')"
+                       echo "$(gettext 'Applied autostash.')" >&2
                else
                        git stash store -m "autostash" -q $stash_sha1 ||
                        die "$(eval_gettext "Cannot store \$stash_sha1")"
                        gettext 'Applying autostash resulted in conflicts.
 Your changes are safe in the stash.
 You can run "git stash pop" or "git stash drop" at any time.
-'
+' >&2
                fi
        fi
 }
 
 finish_rebase () {
        apply_autostash &&
-       git gc --auto &&
+       { git gc --auto || true; } &&
        rm -rf "$state_dir"
 }
 
@@ -239,7 +243,7 @@ do
        --verify)
                ok_to_skip_pre_rebase=
                ;;
-       --continue|--skip|--abort|--edit-todo)
+       --continue|--skip|--abort|--quit|--edit-todo)
                test $total_argc -eq 2 || usage
                action=${1##--}
                ;;
@@ -248,6 +252,7 @@ do
                ;;
        --exec=*)
                cmd="${cmd}exec ${1#--exec=}${LF}"
+               test -z "$interactive_rebase" && interactive_rebase=implied
                ;;
        --interactive)
                interactive_rebase=explicit
@@ -317,7 +322,7 @@ do
        --ignore-whitespace)
                git_am_opt="$git_am_opt $1"
                ;;
-       --committer-date-is-author-date|--ignore-date)
+       --committer-date-is-author-date|--ignore-date|--signoff|--no-signoff)
                git_am_opt="$git_am_opt $1"
                force_rebase=t
                ;;
@@ -348,12 +353,6 @@ do
 done
 test $# -gt 2 && usage
 
-if test -n "$cmd" &&
-   test "$interactive_rebase" != explicit
-then
-       die "$(gettext "The --exec option must be used with the --interactive option")"
-fi
-
 if test -n "$action"
 then
        test -z "$in_progress" && die "$(gettext "No rebase in progress?")"
@@ -402,6 +401,9 @@ abort)
        finish_rebase
        exit
        ;;
+quit)
+       exec rm -rf "$state_dir"
+       ;;
 edit-todo)
        run_specific_rebase
        ;;
@@ -451,7 +453,7 @@ then
                then
                        . git-parse-remote
                        error_on_missing_default_upstream "rebase" "rebase" \
-                               "against" "git rebase <branch>"
+                               "against" "git rebase $(gettext '<branch>')"
                fi
 
                test "$fork_point" = auto && fork_point=t