Merge branch 'km/avoid-cp-a'
[git/git-svn.git] / git-rebase--am.sh
blobdf46f4ca9629253238e94ae31ae26c77b452dde3
1 # This shell script fragment is sourced by git-rebase to implement
2 # its default, fast, patch-based, non-interactive mode.
4 # Copyright (c) 2010 Junio C Hamano.
7 case "$action" in
8 continue)
9 git am --resolved --resolvemsg="$resolvemsg" \
10 ${gpg_sign_opt:+"$gpg_sign_opt"} &&
11 move_to_original_branch
12 return
14 skip)
15 git am --skip --resolvemsg="$resolvemsg" &&
16 move_to_original_branch
17 return
19 esac
21 test -n "$rebase_root" && root_flag=--root
23 ret=0
24 if test -n "$keep_empty"
25 then
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=$?
32 else
33 rm -f "$GIT_DIR/rebased-patches"
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=$?
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"
48 git checkout -q "$orig_head"
50 esac
52 cat >&2 <<-EOF
54 git encountered an error while preparing the patches to replay
55 these revisions:
57 $revisions
59 As a result, git cannot rebase them.
60 EOF
61 return $?
64 git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" \
65 ${gpg_sign_opt:+"$gpg_sign_opt"} <"$GIT_DIR/rebased-patches"
66 ret=$?
68 rm -f "$GIT_DIR/rebased-patches"
71 if test 0 != $ret
72 then
73 test -d "$state_dir" && write_basic_state
74 return $ret
77 move_to_original_branch