]> git.ipfire.org Git - thirdparty/git.git/blame - git-rebase--am.sh
t5318: avoid unnecessary command substitutions
[thirdparty/git.git] / git-rebase--am.sh
CommitLineData
11d62145
JN
1# This shell script fragment is sourced by git-rebase to implement
2# its default, fast, patch-based, non-interactive mode.
46df82d5
MZ
3#
4# Copyright (c) 2010 Junio C Hamano.
5#
6
9f50d32b
KM
7git_rebase__am () {
8
46df82d5
MZ
9case "$action" in
10continue)
3ee5e540
NV
11 git am --resolved --resolvemsg="$resolvemsg" \
12 ${gpg_sign_opt:+"$gpg_sign_opt"} &&
46df82d5 13 move_to_original_branch
a1549e10 14 return
46df82d5
MZ
15 ;;
16skip)
c5e610be 17 git am --skip --resolvemsg="$resolvemsg" &&
46df82d5 18 move_to_original_branch
a1549e10 19 return
46df82d5 20 ;;
66335298
NTND
21show-current-patch)
22 exec git am --show-current-patch
23 ;;
46df82d5
MZ
24esac
25
b6266dc8
JK
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
46df82d5 33
e481af06 34ret=0
da27a6fb 35rm -f "$GIT_DIR/rebased-patches"
e481af06 36
da27a6fb
PW
37git format-patch -k --stdout --full-index --cherry-pick --right-only \
38 --src-prefix=a/ --dst-prefix=b/ --no-renames --no-cover-letter \
39 --pretty=mboxrd \
40 $git_format_patch_opt \
41 "$revisions" ${restrict_revision+^$restrict_revision} \
42 >"$GIT_DIR/rebased-patches"
43ret=$?
e481af06 44
da27a6fb
PW
45if test 0 != $ret
46then
47 rm -f "$GIT_DIR/rebased-patches"
48 case "$head_name" in
49 refs/heads/*)
50 git checkout -q "$head_name"
51 ;;
52 *)
53 git checkout -q "$orig_head"
54 ;;
55 esac
e481af06 56
da27a6fb 57 cat >&2 <<-EOF
e481af06 58
da27a6fb
PW
59 git encountered an error while preparing the patches to replay
60 these revisions:
e481af06 61
da27a6fb 62 $revisions
e481af06 63
da27a6fb
PW
64 As a result, git cannot rebase them.
65 EOF
66 return $ret
67fi
e481af06 68
da27a6fb
PW
69git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" \
70 --patch-format=mboxrd \
71 $allow_rerere_autoupdate \
72 ${gpg_sign_opt:+"$gpg_sign_opt"} <"$GIT_DIR/rebased-patches"
73ret=$?
e481af06 74
da27a6fb 75rm -f "$GIT_DIR/rebased-patches"
e481af06
AW
76
77if test 0 != $ret
78then
79 test -d "$state_dir" && write_basic_state
a1549e10 80 return $ret
e481af06 81fi
90e1818f 82
e481af06 83move_to_original_branch
9f50d32b
KM
84
85}