threads / discuss / 14298

About -X<option>

Subject: About -X<option>

## tl;dr

8 messages between Jul 5, 2008 and Jul 6, 2008.

replies: 7people: 4as markdown or json

Johannes Schindelin· Jul 5, 2008, 12:57 UTC · lore
Hi,

the -X<option> options are not really easy to convert to parseopt. This is only one indication that the interface can be improved.

Another one: you are more likely wanting to pass backend-_specific_ options to git-merge.

So, how about using this syntax instead?
	git pull -s recursive,theirs

i.e. strategy terms consist of the strategy name, optionally followed by a comma separated list of backend options.

Hmm?

Ciao, Dscho

Miklos Vajna· Jul 5, 2008, 13:32 UTC · re: Johannes Schindelin · lore

Re: About -X<option>

On Sat, Jul 05, 2008 at 02:57:12PM +0200, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
Show 6 quoted lines
> So, how about using this syntax instead?
> 
> 	git pull -s recursive,theirs
> 
> i.e. strategy terms consist of the strategy name, optionally followed by a 
> comma separated list of backend options.

As a user I would think that it tells git-merge to first try 'recursive' then 'theirs'.

Of course you can still say that users should read the documentation, but... ;-)

Pieter de Bie· Jul 5, 2008, 13:48 UTC · re: Miklos Vajna · lore

Re: About -X<option>

On 5 jul 2008, at 15:32, Miklos Vajna wrote:
> As a user I would think that it tells git-merge to first try  
> 'recursive'
> then 'theirs'.
>
I agree with this. Perhaps there's an easy fix: how about a colon?
	git pull -s recursive:theirs
might be more intuitive?
Junio C Hamano· Jul 5, 2008, 17:40 UTC · re: Pieter de Bie · lore

Re: About -X<option>

Pieter de Bie <frimmirf@gmail.com> writes:
Show 12 quoted lines
> On 5 jul 2008, at 15:32, Miklos Vajna wrote:
>
>> As a user I would think that it tells git-merge to first try
>> 'recursive'
>> then 'theirs'.
>>
>
> I agree with this. Perhaps there's an easy fix: how about a colon?
>
> 	git pull -s recursive:theirs
>
> might be more intuitive?
How would you do the equivalent of
	git pull -s recursive -Xsubtree="My Playpen/" -Xours
with the syntax?

Note that the current scripted "pull" and "merge" has a limitation that it does not allow $IFS in -X<option> but that is not a designed-in limitation but purely comes from a lazy implementation .

Also I do not see why -X<option> is not easy with parseopt() as Dscho claimed in the original message in this thread...

Johannes Schindelin· Jul 6, 2008, 01:44 UTC · re: Junio C Hamano · lore

Re: About -X<option>

Hi,
On Sat, 5 Jul 2008, Junio C Hamano wrote:
> Also I do not see why -X<option> is not easy with parseopt() as Dscho 
> claimed in the original message in this thread...

Isn't that obvious? -X looks like a short option, but the rest of that string does not consist of aggregated short options.

Besides, it is extremely ugly a syntax.  Just like git-log's -S thing.

Ciao, Dscho

Junio C Hamano· Jul 6, 2008, 04:57 UTC · re: Johannes Schindelin · lore

Re: About -X<option>

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> Isn't that obvious?  -X looks like a short option, but the rest of that 
> string does not consist of aggregated short options.

Ah, I see. Then the issue is not about "not easy to code" but about "not being consistent". We should care much more deeply about the latter.

We can change it to "--X<option>[=<value>]" and "-X option[=<value>]"; the topic is still young, not even documented properly IIRC, and is not scheduled for 'master' any time soon yet.

Johannes Schindelin· Jul 6, 2008, 11:28 UTC · re: Junio C Hamano · lore

Re: About -X<option>

Hi,
On Sat, 5 Jul 2008, Junio C Hamano wrote:
Show 7 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > Isn't that obvious?  -X looks like a short option, but the rest of 
> > that string does not consist of aggregated short options.
> 
> Ah, I see.  Then the issue is not about "not easy to code" but about "not
> being consistent".

I never meant to say "easy to code". I always meant "not possible with parseopt, without major -- and ugly -- surgery".

> We can change it to "--X<option>[=<value>]" and "-X option[=<value>]"; 
> the topic is still young, not even documented properly IIRC, and is not 
> scheduled for 'master' any time soon yet.

I feel that this is too limiting. You really do not want to allow passing "theirs" to git-merge, when you only ask for stratgey "resolve", right? Because the "resolve" strategy never heard about "theirs".

To be frank, the semantics of "theirs" _wants_ to treat it as a strategy; just think of

	$ git merge -s ours -Xtheirs

Besides, I sincerely doubt that anybody will find the naming of "-X" intuitive.

But let's step back a little: "theirs" is most likely something we do not want to announce, since a careful review in case of merge conflicts should be performed in that case.

So we do not want official support for it.

And there comes in an aspect of the broader plan for the second half of Miklos' project: user-defined merge backends.

By allowing users to put a script in their PATH (possibly resorting to "." just for that script), named "git-merge-<mybackend>", the following becomes possible:

	$ echo 'git merge-recursive --theirs "$@"' > ~/bin/git-merge-X
	$ chmod a+x ~/bin/git-merge-X
	$ git merge -s X

This would be even more flexible than the "-X" option, and it would properly keep "--theirs" out of our officially supported features.

If we feel like it, we could even accept a "git-merge-partially-theirs" into contrib/.

Ciao, Dscho

Junio C Hamano· Jul 6, 2008, 19:25 UTC · re: Johannes Schindelin · lore

Re: About -X<option>

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 10 quoted lines
> By allowing users to put a script in their PATH (possibly resorting to "." 
> just for that script), named "git-merge-<mybackend>", the following 
> becomes possible:
>
> 	$ echo 'git merge-recursive --theirs "$@"' > ~/bin/git-merge-X
> 	$ chmod a+x ~/bin/git-merge-X
> 	$ git merge -s X
>
> This would be even more flexible than the "-X" option, and it would 
> properly keep "--theirs" out of our officially supported features.

The above "custom backend" is fine, and would be useful for _other_ things (That's why I invented "-s" option to "git-merge" to begin with). The sad part is that it does not have much to do with a solution about -X<option> issue.

Imagine you want to enhance the recursive strategy so that the user can tweak the similarity threashold used in the rename detection. You would want to pass the equilvalent of -M<similarity> to the strategy backend through "git merge". You could use millions of such custom merge backend to do so:

	$ echo 'git merge-recursive -M2 "$@"' >~/bin/git-merge-M2
	$ echo 'git merge-recursive -M4 "$@"' >~/bin/git-merge-M4
	$ echo 'git merge-recursive -M6 "$@"' >~/bin/git-merge-M6
	$ ... millions of these ...
        $ git merge -s M09

but that's not a solution. You are kuldging around the issue by punting and by not solving it (iow "I did not have forsight to allow passing options through git-merge, and as consequence, the users are forced to have canned set of options in their backend"). You have the same issue with "-Xsubtree=git-gui/", for example.

Being able to pick strategy backend is wonderful, and being able to define new ones is also wonderful. But that is unrelated to what we are discussing here. Don't confuse the issue.

I am not married to -X<option> notation. Perhaps we can borrow the way "gcc" does this, when allowing linker and assmebler options to be passed from the command line to the backend with -Wa,<option> and -Wl,<option>.

The issue being addressed with these notation is exactly the same as what we are discussing, and we can follow the same model. The intermediary (gcc and git-merge) does not have to fully understand what the option they are passing to the backend (assembler and merge-* strategy).

← back to recent threads