3

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.

user001
  • 1,850
  • 4
  • 27
  • 42

1 Answers1

3

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 
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for pointing out the fact that varying syntax is used for provision of multiple `-X` options to different git subcommands. – user001 Jun 28 '19 at 07:09
  • 2
    @user001 I have found *one* example of *multiple* strategy options used: see my edited answer. – VonC Jun 28 '19 at 07:15
  • Thanks for the update -- looks like it may be possible to use multiple without overriding. Is it obvious to you what is causing that cherry-pick command to exit with status 128, which seems to indicate an unexpected error (https://stackoverflow.com/a/8059956/873757)? – user001 Jun 28 '19 at 10:29
  • 1
    @user001 Not sure. I have seen it in case of invalid file descriptor (https://stackoverflow.com/a/18939111/6309) Or a way to avoid -1: https://stackoverflow.com/a/52902804/6309. Or as way to signal an invalid value: https://stackoverflow.com/a/42797658/6309 – VonC Jun 28 '19 at 12:11