git-rebase--am.shon commit Merge branch 'maint' (2d1a5a5)
   1# This shell script fragment is sourced by git-rebase to implement
   2# its default, fast, patch-based, non-interactive mode.
   3#
   4# Copyright (c) 2010 Junio C Hamano.
   5#
   6
   7case "$action" in
   8continue)
   9        git am --resolved --resolvemsg="$resolvemsg" \
  10                ${gpg_sign_opt:+"$gpg_sign_opt"} &&
  11        move_to_original_branch
  12        return
  13        ;;
  14skip)
  15        git am --skip --resolvemsg="$resolvemsg" &&
  16        move_to_original_branch
  17        return
  18        ;;
  19esac
  20
  21test -n "$rebase_root" && root_flag=--root
  22
  23ret=0
  24if test -n "$keep_empty"
  25then
  26        # we have to do this the hard way.  git format-patch completely squashes
  27        # empty commits and even if it didn't the format doesn't really lend
  28        # itself well to recording empty patches.  fortunately, cherry-pick
  29        # makes this easy
  30        git cherry-pick ${gpg_sign_opt:+"$gpg_sign_opt"} --allow-empty "$revisions"
  31        ret=$?
  32else
  33        rm -f "$GIT_DIR/rebased-patches"
  34
  35        git format-patch -k --stdout --full-index --ignore-if-in-upstream \
  36                --src-prefix=a/ --dst-prefix=b/ --no-renames --no-cover-letter \
  37                $root_flag "$revisions" >"$GIT_DIR/rebased-patches"
  38        ret=$?
  39
  40        if test 0 != $ret
  41        then
  42                rm -f "$GIT_DIR/rebased-patches"
  43                case "$head_name" in
  44                refs/heads/*)
  45                        git checkout -q "$head_name"
  46                        ;;
  47                *)
  48                        git checkout -q "$orig_head"
  49                        ;;
  50                esac
  51
  52                cat >&2 <<-EOF
  53
  54                git encountered an error while preparing the patches to replay
  55                these revisions:
  56
  57                    $revisions
  58
  59                As a result, git cannot rebase them.
  60                EOF
  61                return $?
  62        fi
  63
  64        git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" \
  65                ${gpg_sign_opt:+"$gpg_sign_opt"} <"$GIT_DIR/rebased-patches"
  66        ret=$?
  67
  68        rm -f "$GIT_DIR/rebased-patches"
  69fi
  70
  71if test 0 != $ret
  72then
  73        test -d "$state_dir" && write_basic_state
  74        return $ret
  75fi
  76
  77move_to_original_branch