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 # 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.
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.
20 git am
--resolved --resolvemsg="$resolvemsg" \
21 ${gpg_sign_opt:+"$gpg_sign_opt"} &&
22 move_to_original_branch
26 git am
--skip --resolvemsg="$resolvemsg" &&
27 move_to_original_branch
32 if test -z "$rebase_root"
33 # this is now equivalent to ! -z "$upstream"
35 revisions
=$upstream...
$orig_head
37 revisions
=$onto...
$orig_head
41 if test -n "$keep_empty"
43 # we have to do this the hard way. git format-patch completely squashes
44 # empty commits and even if it didn't the format doesn't really lend
45 # itself well to recording empty patches. fortunately, cherry-pick
47 git cherry-pick
${gpg_sign_opt:+"$gpg_sign_opt"} --allow-empty \
48 --right-only "$revisions" \
49 ${restrict_revision+^$restrict_revision}
52 rm -f "$GIT_DIR/rebased-patches"
54 git format-patch
-k --stdout --full-index --cherry-pick --right-only \
55 --src-prefix=a
/ --dst-prefix=b
/ --no-renames --no-cover-letter \
56 "$revisions" ${restrict_revision+^$restrict_revision} \
57 >"$GIT_DIR/rebased-patches"
62 rm -f "$GIT_DIR/rebased-patches"
65 git checkout
-q "$head_name"
68 git checkout
-q "$orig_head"
74 git encountered an error while preparing the patches to replay
79 As a result, git cannot rebase them.
84 git am
$git_am_opt --rebasing --resolvemsg="$resolvemsg" \
85 ${gpg_sign_opt:+"$gpg_sign_opt"} <"$GIT_DIR/rebased-patches"
88 rm -f "$GIT_DIR/rebased-patches"
93 test -d "$state_dir" && write_basic_state
97 move_to_original_branch
100 # ... and then we call the whole thing.