Merge branch 'ml/rebase-x-strategy'

* ml/rebase-x-strategy:
  rebase: support -X to pass through strategy options
This commit is contained in:
Junio C Hamano 2010-08-18 12:29:47 -07:00
commit 06d11b2e8d
3 changed files with 39 additions and 1 deletions

View file

@ -250,6 +250,13 @@ on top of the <upstream> branch using the given strategy, using
the 'ours' strategy simply discards all patches from the <branch>,
which makes little sense.
-X <strategy-option>::
--strategy-option=<strategy-option>::
Pass the <strategy-option> through to the merge strategy.
This implies `\--merge` and, if no strategy has been
specified, `-s recursive`. Note the reversal of 'ours' and
'theirs' as noted in above for the `-m` option.
-q::
--quiet::
Be quiet. Implies --no-stat.

View file

@ -44,6 +44,7 @@ To restore the original branch and stop rebasing run \"git rebase --abort\".
"
unset newbase
strategy=recursive
strategy_opts=
do_merge=
dotest="$GIT_DIR"/rebase-merge
prec=4
@ -112,7 +113,7 @@ call_merge () {
then
export GIT_MERGE_VERBOSITY=1
fi
git-merge-$strategy "$cmt^" -- "$hd" "$cmt"
eval 'git-merge-$strategy' $strategy_opts '"$cmt^" -- "$hd" "$cmt"'
rv=$?
case "$rv" in
0)
@ -294,6 +295,27 @@ do
-M|-m|--m|--me|--mer|--merg|--merge)
do_merge=t
;;
-X*|--strategy-option*)
case "$#,$1" in
1,-X|1,--strategy-option)
usage ;;
*,-X|*,--strategy-option)
newopt="$2"
shift ;;
*,--strategy-option=*)
newopt="$(expr " $1" : ' --strategy-option=\(.*\)')" ;;
*,-X*)
newopt="$(expr " $1" : ' -X\(.*\)')" ;;
1,*)
usage ;;
esac
strategy_opts="$strategy_opts $(git rev-parse --sq-quote "--$newopt")"
do_merge=t
if test -n "$strategy"
then
strategy=recursive
fi
;;
-s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\
--strateg=*|--strategy=*|\
-s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)

View file

@ -74,6 +74,15 @@ test_expect_success 'rebase the other way' '
git rebase --merge side
'
test_expect_success 'rebase -Xtheirs' '
git checkout -b conflicting master~2 &&
echo "AB $T" >> original &&
git commit -mconflicting original &&
git rebase -Xtheirs master &&
grep AB original &&
! grep 11 original
'
test_expect_success 'merge and rebase should match' '
git diff-tree -r test-rebase test-merge >difference &&
if test -s difference