commit: fix patch hunk editing with "commit -p -m"
[git/git-svn.git] / git-rebase--am.sh
bloba4f683a5d70213151f3713cc0a2d76dfe8293fd3
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 move_to_original_branch
11 return
13 skip)
14 git am --skip --resolvemsg="$resolvemsg" &&
15 move_to_original_branch
16 return
18 esac
20 test -n "$rebase_root" && root_flag=--root
22 ret=0
23 if test -n "$keep_empty"
24 then
25 # we have to do this the hard way. git format-patch completely squashes
26 # empty commits and even if it didn't the format doesn't really lend
27 # itself well to recording empty patches. fortunately, cherry-pick
28 # makes this easy
29 git cherry-pick --allow-empty "$revisions"
30 ret=$?
31 else
32 rm -f "$GIT_DIR/rebased-patches"
34 git format-patch -k --stdout --full-index --ignore-if-in-upstream \
35 --src-prefix=a/ --dst-prefix=b/ --no-renames --no-cover-letter \
36 $root_flag "$revisions" >"$GIT_DIR/rebased-patches"
37 ret=$?
39 if test 0 != $ret
40 then
41 rm -f "$GIT_DIR/rebased-patches"
42 case "$head_name" in
43 refs/heads/*)
44 git checkout -q "$head_name"
47 git checkout -q "$orig_head"
49 esac
51 cat >&2 <<-EOF
53 git encountered an error while preparing the patches to replay
54 these revisions:
56 $revisions
58 As a result, git cannot rebase them.
59 EOF
60 return $?
63 git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" <"$GIT_DIR/rebased-patches"
64 ret=$?
66 rm -f "$GIT_DIR/rebased-patches"
69 if test 0 != $ret
70 then
71 test -d "$state_dir" && write_basic_state
72 return $ret
75 move_to_original_branch