File tree Expand file tree Collapse file tree 4 files changed +34
-11
lines changed
Expand file tree Collapse file tree 4 files changed +34
-11
lines changed Original file line number Diff line number Diff line change @@ -324,6 +324,16 @@ fresh commits so it can be remerged successfully without needing to "revert
324324the reversion" (see the
325325link:howto/revert-a-faulty-merge.html[revert-a-faulty-merge How-To] for details).
326326
327+ --fork-point::
328+ --no-fork-point::
329+ Use 'git merge-base --fork-point' to find a better common ancestor
330+ between `upstream` and `branch` when calculating which commits have
331+ have been introduced by `branch` (see linkgit:git-merge-base[1]).
332+ +
333+ If no non-option arguments are given on the command line, then the default is
334+ `--fork-point @{u}` otherwise the `upstream` argument is interpreted literally
335+ unless the `--fork-point` option is specified.
336+
327337--ignore-whitespace::
328338--whitespace=<option>::
329339 These flag are passed to the 'git apply' program
Original file line number Diff line number Diff line change @@ -229,15 +229,7 @@ test true = "$rebase" && {
229229 test -n " $curr_branch " &&
230230 . git-parse-remote &&
231231 remoteref=" $( get_remote_merge_branch " $@ " 2> /dev/null) " &&
232- oldremoteref=" $( git rev-parse -q --verify " $remoteref " ) " &&
233- for reflog in $( git rev-list -g $remoteref 2> /dev/null)
234- do
235- if test " $reflog " = " $( git merge-base $reflog $curr_branch ) "
236- then
237- oldremoteref=" $reflog "
238- break
239- fi
240- done
232+ oldremoteref=$( git merge-base --fork-point " $remoteref " $curr_branch )
241233}
242234orig_head=$( git rev-parse -q --verify HEAD)
243235git fetch $verbosity $progress $dry_run $recurse_submodules --update-head-ok " $@ " || exit 1
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ git-rebase --continue | --abort | --skip | --edit-todo
1414v,verbose! display a diffstat of what changed upstream
1515q,quiet! be quiet. implies --no-stat
1616autostash! automatically stash/stash pop before and after
17+ fork-point use 'merge-base --fork-point' to refine upstream
1718onto=! rebase onto given branch instead of upstream
1819p,preserve-merges! try to recreate merges instead of ignoring them
1920s,strategy=! use the given merge strategy
@@ -66,6 +67,7 @@ verbose=
6667diffstat=
6768test " $( git config --bool rebase.stat) " = true && diffstat=t
6869autostash=" $( git config --bool rebase.autostash || echo false) "
70+ fork_point=auto
6971git_am_opt=
7072rebase_root=
7173force_rebase=
260262 --no-autosquash)
261263 autosquash=
262264 ;;
265+ --fork-point)
266+ fork_point=t
267+ ;;
268+ --no-fork-point)
269+ fork_point=
270+ ;;
263271 -M|-m)
264272 do_merge=t
265273 ;;
437445 error_on_missing_default_upstream " rebase" " rebase" \
438446 " against" " git rebase <branch>"
439447 fi
448+
449+ test " $fork_point " = auto && fork_point=t
440450 ;;
441451 * ) upstream_name=" $1 "
442452 shift
@@ -522,6 +532,15 @@ case "$#" in
522532 ;;
523533esac
524534
535+ if test " $fork_point " = t
536+ then
537+ new_upstream=$( git merge-base --fork-point " $upstream_name " " $switch_to " )
538+ if test -n " $new_upstream "
539+ then
540+ upstream=$new_upstream
541+ fi
542+ fi
543+
525544if test " $autostash " = true && ! (require_clean_work_tree) 2> /dev/null
526545then
527546 stash_sha1=$( git stash create " autostash" ) ||
Original file line number Diff line number Diff line change @@ -134,12 +134,14 @@ test_expect_success 'fail when upstream arg is missing and not configured' '
134134 test_must_fail git rebase
135135'
136136
137- test_expect_success ' default to @{upstream} when upstream arg is missing ' '
137+ test_expect_success ' default to common base in @{upstream}s reflog if no upstream arg ' '
138138 git checkout -b default topic &&
139139 git config branch.default.remote . &&
140140 git config branch.default.merge refs/heads/master &&
141141 git rebase &&
142- test "$(git rev-parse default~1)" = "$(git rev-parse master)"
142+ git rev-parse --verify master >expect &&
143+ git rev-parse default~1 >actual &&
144+ test_cmp expect actual
143145'
144146
145147test_expect_success ' rebase -q is quiet' '
You can’t perform that action at this time.
0 commit comments