2013-11-25 21:03:52 +00:00
|
|
|
# This shell script fragment is sourced by git-rebase to implement
|
|
|
|
# its interactive mode. "git rebase --interactive" makes it easy
|
|
|
|
# to fix up commits in the middle of a series and rearrange commits.
|
2007-06-25 00:11:14 +00:00
|
|
|
#
|
|
|
|
# Copyright (c) 2006 Johannes E. Schindelin
|
|
|
|
#
|
|
|
|
# The original idea comes from Eric W. Biederman, in
|
2017-05-08 01:38:59 +00:00
|
|
|
# https://public-inbox.org/git/m1odwkyuf5.fsf_-_@ebiederm.dsl.xmission.com/
|
2012-06-26 14:51:54 +00:00
|
|
|
#
|
2010-01-14 05:54:45 +00:00
|
|
|
# The file containing rebase commands, comments, and empty lines.
|
|
|
|
# This file is created by "git rebase -i" then edited by the user. As
|
|
|
|
# the lines are processed, they are removed from the front of this
|
2011-02-06 18:43:37 +00:00
|
|
|
# file and written to the tail of $done.
|
2011-02-06 18:43:50 +00:00
|
|
|
todo="$state_dir"/git-rebase-todo
|
2010-01-14 05:54:45 +00:00
|
|
|
|
2011-02-06 18:43:49 +00:00
|
|
|
GIT_CHERRY_PICK_HELP="$resolvemsg"
|
2007-11-28 08:06:36 +00:00
|
|
|
export GIT_CHERRY_PICK_HELP
|
|
|
|
|
2016-11-21 14:18:29 +00:00
|
|
|
comment_char=$(git config --get core.commentchar 2>/dev/null)
|
|
|
|
case "$comment_char" in
|
|
|
|
'' | auto)
|
|
|
|
comment_char="#"
|
|
|
|
;;
|
|
|
|
?)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
comment_char=$(echo "$comment_char" | cut -c1)
|
|
|
|
;;
|
|
|
|
esac
|
2013-02-11 23:08:04 +00:00
|
|
|
|
2011-02-06 18:43:37 +00:00
|
|
|
orig_reflog_action="$GIT_REFLOG_ACTION"
|
2007-06-25 00:11:14 +00:00
|
|
|
|
|
|
|
comment_for_reflog () {
|
2011-02-06 18:43:37 +00:00
|
|
|
case "$orig_reflog_action" in
|
2007-06-25 00:11:14 +00:00
|
|
|
''|rebase*)
|
|
|
|
GIT_REFLOG_ACTION="rebase -i ($1)"
|
|
|
|
export GIT_REFLOG_ACTION
|
2007-09-25 15:42:51 +00:00
|
|
|
;;
|
2007-06-25 00:11:14 +00:00
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2012-09-18 01:28:08 +00:00
|
|
|
append_todo_help () {
|
2016-06-17 20:21:04 +00:00
|
|
|
gettext "
|
2013-02-11 23:08:04 +00:00
|
|
|
Commands:
|
2018-04-25 12:28:45 +00:00
|
|
|
p, pick <commit> = use commit
|
|
|
|
r, reword <commit> = use commit, but edit the commit message
|
|
|
|
e, edit <commit> = use commit, but stop for amending
|
|
|
|
s, squash <commit> = use commit, but meld into previous commit
|
|
|
|
f, fixup <commit> = like \"squash\", but discard this commit's log message
|
2018-05-27 06:51:27 +00:00
|
|
|
x, exec <command> = run command (the rest of the line) using shell
|
2018-04-25 12:28:45 +00:00
|
|
|
d, drop <commit> = remove commit
|
sequencer: introduce new commands to reset the revision
In the upcoming commits, we will teach the sequencer to rebase merges.
This will be done in a very different way from the unfortunate design of
`git rebase --preserve-merges` (which does not allow for reordering
commits, or changing the branch topology).
The main idea is to introduce new todo list commands, to support
labeling the current revision with a given name, resetting the current
revision to a previous state, and merging labeled revisions.
This idea was developed in Git for Windows' Git garden shears (that are
used to maintain Git for Windows' "thicket of branches" on top of
upstream Git), and this patch is part of the effort to make it available
to a wider audience, as well as to make the entire process more robust
(by implementing it in a safe and portable language rather than a Unix
shell script).
This commit implements the commands to label, and to reset to, given
revisions. The syntax is:
label <name>
reset <name>
Internally, the `label <name>` command creates the ref
`refs/rewritten/<name>`. This makes it possible to work with the labeled
revisions interactively, or in a scripted fashion (e.g. via the todo
list command `exec`).
These temporary refs are removed upon sequencer_remove_state(), so that
even a `git rebase --abort` cleans them up.
We disallow '#' as label because that character will be used as separator
in the upcoming `merge` command.
Later in this patch series, we will mark the `refs/rewritten/` refs as
worktree-local, to allow for interactive rebases to be run in parallel in
worktrees linked to the same repository.
As typos happen, a failed `label` or `reset` command will be rescheduled
immediately. As the previous code to reschedule a command is embedded
deeply in the pick/fixup/squash code path, we simply duplicate the few
lines. This will allow us to extend the new code path easily for the
upcoming `merge` command.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-04-25 12:28:47 +00:00
|
|
|
l, label <label> = label current HEAD with a name
|
|
|
|
t, reset <label> = reset HEAD to a label
|
sequencer: introduce the `merge` command
This patch is part of the effort to reimplement `--preserve-merges` with
a substantially improved design, a design that has been developed in the
Git for Windows project to maintain the dozens of Windows-specific patch
series on top of upstream Git.
The previous patch implemented the `label` and `reset` commands to label
commits and to reset to labeled commits. This patch adds the `merge`
command, with the following syntax:
merge [-C <commit>] <rev> # <oneline>
The <commit> parameter in this instance is the *original* merge commit,
whose author and message will be used for the merge commit that is about
to be created.
The <rev> parameter refers to the (possibly rewritten) revision to
merge. Let's see an example of a todo list (the initial `label onto`
command is an auto-generated convenience so that the label `onto` can be
used to refer to the revision onto which we rebase):
label onto
# Branch abc
reset onto
pick deadbeef Hello, world!
label abc
reset onto
pick cafecafe And now for something completely different
merge -C baaabaaa abc # Merge the branch 'abc' into master
To edit the merge commit's message (a "reword" for merges, if you will),
use `-c` (lower-case) instead of `-C`; this convention was borrowed from
`git commit` that also supports `-c` and `-C` with similar meanings.
To create *new* merges, i.e. without copying the commit message from an
existing commit, simply omit the `-C <commit>` parameter (which will
open an editor for the merge message):
merge abc
This comes in handy when splitting a branch into two or more branches.
Note: this patch only adds support for recursive merges, to keep things
simple. Support for octopus merges will be added later in a separate
patch series, support for merges using strategies other than the
recursive merge is left for the future.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-04-25 12:28:54 +00:00
|
|
|
m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
|
|
|
|
. create a merge commit using the original merge commit's
|
|
|
|
. message (or the oneline, if no original merge commit was
|
|
|
|
. specified). Use -c <commit> to reword the commit message.
|
2013-02-11 23:08:04 +00:00
|
|
|
|
|
|
|
These lines can be re-ordered; they are executed from top to bottom.
|
2016-06-17 20:21:04 +00:00
|
|
|
" | git stripspace --comment-lines >>"$todo"
|
2013-02-11 23:08:04 +00:00
|
|
|
|
2015-06-29 20:20:31 +00:00
|
|
|
if test $(get_missing_commit_check_level) = error
|
|
|
|
then
|
2016-06-17 20:21:04 +00:00
|
|
|
gettext "
|
2015-06-29 20:20:31 +00:00
|
|
|
Do not remove any line. Use 'drop' explicitly to remove a commit.
|
2016-06-17 20:21:04 +00:00
|
|
|
" | git stripspace --comment-lines >>"$todo"
|
2015-06-29 20:20:31 +00:00
|
|
|
else
|
2016-06-17 20:21:04 +00:00
|
|
|
gettext "
|
2013-02-11 23:08:04 +00:00
|
|
|
If you remove a line here THAT COMMIT WILL BE LOST.
|
2016-06-17 20:21:04 +00:00
|
|
|
" | git stripspace --comment-lines >>"$todo"
|
2015-06-29 20:20:31 +00:00
|
|
|
fi
|
2012-09-18 01:28:08 +00:00
|
|
|
}
|
|
|
|
|
2007-06-25 17:56:55 +00:00
|
|
|
die_abort () {
|
2016-06-29 06:21:27 +00:00
|
|
|
apply_autostash
|
2011-02-06 18:43:50 +00:00
|
|
|
rm -rf "$state_dir"
|
2007-06-25 17:56:55 +00:00
|
|
|
die "$1"
|
|
|
|
}
|
|
|
|
|
2007-09-25 15:42:51 +00:00
|
|
|
has_action () {
|
2013-02-11 23:08:04 +00:00
|
|
|
test -n "$(git stripspace --strip-comments <"$1")"
|
2007-09-25 15:42:51 +00:00
|
|
|
}
|
|
|
|
|
2011-10-17 20:26:23 +00:00
|
|
|
git_sequence_editor () {
|
|
|
|
if test -z "$GIT_SEQUENCE_EDITOR"
|
|
|
|
then
|
|
|
|
GIT_SEQUENCE_EDITOR="$(git config sequence.editor)"
|
|
|
|
if [ -z "$GIT_SEQUENCE_EDITOR" ]
|
|
|
|
then
|
|
|
|
GIT_SEQUENCE_EDITOR="$(git var GIT_EDITOR)" || return $?
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
eval "$GIT_SEQUENCE_EDITOR" '"$@"'
|
|
|
|
}
|
|
|
|
|
2013-08-24 00:10:42 +00:00
|
|
|
expand_todo_ids() {
|
2017-07-14 14:45:11 +00:00
|
|
|
git rebase--helper --expand-ids
|
2013-08-24 00:10:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
collapse_todo_ids() {
|
2017-07-14 14:45:11 +00:00
|
|
|
git rebase--helper --shorten-ids
|
2009-12-08 03:13:14 +00:00
|
|
|
}
|
|
|
|
|
2015-06-29 20:20:31 +00:00
|
|
|
# Switch to the branch in $into and notify it in the reflog
|
|
|
|
checkout_onto () {
|
|
|
|
GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $onto_name"
|
2016-06-17 20:21:03 +00:00
|
|
|
output git checkout $onto || die_abort "$(gettext "could not detach HEAD")"
|
2015-06-29 20:20:31 +00:00
|
|
|
git update-ref ORIG_HEAD $orig_head
|
|
|
|
}
|
|
|
|
|
|
|
|
get_missing_commit_check_level () {
|
|
|
|
check_level=$(git config --get rebase.missingCommitsCheck)
|
|
|
|
check_level=${check_level:-ignore}
|
|
|
|
# Don't be case sensitive
|
|
|
|
printf '%s' "$check_level" | tr 'A-Z' 'a-z'
|
|
|
|
}
|
|
|
|
|
2018-03-23 21:25:25 +00:00
|
|
|
# Initiate an action. If the cannot be any
|
|
|
|
# further action it may exec a command
|
|
|
|
# or exit and not return.
|
|
|
|
#
|
|
|
|
# TODO: Consider a cleaner return model so it
|
|
|
|
# never exits and always return 0 if process
|
|
|
|
# is complete.
|
|
|
|
#
|
|
|
|
# Parameter 1 is the action to initiate.
|
|
|
|
#
|
|
|
|
# Returns 0 if the action was able to complete
|
|
|
|
# and if 1 if further processing is required.
|
|
|
|
initiate_action () {
|
|
|
|
case "$1" in
|
2018-03-23 21:25:24 +00:00
|
|
|
continue)
|
2018-05-28 12:34:22 +00:00
|
|
|
exec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \
|
|
|
|
--continue
|
2018-03-23 21:25:24 +00:00
|
|
|
;;
|
|
|
|
skip)
|
|
|
|
git rerere clear
|
2018-05-28 12:34:22 +00:00
|
|
|
exec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \
|
|
|
|
--continue
|
2018-03-23 21:25:24 +00:00
|
|
|
;;
|
|
|
|
edit-todo)
|
|
|
|
git stripspace --strip-comments <"$todo" >"$todo".new
|
|
|
|
mv -f "$todo".new "$todo"
|
|
|
|
collapse_todo_ids
|
|
|
|
append_todo_help
|
|
|
|
gettext "
|
2013-02-11 23:08:04 +00:00
|
|
|
You are editing the todo file of an ongoing interactive rebase.
|
|
|
|
To continue rebase after editing, run:
|
|
|
|
git rebase --continue
|
|
|
|
|
2016-06-17 20:21:04 +00:00
|
|
|
" | git stripspace --comment-lines >>"$todo"
|
2012-09-18 01:28:09 +00:00
|
|
|
|
2018-03-23 21:25:24 +00:00
|
|
|
git_sequence_editor "$todo" ||
|
|
|
|
die "$(gettext "Could not execute editor")"
|
|
|
|
expand_todo_ids
|
2011-02-06 18:43:35 +00:00
|
|
|
|
2018-03-23 21:25:24 +00:00
|
|
|
exit
|
|
|
|
;;
|
|
|
|
show-current-patch)
|
|
|
|
exec git show REBASE_HEAD --
|
|
|
|
;;
|
2018-03-23 21:25:25 +00:00
|
|
|
*)
|
|
|
|
return 1 # continue
|
|
|
|
;;
|
2018-03-23 21:25:24 +00:00
|
|
|
esac
|
2018-03-23 21:25:25 +00:00
|
|
|
}
|
2013-06-16 08:45:13 +00:00
|
|
|
|
2018-03-23 21:25:25 +00:00
|
|
|
setup_reflog_action () {
|
2013-06-16 08:45:13 +00:00
|
|
|
comment_for_reflog start
|
2011-02-06 18:43:35 +00:00
|
|
|
|
2018-03-23 21:25:24 +00:00
|
|
|
if test ! -z "$switch_to"
|
2011-02-06 18:43:35 +00:00
|
|
|
then
|
2018-03-23 21:25:24 +00:00
|
|
|
GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to"
|
|
|
|
output git checkout "$switch_to" -- ||
|
|
|
|
die "$(eval_gettext "Could not checkout \$switch_to")"
|
|
|
|
|
|
|
|
comment_for_reflog start
|
2011-02-06 18:43:35 +00:00
|
|
|
fi
|
2018-03-23 21:25:25 +00:00
|
|
|
}
|
2017-07-14 14:44:58 +00:00
|
|
|
|
2018-03-23 21:25:25 +00:00
|
|
|
init_basic_state () {
|
2018-03-23 21:25:24 +00:00
|
|
|
orig_head=$(git rev-parse --verify HEAD) || die "$(gettext "No HEAD?")"
|
|
|
|
mkdir -p "$state_dir" || die "$(eval_gettext "Could not create temporary \$state_dir")"
|
|
|
|
rm -f "$(git rev-parse --git-path REBASE_HEAD)"
|
2012-04-20 14:36:17 +00:00
|
|
|
|
2018-03-23 21:25:24 +00:00
|
|
|
: > "$state_dir"/interactive || die "$(gettext "Could not mark as interactive")"
|
|
|
|
write_basic_state
|
2018-03-23 21:25:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
init_revisions_and_shortrevisions () {
|
|
|
|
shorthead=$(git rev-parse --short $orig_head)
|
|
|
|
shortonto=$(git rev-parse --short $onto)
|
|
|
|
if test -z "$rebase_root"
|
|
|
|
# this is now equivalent to ! -z "$upstream"
|
|
|
|
then
|
|
|
|
shortupstream=$(git rev-parse --short $upstream)
|
|
|
|
revisions=$upstream...$orig_head
|
|
|
|
shortrevisions=$shortupstream..$shorthead
|
|
|
|
else
|
|
|
|
revisions=$onto...$orig_head
|
|
|
|
shortrevisions=$shorthead
|
rebase -i --root: let the sequencer handle even the initial part
In this developer's earlier attempt to accelerate interactive rebases by
converting large parts from Unix shell script into portable, performant
C, the --root handling was specifically excluded (to simplify the task a
little bit; it still took over a year to get that reduced set of patches
into Git proper).
This patch ties up that loose end: now only --preserve-merges uses the
slow Unix shell script implementation to perform the interactive rebase.
As the rebase--helper reports progress to stderr (unlike the scripted
interactive rebase, which reports it to stdout, of all places), we have
to adjust a couple of tests that did not expect that for `git rebase -i
--root`.
This patch fixes -- at long last! -- the really old bug reported in
6a6bc5bdc4d (add tests for rebasing root, 2013-06-06) that rebasing with
--root *always* rewrote the root commit, even if there were no changes.
The bug still persists in --preserve-merges mode, of course, but that
mode will be deprecated as soon as the new --rebase-merges mode
stabilizes, anyway.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-05-03 23:01:18 +00:00
|
|
|
test -z "$squash_onto" ||
|
|
|
|
echo "$squash_onto" >"$state_dir"/squash-onto
|
2018-03-23 21:25:25 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
complete_action() {
|
|
|
|
test -s "$todo" || echo noop >> "$todo"
|
|
|
|
test -z "$autosquash" || git rebase--helper --rearrange-squash || exit
|
|
|
|
test -n "$cmd" && git rebase--helper --add-exec-commands "$cmd"
|
|
|
|
|
|
|
|
todocount=$(git stripspace --strip-comments <"$todo" | wc -l)
|
|
|
|
todocount=${todocount##* }
|
|
|
|
|
|
|
|
cat >>"$todo" <<EOF
|
|
|
|
|
|
|
|
$comment_char $(eval_ngettext \
|
|
|
|
"Rebase \$shortrevisions onto \$shortonto (\$todocount command)" \
|
|
|
|
"Rebase \$shortrevisions onto \$shortonto (\$todocount commands)" \
|
|
|
|
"$todocount")
|
|
|
|
EOF
|
|
|
|
append_todo_help
|
|
|
|
gettext "
|
|
|
|
However, if you remove everything, the rebase will be aborted.
|
|
|
|
|
|
|
|
" | git stripspace --comment-lines >>"$todo"
|
|
|
|
|
|
|
|
if test -z "$keep_empty"
|
|
|
|
then
|
|
|
|
printf '%s\n' "$comment_char $(gettext "Note that empty commits are commented out")" >>"$todo"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
has_action "$todo" ||
|
|
|
|
return 2
|
|
|
|
|
|
|
|
cp "$todo" "$todo".backup
|
|
|
|
collapse_todo_ids
|
|
|
|
git_sequence_editor "$todo" ||
|
|
|
|
die_abort "$(gettext "Could not execute editor")"
|
|
|
|
|
|
|
|
has_action "$todo" ||
|
|
|
|
return 2
|
|
|
|
|
|
|
|
git rebase--helper --check-todo-list || {
|
|
|
|
ret=$?
|
|
|
|
checkout_onto
|
|
|
|
exit $ret
|
|
|
|
}
|
|
|
|
|
|
|
|
expand_todo_ids
|
|
|
|
|
2018-05-28 12:34:22 +00:00
|
|
|
test -n "$force_rebase" ||
|
2018-03-23 21:25:25 +00:00
|
|
|
onto="$(git rebase--helper --skip-unnecessary-picks)" ||
|
|
|
|
die "Could not skip unnecessary pick commands"
|
|
|
|
|
|
|
|
checkout_onto
|
2018-05-28 12:34:22 +00:00
|
|
|
require_clean_work_tree "rebase"
|
|
|
|
exec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \
|
|
|
|
--continue
|
2018-03-23 21:25:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
git_rebase__interactive () {
|
|
|
|
initiate_action "$action"
|
|
|
|
ret=$?
|
|
|
|
if test $ret = 0; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
setup_reflog_action
|
|
|
|
init_basic_state
|
|
|
|
|
|
|
|
init_revisions_and_shortrevisions
|
|
|
|
|
2018-03-23 21:25:27 +00:00
|
|
|
git rebase--helper --make-script ${keep_empty:+--keep-empty} \
|
rebase: introduce the --rebase-merges option
Once upon a time, this here developer thought: wouldn't it be nice if,
say, Git for Windows' patches on top of core Git could be represented as
a thicket of branches, and be rebased on top of core Git in order to
maintain a cherry-pick'able set of patch series?
The original attempt to answer this was: git rebase --preserve-merges.
However, that experiment was never intended as an interactive option,
and it only piggy-backed on git rebase --interactive because that
command's implementation looked already very, very familiar: it was
designed by the same person who designed --preserve-merges: yours truly.
Some time later, some other developer (I am looking at you, Andreas!
;-)) decided that it would be a good idea to allow --preserve-merges to
be combined with --interactive (with caveats!) and the Git maintainer
(well, the interim Git maintainer during Junio's absence, that is)
agreed, and that is when the glamor of the --preserve-merges design
started to fall apart rather quickly and unglamorously.
The reason? In --preserve-merges mode, the parents of a merge commit (or
for that matter, of *any* commit) were not stated explicitly, but were
*implied* by the commit name passed to the `pick` command.
This made it impossible, for example, to reorder commits. Not to mention
to move commits between branches or, deity forbid, to split topic branches
into two.
Alas, these shortcomings also prevented that mode (whose original
purpose was to serve Git for Windows' needs, with the additional hope
that it may be useful to others, too) from serving Git for Windows'
needs.
Five years later, when it became really untenable to have one unwieldy,
big hodge-podge patch series of partly related, partly unrelated patches
in Git for Windows that was rebased onto core Git's tags from time to
time (earning the undeserved wrath of the developer of the ill-fated
git-remote-hg series that first obsoleted Git for Windows' competing
approach, only to be abandoned without maintainer later) was really
untenable, the "Git garden shears" were born [*1*/*2*]: a script,
piggy-backing on top of the interactive rebase, that would first
determine the branch topology of the patches to be rebased, create a
pseudo todo list for further editing, transform the result into a real
todo list (making heavy use of the `exec` command to "implement" the
missing todo list commands) and finally recreate the patch series on
top of the new base commit.
That was in 2013. And it took about three weeks to come up with the
design and implement it as an out-of-tree script. Needless to say, the
implementation needed quite a few years to stabilize, all the while the
design itself proved itself sound.
With this patch, the goodness of the Git garden shears comes to `git
rebase -i` itself. Passing the `--rebase-merges` option will generate
a todo list that can be understood readily, and where it is obvious
how to reorder commits. New branches can be introduced by inserting
`label` commands and calling `merge <label>`. And once this mode will
have become stable and universally accepted, we can deprecate the design
mistake that was `--preserve-merges`.
Link *1*:
https://github.com/msysgit/msysgit/blob/master/share/msysGit/shears.sh
Link *2*:
https://github.com/git-for-windows/build-extra/blob/master/shears.sh
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-04-25 12:29:04 +00:00
|
|
|
${rebase_merges:+--rebase-merges} \
|
rebase -i: introduce --rebase-merges=[no-]rebase-cousins
When running `git rebase --rebase-merges` non-interactively with an
ancestor of HEAD as <upstream> (or leaving the todo list unmodified),
we would ideally recreate the exact same commits as before the rebase.
However, if there are commits in the commit range <upstream>.. that do not
have <upstream> as direct ancestor (i.e. if `git log <upstream>..` would
show commits that are omitted by `git log --ancestry-path <upstream>..`),
this is currently not the case: we would turn them into commits that have
<upstream> as direct ancestor.
Let's illustrate that with a diagram:
C
/ \
A - B - E - F
\ /
D
Currently, after running `git rebase -i --rebase-merges B`, the new branch
structure would be (pay particular attention to the commit `D`):
--- C' --
/ \
A - B ------ E' - F'
\ /
D'
This is not really preserving the branch topology from before! The
reason is that the commit `D` does not have `B` as ancestor, and
therefore it gets rebased onto `B`.
This is unintuitive behavior. Even worse, when recreating branch
structure, most use cases would appear to want cousins *not* to be
rebased onto the new base commit. For example, Git for Windows (the
heaviest user of the Git garden shears, which served as the blueprint
for --rebase-merges) frequently merges branches from `next` early, and
these branches certainly do *not* want to be rebased. In the example
above, the desired outcome would look like this:
--- C' --
/ \
A - B ------ E' - F'
\ /
-- D' --
Let's introduce the term "cousins" for such commits ("D" in the
example), and let's not rebase them by default. For hypothetical
use cases where cousins *do* need to be rebased, `git rebase
--rebase=merges=rebase-cousins` needs to be used.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-04-25 12:29:40 +00:00
|
|
|
${rebase_cousins:+--rebase-cousins} \
|
2018-03-23 21:25:27 +00:00
|
|
|
$revisions ${restrict_revision+^$restrict_revision} >"$todo" ||
|
|
|
|
die "$(gettext "Could not generate todo list")"
|
2018-03-23 21:25:26 +00:00
|
|
|
|
|
|
|
complete_action
|
|
|
|
}
|