]> git.ipfire.org Git - thirdparty/git.git/blame_incremental - git-rebase--am.sh
Merge branch 'mh/pack-protocol-doc-fix'
[thirdparty/git.git] / git-rebase--am.sh
... / ...
CommitLineData
1# This shell script fragment is sourced by git-rebase to implement
2# its default, fast, patch-based, non-interactive mode.
3#
4# Copyright (c) 2010 Junio C Hamano.
5#
6
7git_rebase__am () {
8
9case "$action" in
10continue)
11 git am --resolved --resolvemsg="$resolvemsg" \
12 ${gpg_sign_opt:+"$gpg_sign_opt"} &&
13 move_to_original_branch
14 return
15 ;;
16skip)
17 git am --skip --resolvemsg="$resolvemsg" &&
18 move_to_original_branch
19 return
20 ;;
21show-current-patch)
22 exec git am --show-current-patch
23 ;;
24esac
25
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
33
34ret=0
35rm -f "$GIT_DIR/rebased-patches"
36
37git format-patch -k --stdout --full-index --cherry-pick --right-only \
38 --src-prefix=a/ --dst-prefix=b/ --no-renames --no-cover-letter \
39 --pretty=mboxrd --topo-order \
40 $git_format_patch_opt \
41 "$revisions" ${restrict_revision+^$restrict_revision} \
42 >"$GIT_DIR/rebased-patches"
43ret=$?
44
45if test 0 != $ret
46then
47 rm -f "$GIT_DIR/rebased-patches"
48 case "$head_name" in
49 refs/heads/*)
50 git checkout -q "$head_name"
51 ;;
52 *)
53 git checkout -q "$orig_head"
54 ;;
55 esac
56
57 cat >&2 <<-EOF
58
59 git encountered an error while preparing the patches to replay
60 these revisions:
61
62 $revisions
63
64 As a result, git cannot rebase them.
65 EOF
66 return $ret
67fi
68
69git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" \
70 --patch-format=mboxrd \
71 $allow_rerere_autoupdate \
72 ${gpg_sign_opt:+"$gpg_sign_opt"} <"$GIT_DIR/rebased-patches"
73ret=$?
74
75rm -f "$GIT_DIR/rebased-patches"
76
77if test 0 != $ret
78then
79 test -d "$state_dir" && write_basic_state
80 return $ret
81fi
82
83move_to_original_branch
84
85}