{"thread":{"id":"24563","subject":"[PATCH] rebase: support -X to pass through strategy options","startedAt":"2010-07-28T22:04:29Z","lastAt":"2010-08-04T09:51:08Z","messageCount":4,"participants":["Thomas Rast","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"146658","messageId":"80763c667fa4685d2b6451838c0f1809e86fe07e.1280354419.git.trast@student.ethz.ch","threadId":"24563","inReplyTo":null,"subject":"[PATCH] rebase: support -X to pass through strategy options","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-07-28T22:04:29Z","receivedAt":"2010-07-28T22:04:29Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"From: Mike Lundy <mike@fluffypenguin.org>\n\ngit-rebase calls out to merge strategies, but did not support merge\nstrategy options so far.  Add this, in the same style used in\ngit-merge.\n\nSadly we have to do the full quoting/eval dance here, since\nmerge-recursive supports the --subtree=<path> option which potentially\ncontains whitespace.\n\nThis patch does not cover git rebase -i, which does not call any merge\nstrategy directly except in --preserve-merges, and even then only for\nmerges.\n\nSigned-off-by: Mike Lundy <mike@fluffypenguin.org>\nSigned-off-by: Thomas Rast <trast@student.ethz.ch>\n---\n\nMike posted this back in February but never picked up again after\nJunio pointed out that the options can contain spaces.  This is an\nattempt to at least finish the job for normal rebase.  Apart from the\nwhitespace issues, I changed the test to verify that the option\nactually takes effect and added docs.\n\n\n Documentation/git-rebase.txt |    7 +++++++\n git-rebase.sh                |   23 ++++++++++++++++++++++-\n t/t3402-rebase-merge.sh      |    9 +++++++++\n 3 files changed, 38 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt\nindex 41e0604..dc8979e 100644\n--- a/Documentation/git-rebase.txt\n+++ b/Documentation/git-rebase.txt\n@@ -249,6 +249,13 @@ on top of the <upstream> branch using the given strategy, using\n the 'ours' strategy simply discards all patches from the <branch>,\n which makes little sense.\n \n+-X <strategy-option>::\n+--strategy-option=<strategy-option>::\n+\tPass the <strategy-option> through to the merge strategy.\n+\tThis implies `\\--merge` and, if no strategy has been\n+\tspecified, `-s recursive`.  Note the reversal of 'ours' and\n+\t'theirs' as noted in above for the `-m` option.\n+\n -q::\n --quiet::\n \tBe quiet. Implies --no-stat.\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 694546f..70efbba 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -51,6 +51,7 @@ To restore the original branch and stop rebasing run \\\"git rebase --abort\\\".\n \"\n unset newbase\n strategy=recursive\n+strategy_opts=\n do_merge=\n dotest=\"$GIT_DIR\"/rebase-merge\n prec=4\n@@ -119,7 +120,7 @@ call_merge () {\n \tthen\n \t\texport GIT_MERGE_VERBOSITY=1\n \tfi\n-\tgit-merge-$strategy \"$cmt^\" -- \"$hd\" \"$cmt\"\n+\teval 'git-merge-$strategy' $strategy_opts '\"$cmt^\" -- \"$hd\" \"$cmt\"'\n \trv=$?\n \tcase \"$rv\" in\n \t0)\n@@ -300,6 +301,26 @@ do\n \t-M|-m|--m|--me|--mer|--merg|--merge)\n \t\tdo_merge=t\n \t\t;;\n+\t-X*|--strategy-option*)\n+\t\tcase \"$#,$1\" in\n+\t\t1,-X|1,--strategy-option)\n+\t\t\tusage ;;\n+\t\t*,-X|*,--strategy-option)\n+\t\t\tnewopt=\"$2\"\n+\t\t\tshift ;;\n+\t\t*,--strategy-option=*)\n+\t\t\tnewopt=\"$(expr \"$1\" : '--strategy-option=\\(.*\\)')\" ;;\n+\t\t*,-X*)\n+\t\t\tnewopt=\"$(expr \"$1\" : '-X\\(.*\\)')\" ;;\n+\t\t1,*)\n+\t\t\tusage ;;\n+\t\tesac\n+\t\tstrategy_opts=\"$strategy_opts $(git rev-parse --sq-quote \"--$newopt\")\"\n+\t\tdo_merge=t\n+\t\tif test -n \"$strategy\"; then\n+\t\t\tstrategy=recursive\n+\t\tfi\n+\t\t;;\n \t-s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\\\n \t\t--strateg=*|--strategy=*|\\\n \t-s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)\ndiff --git a/t/t3402-rebase-merge.sh b/t/t3402-rebase-merge.sh\nindex 7b7d072..2bea656 100755\n--- a/t/t3402-rebase-merge.sh\n+++ b/t/t3402-rebase-merge.sh\n@@ -74,6 +74,15 @@ test_expect_success 'rebase the other way' '\n \tgit rebase --merge side\n '\n \n+test_expect_success 'rebase -Xtheirs' '\n+\tgit checkout -b conflicting master~2 &&\n+\techo \"AB $T\" >> original &&\n+\tgit commit -mconflicting original &&\n+\tgit rebase -Xtheirs master &&\n+\tgrep AB original &&\n+\t! grep 11 original\n+'\n+\n test_expect_success 'merge and rebase should match' '\n \tgit diff-tree -r test-rebase test-merge >difference &&\n \tif test -s difference\n-- \n1.7.2.350.ga619b6.dirty\n"},{"id":"146719","messageId":"7vd3u6uv41.fsf@alter.siamese.dyndns.org","threadId":"24563","inReplyTo":"80763c667fa4685d2b6451838c0f1809e86fe07e.1280354419.git.trast@student.ethz.ch","subject":"Re: [PATCH] rebase: support -X to pass through strategy options","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-07-29T16:10:38Z","receivedAt":"2010-07-29T16:10:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Looks good; thanks both.\n"},{"id":"147079","messageId":"7vaap3i9c0.fsf@alter.siamese.dyndns.org","threadId":"24563","inReplyTo":"7vd3u6uv41.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] rebase: support -X to pass through strategy options","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-08-03T23:07:43Z","receivedAt":"2010-08-03T23:07:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Looks good; thanks both.\n\nI spoke too fast.  You would need something like this on top to avoid\nconfusing certain implementations of \"expr\" (e.g. FreeBSD 8.0).\n\n git-rebase.sh |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex b1743ea..7d1c5c3 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -302,9 +302,9 @@ do\n \t\t\tnewopt=\"$2\"\n \t\t\tshift ;;\n \t\t*,--strategy-option=*)\n-\t\t\tnewopt=\"$(expr \"$1\" : '--strategy-option=\\(.*\\)')\" ;;\n+\t\t\tnewopt=\"$(expr \" $1\" : ' --strategy-option=\\(.*\\)')\" ;;\n \t\t*,-X*)\n-\t\t\tnewopt=\"$(expr \"$1\" : '-X\\(.*\\)')\" ;;\n+\t\t\tnewopt=\"$(expr \" $1\" : ' -X\\(.*\\)')\" ;;\n \t\t1,*)\n \t\t\tusage ;;\n \t\tesac\n"},{"id":"147102","messageId":"201008041151.08650.trast@student.ethz.ch","threadId":"24563","inReplyTo":"7vaap3i9c0.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] rebase: support -X to pass through strategy options","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-08-04T09:51:08Z","receivedAt":"2010-08-04T09:51:08Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Junio C Hamano wrote:\n> Junio C Hamano <gitster@pobox.com> writes:\n> \n> > Looks good; thanks both.\n> \n> I spoke too fast.  You would need something like this on top to avoid\n> confusing certain implementations of \"expr\" (e.g. FreeBSD 8.0).\n\nAnnoying, but thanks...  and it turns out this is even in the expr\ninfo manual, so I should have known.  Sigh.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"}]}