]>
Commit | Line | Data |
---|---|---|
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 |
7 | # The whole contents of this file is run by dot-sourcing it from |
8 | # inside a shell function. It used to be that "return"s we see | |
9 | # below were not inside any function, and expected to return | |
10 | # to the function that dot-sourced us. | |
11 | # | |
12 | # However, FreeBSD /bin/sh misbehaves on such a construct and | |
13 | # continues to run the statements that follow such a "return". | |
14 | # As a work-around, we introduce an extra layer of a function | |
15 | # here, and immediately call it after defining it. | |
16 | git_rebase__am () { | |
17 | ||
46df82d5 MZ |
18 | case "$action" in |
19 | continue) | |
3ee5e540 NV |
20 | git am --resolved --resolvemsg="$resolvemsg" \ |
21 | ${gpg_sign_opt:+"$gpg_sign_opt"} && | |
46df82d5 | 22 | move_to_original_branch |
a1549e10 | 23 | return |
46df82d5 MZ |
24 | ;; |
25 | skip) | |
c5e610be | 26 | git am --skip --resolvemsg="$resolvemsg" && |
46df82d5 | 27 | move_to_original_branch |
a1549e10 | 28 | return |
46df82d5 MZ |
29 | ;; |
30 | esac | |
31 | ||
32 | test -n "$rebase_root" && root_flag=--root | |
33 | ||
e481af06 | 34 | ret=0 |
90e1818f NH |
35 | if test -n "$keep_empty" |
36 | then | |
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 | |
3ee5e540 | 41 | git cherry-pick ${gpg_sign_opt:+"$gpg_sign_opt"} --allow-empty "$revisions" |
e481af06 | 42 | ret=$? |
90e1818f | 43 | else |
e481af06 AW |
44 | rm -f "$GIT_DIR/rebased-patches" |
45 | ||
90e1818f | 46 | git format-patch -k --stdout --full-index --ignore-if-in-upstream \ |
0597ffa5 FC |
47 | --src-prefix=a/ --dst-prefix=b/ --no-renames --no-cover-letter \ |
48 | $root_flag "$revisions" >"$GIT_DIR/rebased-patches" | |
e481af06 AW |
49 | ret=$? |
50 | ||
51 | if test 0 != $ret | |
52 | then | |
53 | rm -f "$GIT_DIR/rebased-patches" | |
54 | case "$head_name" in | |
55 | refs/heads/*) | |
56 | git checkout -q "$head_name" | |
57 | ;; | |
58 | *) | |
59 | git checkout -q "$orig_head" | |
60 | ;; | |
61 | esac | |
62 | ||
63 | cat >&2 <<-EOF | |
64 | ||
65 | git encountered an error while preparing the patches to replay | |
66 | these revisions: | |
67 | ||
68 | $revisions | |
69 | ||
70 | As a result, git cannot rebase them. | |
71 | EOF | |
a1549e10 | 72 | return $? |
e481af06 AW |
73 | fi |
74 | ||
3ee5e540 NV |
75 | git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" \ |
76 | ${gpg_sign_opt:+"$gpg_sign_opt"} <"$GIT_DIR/rebased-patches" | |
e481af06 AW |
77 | ret=$? |
78 | ||
79 | rm -f "$GIT_DIR/rebased-patches" | |
80 | fi | |
81 | ||
82 | if test 0 != $ret | |
83 | then | |
84 | test -d "$state_dir" && write_basic_state | |
a1549e10 | 85 | return $ret |
e481af06 | 86 | fi |
90e1818f | 87 | |
e481af06 | 88 | move_to_original_branch |
9f50d32b KM |
89 | |
90 | } | |
91 | # ... and then we call the whole thing. | |
92 | git_rebase__am |