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, older (9.x) versions of FreeBSD /bin/sh misbehave on such a
13 # construct and continue 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
31 exec git am
--show-current-patch
35 if test -z "$rebase_root"
36 # this is now equivalent to ! -z "$upstream"
38 revisions
=$upstream...
$orig_head
40 revisions
=$onto...
$orig_head
44 if test -n "$keep_empty"
46 # we have to do this the hard way. git format-patch completely squashes
47 # empty commits and even if it didn't the format doesn't really lend
48 # itself well to recording empty patches. fortunately, cherry-pick
50 git cherry-pick
${gpg_sign_opt:+"$gpg_sign_opt"} --allow-empty \
51 $allow_rerere_autoupdate --right-only "$revisions" \
52 $allow_empty_message \
53 ${restrict_revision+^$restrict_revision}
56 rm -f "$GIT_DIR/rebased-patches"
58 git format-patch
-k --stdout --full-index --cherry-pick --right-only \
59 --src-prefix=a
/ --dst-prefix=b
/ --no-renames --no-cover-letter \
61 $git_format_patch_opt \
62 "$revisions" ${restrict_revision+^$restrict_revision} \
63 >"$GIT_DIR/rebased-patches"
68 rm -f "$GIT_DIR/rebased-patches"
71 git checkout
-q "$head_name"
74 git checkout
-q "$orig_head"
80 git encountered an error while preparing the patches to replay
85 As a result, git cannot rebase them.
90 git am
$git_am_opt --rebasing --resolvemsg="$resolvemsg" \
91 --patch-format=mboxrd \
92 $allow_rerere_autoupdate \
93 ${gpg_sign_opt:+"$gpg_sign_opt"} <"$GIT_DIR/rebased-patches"
96 rm -f "$GIT_DIR/rebased-patches"
101 test -d "$state_dir" && write_basic_state
105 move_to_original_branch
108 # ... and then we call the whole thing.