git rebase: passing multiple strategy options

Viewed 117

With git rebase, a merge strategy option can be passed using -X <strategy-option> or --strategy-option=<strategy-option>. It's unclear from the man page, however, whether multiple options can be passed (or if subsequent options replace previous ones) and, if so, whether the correct syntax is -X <opt1,opt2> or -X <opt1> -X <opt2>. Running git rebase --verbose -m -X <opt1> -X <opt2> <upstream> does not produce errors, but even with verbose output enabled there is no indication whether both options were applied or only the last.

1 Answers

The opt1,opt2,opt3 comma-separated syntax is used for git diff

D:\git\git\t>grep -E "\-X" *.sh|grep "\,"
t4047-diff-dirstat.sh:  test_must_fail git show -X=20,cumulative
t4047-diff-dirstat.sh:test_expect_success 'explicit defaults: -Xchanges,noncumulative,3' '
t4047-diff-dirstat.sh:  git diff -Xchanges,noncumulative,3 HEAD^..HEAD >actual_diff_dirstat &&

Not for strategy-options in merge/rebase.

For those, multiple -Xopt1 -Xopt2 are needed.

But I can find only one instance where such a syntax is tested, and for a fail case: t3418-rebase-continue.sh

test_must_fail git rebase -i -s funny -Xopt -Xfoo master topic

So in practice, I am not sure if this would ever be used.

The initial commit (Nov 2009, Git v1.7.0-rc0) which introduced -X only tested with one strategy option at a time.

I see one example howhever, with git cherry-pick:

D:\git\git\t>grep -E "-X.*?-X" *.sh

t3418-rebase-continue.sh: test_must_fail git rebase -i -s funny -Xopt -Xfoo master topic t3510-cherry-pick-sequence.sh: test_expect_code 128 git cherry-pick -s -m $mainline --strategy=recursive -X patience -X ours initial..anotherpick &&

See t3510-cherry-pick-sequence.sh, which uses the same strategy/options as git merge.

test_expect_code 128 git cherry-pick -s -m $mainline --strategy=recursive -X patience -X ours initial..anotherpick 
Related