]> git.ipfire.org Git - thirdparty/git.git/blame - git-rebase--am.sh
directory rename detection: testcases exploring possibly suboptimal merges
[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
90e1818f
NH
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
b6266dc8 41 git cherry-pick ${gpg_sign_opt:+"$gpg_sign_opt"} --allow-empty \
5fb415b5 42 $allow_rerere_autoupdate --right-only "$revisions" \
a6c612b5 43 $allow_empty_message \
1e0dacdb 44 ${restrict_revision+^$restrict_revision}
e481af06 45 ret=$?
90e1818f 46else
e481af06
AW
47 rm -f "$GIT_DIR/rebased-patches"
48
b6266dc8 49 git format-patch -k --stdout --full-index --cherry-pick --right-only \
0597ffa5 50 --src-prefix=a/ --dst-prefix=b/ --no-renames --no-cover-letter \
ae3b2b04 51 --pretty=mboxrd \
9eaa858e 52 $git_format_patch_opt \
1e0dacdb
JK
53 "$revisions" ${restrict_revision+^$restrict_revision} \
54 >"$GIT_DIR/rebased-patches"
e481af06
AW
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
60d708b2 78 return $ret
e481af06
AW
79 fi
80
3ee5e540 81 git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" \
ae3b2b04 82 --patch-format=mboxrd \
5fb415b5 83 $allow_rerere_autoupdate \
3ee5e540 84 ${gpg_sign_opt:+"$gpg_sign_opt"} <"$GIT_DIR/rebased-patches"
e481af06
AW
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
a1549e10 93 return $ret
e481af06 94fi
90e1818f 95
e481af06 96move_to_original_branch
9f50d32b
KM
97
98}