git-rebase--am.shon commit completion: implement and use --list-cmds=main,others (6bb2dc0)
   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
   7git_rebase__am () {
   8
   9case "$action" in
  10continue)
  11        git am --resolved --resolvemsg="$resolvemsg" \
  12                ${gpg_sign_opt:+"$gpg_sign_opt"} &&
  13        move_to_original_branch
  14        return
  15        ;;
  16skip)
  17        git am --skip --resolvemsg="$resolvemsg" &&
  18        move_to_original_branch
  19        return
  20        ;;
  21show-current-patch)
  22        exec git am --show-current-patch
  23        ;;
  24esac
  25
  26if test -z "$rebase_root"
  27        # this is now equivalent to ! -z "$upstream"
  28then
  29        revisions=$upstream...$orig_head
  30else
  31        revisions=$onto...$orig_head
  32fi
  33
  34ret=0
  35if test -n "$keep_empty"
  36then
  37        # we have to do this the hard way.  git format-patch completely squashes
  38        # empty commits and even if it didn't the format doesn't really lend
  39        # itself well to recording empty patches.  fortunately, cherry-pick
  40        # makes this easy
  41        git cherry-pick ${gpg_sign_opt:+"$gpg_sign_opt"} --allow-empty \
  42                $allow_rerere_autoupdate --right-only "$revisions" \
  43                $allow_empty_message \
  44                ${restrict_revision+^$restrict_revision}
  45        ret=$?
  46else
  47        rm -f "$GIT_DIR/rebased-patches"
  48
  49        git format-patch -k --stdout --full-index --cherry-pick --right-only \
  50                --src-prefix=a/ --dst-prefix=b/ --no-renames --no-cover-letter \
  51                --pretty=mboxrd \
  52                $git_format_patch_opt \
  53                "$revisions" ${restrict_revision+^$restrict_revision} \
  54                >"$GIT_DIR/rebased-patches"
  55        ret=$?
  56
  57        if test 0 != $ret
  58        then
  59                rm -f "$GIT_DIR/rebased-patches"
  60                case "$head_name" in
  61                refs/heads/*)
  62                        git checkout -q "$head_name"
  63                        ;;
  64                *)
  65                        git checkout -q "$orig_head"
  66                        ;;
  67                esac
  68
  69                cat >&2 <<-EOF
  70
  71                git encountered an error while preparing the patches to replay
  72                these revisions:
  73
  74                    $revisions
  75
  76                As a result, git cannot rebase them.
  77                EOF
  78                return $ret
  79        fi
  80
  81        git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" \
  82                --patch-format=mboxrd \
  83                $allow_rerere_autoupdate \
  84                ${gpg_sign_opt:+"$gpg_sign_opt"} <"$GIT_DIR/rebased-patches"
  85        ret=$?
  86
  87        rm -f "$GIT_DIR/rebased-patches"
  88fi
  89
  90if test 0 != $ret
  91then
  92        test -d "$state_dir" && write_basic_state
  93        return $ret
  94fi
  95
  96move_to_original_branch
  97
  98}