]> git.ipfire.org Git - thirdparty/git.git/blame - git-rebase--am.sh
Sync with 1.9.2
[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
46df82d5
MZ
7case "$action" in
8continue)
3ee5e540
NV
9 git am --resolved --resolvemsg="$resolvemsg" \
10 ${gpg_sign_opt:+"$gpg_sign_opt"} &&
46df82d5 11 move_to_original_branch
a1549e10 12 return
46df82d5
MZ
13 ;;
14skip)
c5e610be 15 git am --skip --resolvemsg="$resolvemsg" &&
46df82d5 16 move_to_original_branch
a1549e10 17 return
46df82d5
MZ
18 ;;
19esac
20
21test -n "$rebase_root" && root_flag=--root
22
e481af06 23ret=0
90e1818f
NH
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
3ee5e540 30 git cherry-pick ${gpg_sign_opt:+"$gpg_sign_opt"} --allow-empty "$revisions"
e481af06 31 ret=$?
90e1818f 32else
e481af06
AW
33 rm -f "$GIT_DIR/rebased-patches"
34
90e1818f 35 git format-patch -k --stdout --full-index --ignore-if-in-upstream \
0597ffa5
FC
36 --src-prefix=a/ --dst-prefix=b/ --no-renames --no-cover-letter \
37 $root_flag "$revisions" >"$GIT_DIR/rebased-patches"
e481af06
AW
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
a1549e10 61 return $?
e481af06
AW
62 fi
63
3ee5e540
NV
64 git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" \
65 ${gpg_sign_opt:+"$gpg_sign_opt"} <"$GIT_DIR/rebased-patches"
e481af06
AW
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
a1549e10 74 return $ret
e481af06 75fi
90e1818f 76
e481af06 77move_to_original_branch