3 # Rebase 'devel' on top of an upstream branch (defaults to 'junio/next').
4 # This merges the old state of 'devel' using the merge strategy 'ours'
5 # to enable a fast-forward.
9 # do not perform the rebase but only display the revisions selected
12 # as for dry-run but display the commits as a graph
15 # as for --dry-run but display the commits using cherry notation to mark
16 # commits that are suitable for upstream consideration.
28 -s|
--show|
-d|
--dry-run)
40 echo "Unknown option: $1" >&2
52 if test -z "$force" && test -z "$(git rev-list .."$TO")"
54 echo "Nothing new in $TO; To force a rebase, use the --force, Luke!" >&2
58 TODO_EXTRA
="$(git rev-parse --git-dir)/todo-extra"
60 case "$(git rev-parse --symbolic-full-name HEAD)" in
62 UPSTREAM
=$
(git rev-parse
--symbolic-full-name HEAD@
{u
}) ||
{
63 echo "Not tracking any remote branch!" >&2
66 test "$(git rev-parse HEAD)" = "$(git rev-parse $UPSTREAM)" ||
67 test "$(git rev-parse devel@{1})" = "$(git rev-parse $UPSTREAM)" ||
{
68 echo "Your 'devel' is not up-to-date!" >&2
74 echo "Not on 'devel'!" >&2
80 test "$(git rev-parse $1:)" = "$(git rev-parse "$1^
:")"
84 git rev-list
--parents "$@" |
sed -n 's/ .* .*//p'
87 # Find old rebasing merge, if any
90 for commit
in $
(list_merges
$TO..
)
92 if is_ours_merge
$commit
94 PREVIOUS_REBASING
=$commit
99 TO_SHA1
=$
(git rev-parse
--short $TO)
100 MESSAGE
="Rebasing merge to $TO ($TO_SHA1)"
102 if test -n "$PREVIOUS_REBASING"
104 MESSAGE
="$(printf "%s
\n\n%s
" "$MESSAGE" \
105 "Previous rebasing merge
: $PREVIOUS_REBASING")"
106 RANGE
="$RANGE ^$PREVIOUS_REBASING^2"
107 for commit
in $
(list_merges
$RANGE)
109 test $commit != $PREVIOUS_REBASING &&
110 is_ours_merge
$commit &&
111 RANGE
="$RANGE ^$commit"
117 git log
--oneline $graph $cherry --boundary $RANGE
121 ORIG_HEAD
=$
(git rev-parse HEAD
)
122 # Get commits to rebase
123 git rev-list
--format='pick %h %s (%an)' --reverse --no-merges $RANGE |
124 grep -v '^commit ' > "$TODO_EXTRA" &&
125 TMP_EDITOR
="$(git rev-parse --git-dir)/rebasing-editor.sh" &&
126 cat > "$TMP_EDITOR" << EOF &&
130 sed -e '/^[^#]/d' < "\$1" >> "$TODO_EXTRA" &&
131 mv "$TODO_EXTRA" "\$1"
133 exec "$(git var GIT_EDITOR)" "\$@"
135 chmod a
+x
"$TMP_EDITOR" &&
136 if GIT_EDITOR
="$TMP_EDITOR" git rebase
--autosquash -i --onto $TO HEAD^
138 git merge
-s ours
-m "$MESSAGE" $ORIG_HEAD
140 FINISH
="$(git rev-parse --git-dir)/finish-rebasing-merge.sh"
141 cat > "$FINISH" << EOF
142 git merge -s ours -m '$MESSAGE' $ORIG_HEAD
147 After the rebase, call '$FINISH' manually