]> git.ipfire.org Git - thirdparty/git.git/blame - git-rebase--am.sh
am doc: add a pointer to relevant hooks
[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)
c5e610be 9 git am --resolved --resolvemsg="$resolvemsg" &&
46df82d5 10 move_to_original_branch
a1549e10 11 return
46df82d5
MZ
12 ;;
13skip)
c5e610be 14 git am --skip --resolvemsg="$resolvemsg" &&
46df82d5 15 move_to_original_branch
a1549e10 16 return
46df82d5
MZ
17 ;;
18esac
19
20test -n "$rebase_root" && root_flag=--root
21
e481af06 22ret=0
90e1818f
NH
23if test -n "$keep_empty"
24then
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"
e481af06 30 ret=$?
90e1818f 31else
e481af06
AW
32 rm -f "$GIT_DIR/rebased-patches"
33
90e1818f 34 git format-patch -k --stdout --full-index --ignore-if-in-upstream \
0597ffa5
FC
35 --src-prefix=a/ --dst-prefix=b/ --no-renames --no-cover-letter \
36 $root_flag "$revisions" >"$GIT_DIR/rebased-patches"
e481af06
AW
37 ret=$?
38
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"
45 ;;
46 *)
47 git checkout -q "$orig_head"
48 ;;
49 esac
50
51 cat >&2 <<-EOF
52
53 git encountered an error while preparing the patches to replay
54 these revisions:
55
56 $revisions
57
58 As a result, git cannot rebase them.
59 EOF
a1549e10 60 return $?
e481af06
AW
61 fi
62
63 git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" <"$GIT_DIR/rebased-patches"
64 ret=$?
65
66 rm -f "$GIT_DIR/rebased-patches"
67fi
68
69if test 0 != $ret
70then
71 test -d "$state_dir" && write_basic_state
a1549e10 72 return $ret
e481af06 73fi
90e1818f 74
e481af06 75move_to_original_branch