Skip to contentSkip to conversation

git interpret-trailers with multiple keys

DISCUSSION Michael S. Tsirkin 4 participants 12 messages Jun 16, 2016

lore
Share & tools
lore

Michael S. Tsirkin

author Reviewed-by Reviewed-by
#0 lore raw

I have this in .git/config

[trailer "r"]
key = Reviewed-by
command = "echo \"Michael S. Tsirkin <[email protected]\""
[trailer "s"]
key = Signed-off-by
command = "echo \"Michael S. Tsirkin <[email protected]\""

whenever I run git interpret-trailers -t r I see these lines added:

Why is Reviewed-by repeated? Bug or feature?

Signature · 1 line
MST
Reviewed-by Michael S. Tsirkin
#1 lore raw
Quoted 9 lines · Michael S. Tsirkin

I have this in .git/config

[trailer "r"]
key = Reviewed-by
command = "echo \"Michael S. Tsirkin <[email protected]\""
[trailer "s"]
key = Signed-off-by
command = "echo \"Michael S. Tsirkin <[email protected]\""

Quoted 7 lines

whenever I run git interpret-trailers -t r I see these lines added:

Why is Reviewed-by repeated? Bug or feature?

The first two lines are added unconditionally:

$ echo | git interpret-trailers 

The last line is added because you've asked for it with --trailer r.

I don't think it's currently possible to get the behavior you seem to expect, ie. to define trailer tokens fully (key and value) in your config file but use them only on request.

(BTW, I think you wanted a closing > at the end)

Signature · 2 lines
Matthieu Moy
http://www-verimag.imag.fr/~moy/
#2 lore raw
Quoted 26 lines · Matthieu Moy
Quoted 9 lines · Michael S. Tsirkin

I have this in .git/config

[trailer "r"]
key = Reviewed-by
command = "echo \"Michael S. Tsirkin <[email protected]\""
[trailer "s"]
key = Signed-off-by
command = "echo \"Michael S. Tsirkin <[email protected]\""

Quoted 7 lines

whenever I run git interpret-trailers -t r I see these lines added:

Why is Reviewed-by repeated? Bug or feature?

The first two lines are added unconditionally:

$ echo | git interpret-trailers 
Quoted 7 lines

The last line is added because you've asked for it with --trailer r.

I don't think it's currently possible to get the behavior you seem to expect, ie. to define trailer tokens fully (key and value) in your config file but use them only on request.

(BTW, I think you wanted a closing > at the end)

Is this worth fixing? It doesn't look like a behaviour anyone would want...

Quoted 3 lines
Signature · 2 lines
Matthieu Moy
http://www-verimag.imag.fr/~moy/
#3 lore raw
Quoted 29 lines · Michael S. Tsirkin
Quoted 28 lines · Matthieu Moy
Quoted 9 lines · Michael S. Tsirkin

I have this in .git/config

[trailer "r"]
key = Reviewed-by
command = "echo \"Michael S. Tsirkin <[email protected]\""
[trailer "s"]
key = Signed-off-by
command = "echo \"Michael S. Tsirkin <[email protected]\""

Quoted 7 lines

whenever I run git interpret-trailers -t r I see these lines added:

Why is Reviewed-by repeated? Bug or feature?

The first two lines are added unconditionally:

$ echo | git interpret-trailers 

The last line is added because you've asked for it with --trailer r.

Quoted 8 lines
Quoted 5 lines

I don't think it's currently possible to get the behavior you seem to expect, ie. to define trailer tokens fully (key and value) in your config file but use them only on request.

(BTW, I think you wanted a closing > at the end)

Is this worth fixing? It doesn't look like a behaviour anyone would want...

CC'ing Christian who's done the "trailers" thing.

Personally, I do not think adding any configured trailers without being asked is a sensible behaviour, but it is likely that people already depend on it, as we seem to see "How do I configure to always add this and that trailer?" from time to time. I do not think it is unreasonable to disable the "automatically add everything that is configured" when the command line arguments ask for some specific trailer, but I haven't thought deeply about it.

An additional (uninformed) observation is that the 'echo' looks like an ugly workaround for the lack of "always use this string as the value" configuration. Perhaps next to trailer.<token>.command, we would need trailer.<token>.value?

#4 lore raw
Quoted 50 lines · Junio C Hamano
Quoted 29 lines · Michael S. Tsirkin
Quoted 28 lines · Matthieu Moy
Quoted 9 lines · Michael S. Tsirkin

I have this in .git/config

[trailer "r"]
key = Reviewed-by
command = "echo \"Michael S. Tsirkin <[email protected]\""
[trailer "s"]
key = Signed-off-by
command = "echo \"Michael S. Tsirkin <[email protected]\""

Quoted 7 lines

whenever I run git interpret-trailers -t r I see these lines added:

Why is Reviewed-by repeated? Bug or feature?

The first two lines are added unconditionally:

$ echo | git interpret-trailers 

The last line is added because you've asked for it with --trailer r.

Quoted 8 lines
Quoted 5 lines

I don't think it's currently possible to get the behavior you seem to expect, ie. to define trailer tokens fully (key and value) in your config file but use them only on request.

(BTW, I think you wanted a closing > at the end)

Is this worth fixing? It doesn't look like a behaviour anyone would want...

CC'ing Christian who's done the "trailers" thing.

Personally, I do not think adding any configured trailers without being asked is a sensible behaviour, but it is likely that people already depend on it, as we seem to see "How do I configure to always add this and that trailer?" from time to time. I do not think it is unreasonable to disable the "automatically add everything that is configured" when the command line arguments ask for some specific trailer, but I haven't thought deeply about it.

Quoted 3 lines

An additional (uninformed) observation is that the 'echo' looks like an ugly workaround for the lack of "always use this string as the value" configuration.

Or at least a default.

Quoted 2 lines

Perhaps next to trailer.<token>.command, we
would need trailer.<token>.value?

Signature · 1 line
MST
#5 lore raw
Quoted 23 lines · Michael S. Tsirkin
Quoted 22 lines · Junio C Hamano
Quoted 20 lines · Michael S. Tsirkin
Quoted 19 lines · Matthieu Moy
Quoted 16 lines · Michael S. Tsirkin

I have this in .git/config

[trailer "r"]
key = Reviewed-by
command = "echo \"Michael S. Tsirkin <[email protected]\""
[trailer "s"]
key = Signed-off-by
command = "echo \"Michael S. Tsirkin <[email protected]\""

whenever I run git interpret-trailers -t r I see these lines added:

Why is Reviewed-by repeated? Bug or feature?

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

The first two lines are added unconditionally:

$ echo | git interpret-trailers

The last line is added because you've asked for it with --trailer r.

Yes, and because the default is to add the trailer at the end.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

I don't think it's currently possible to get the behavior you seem to expect, ie. to define trailer tokens fully (key and value) in your config file but use them only on request.

Yes, because you could define for example a function like this:

reviewed() {
    git interpret-trailers --trailer 'Reviewed-by: Michael S. Tsirkin

<[email protected]>' --in-place "$@"
}

So it is kind of easy already to make things requestable.

If people really want some configured trailers to be used only on request, it is possible to add a config option for that.

Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
Quoted 1 line

(BTW, I think you wanted a closing > at the end)

Is this worth fixing? It doesn't look like a behaviour anyone would want...

CC'ing Christian who's done the "trailers" thing.

Personally, I do not think adding any configured trailers without being asked is a sensible behaviour, but it is likely that people already depend on it, as we seem to see "How do I configure to always add this and that trailer?" from time to time. I do not think it is unreasonable to disable the "automatically add everything that is configured" when the command line arguments ask for some specific trailer, but I haven't thought deeply about it.

Quoted 8 lines
Quoted 3 lines

An additional (uninformed) observation is that the 'echo' looks like an ugly workaround for the lack of "always use this string as the value" configuration.

Or at least a default.

Quoted 2 lines

Perhaps next to trailer.<token>.command, we
would need trailer.<token>.value?

Yeah, that is possible too.
It could be bit redundant if we already have a config option to say if the trailer has to be requested.

#6 lore raw
Quoted 39 lines · Christian Couder
Quoted 23 lines · Michael S. Tsirkin
Quoted 22 lines · Junio C Hamano
Quoted 20 lines · Michael S. Tsirkin
Quoted 19 lines · Matthieu Moy
Quoted 16 lines · Michael S. Tsirkin

I have this in .git/config

[trailer "r"]
key = Reviewed-by
command = "echo \"Michael S. Tsirkin <[email protected]\""
[trailer "s"]
key = Signed-off-by
command = "echo \"Michael S. Tsirkin <[email protected]\""

whenever I run git interpret-trailers -t r I see these lines added:

Why is Reviewed-by repeated? Bug or feature?

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

The first two lines are added unconditionally:

$ echo | git interpret-trailers

The last line is added because you've asked for it with --trailer r.

Yes, and because the default is to add the trailer at the end.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

I don't think it's currently possible to get the behavior you seem to expect, ie. to define trailer tokens fully (key and value) in your config file but use them only on request.

Quoted 8 lines

Yes, because you could define for example a function like this:

reviewed() {
    git interpret-trailers --trailer 'Reviewed-by: Michael S. Tsirkin

<[email protected]>' --in-place "$@"
}

So it is kind of easy already to make things requestable.

Not if any commands are configured. interpret-trailers will insist on running them in any case.

Quoted 2 lines

If people really want some configured trailers to be used only on request, it is possible to add a config option for that.

this is not what the documentation says though:

If some <token>=<value> arguments are also passed on the
command line, when a trailer.<token>.command is configured, the
command will also be executed for each of these arguments.
And the <value> part of these arguments, if any, will be used to
replace the $ARG string in the command.

so it says command *for a given token* is run.

I would say that if people really want to run all trailers while also passing some on command line, *that* should be a config option. Current default violates the principle of least surprise.

Quoted 19 lines
Quoted 19 lines
Quoted 18 lines
Quoted 4 lines
Quoted 1 line

(BTW, I think you wanted a closing > at the end)

Is this worth fixing? It doesn't look like a behaviour anyone would want...

CC'ing Christian who's done the "trailers" thing.

Personally, I do not think adding any configured trailers without being asked is a sensible behaviour, but it is likely that people already depend on it, as we seem to see "How do I configure to always add this and that trailer?" from time to time. I do not think it is unreasonable to disable the "automatically add everything that is configured" when the command line arguments ask for some specific trailer, but I haven't thought deeply about it.

An additional (uninformed) observation is that the 'echo' looks like an ugly workaround for the lack of "always use this string as the value" configuration.

Quoted 8 lines
Quoted 4 lines

Or at least a default.

Quoted 2 lines

Perhaps next to trailer.<token>.command, we
would need trailer.<token>.value?

Yeah, that is possible too.
It could be bit redundant if we already have a config option to say if the trailer has to be requested.

Seems unrelated - if one just wants a string, using echo as a command is inefficient and inconvenient.

Signature · 1 line
MST
#7 lore raw
Quoted 47 lines · Michael S. Tsirkin
Quoted 46 lines · Christian Couder
Quoted 23 lines · Michael S. Tsirkin
Quoted 22 lines · Junio C Hamano
Quoted 20 lines · Michael S. Tsirkin
Quoted 19 lines · Matthieu Moy
Quoted 16 lines · Michael S. Tsirkin

I have this in .git/config

[trailer "r"]
key = Reviewed-by
command = "echo \"Michael S. Tsirkin <[email protected]\""
[trailer "s"]
key = Signed-off-by
command = "echo \"Michael S. Tsirkin <[email protected]\""

whenever I run git interpret-trailers -t r I see these lines added:

Why is Reviewed-by repeated? Bug or feature?

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

The first two lines are added unconditionally:

$ echo | git interpret-trailers

The last line is added because you've asked for it with --trailer r.

Yes, and because the default is to add the trailer at the end.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

I don't think it's currently possible to get the behavior you seem to expect, ie. to define trailer tokens fully (key and value) in your config file but use them only on request.

Yes, because you could define for example a function like this:

reviewed() {
    git interpret-trailers --trailer 'Reviewed-by: Michael S. Tsirkin

<[email protected]>' --in-place "$@"
}

Quoted 4 lines
Quoted 1 line

So it is kind of easy already to make things requestable.

Not if any commands are configured. interpret-trailers will insist on running them in any case.

If one want something requestable instead of automatic, one should definitely not configure any command.

Quoted 4 lines
Quoted 2 lines

If people really want some configured trailers to be used only on request, it is possible to add a config option for that.

this is not what the documentation says though:

What I meant is that we could create new options called maybe trailer.autocommands and trailer.<token>.autocommands that default to 'true' and if 'false' the command would not be run automatically and the corresponding trailer would not be added.

Quoted 3 lines

I would say that if people really want to run all trailers while also passing some on command line, *that* should be a config option. Current default violates the principle of least surprise.

Current default is documented and is the most powerful default. Yes, it might be surprising though.

Quoted 24 lines
Quoted 24 lines
Quoted 23 lines
Quoted 15 lines
Quoted 4 lines
Quoted 1 line

(BTW, I think you wanted a closing > at the end)

Is this worth fixing? It doesn't look like a behaviour anyone would want...

CC'ing Christian who's done the "trailers" thing.

Personally, I do not think adding any configured trailers without being asked is a sensible behaviour, but it is likely that people already depend on it, as we seem to see "How do I configure to always add this and that trailer?" from time to time. I do not think it is unreasonable to disable the "automatically add everything that is configured" when the command line arguments ask for some specific trailer, but I haven't thought deeply about it.

Quoted 3 lines

An additional (uninformed) observation is that the 'echo' looks like an ugly workaround for the lack of "always use this string as the value" configuration.

Or at least a default.

Quoted 2 lines

Perhaps next to trailer.<token>.command, we
would need trailer.<token>.value?

Quoted 6 lines
Quoted 3 lines

Yeah, that is possible too.
It could be bit redundant if we already have a config option to say if the trailer has to be requested.

Seems unrelated - if one just wants a string, using echo as a command is inefficient and inconvenient.

Efficiency is not very high in the list for this kind of things. Also when these features were developed, many people wanted different powerful things and many people said they could help develop them though very few did help. So if you think trailer.<token>.value is really needed you are welcome to develop it.

Thanks,
Christian.

#8 lore raw
Quoted 48 lines · Christian Couder
Quoted 47 lines · Michael S. Tsirkin
Quoted 46 lines · Christian Couder
Quoted 23 lines · Michael S. Tsirkin
Quoted 22 lines · Junio C Hamano
Quoted 20 lines · Michael S. Tsirkin
Quoted 19 lines · Matthieu Moy
Quoted 16 lines · Michael S. Tsirkin

I have this in .git/config

[trailer "r"]
key = Reviewed-by
command = "echo \"Michael S. Tsirkin <[email protected]\""
[trailer "s"]
key = Signed-off-by
command = "echo \"Michael S. Tsirkin <[email protected]\""

whenever I run git interpret-trailers -t r I see these lines added:

Why is Reviewed-by repeated? Bug or feature?

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

The first two lines are added unconditionally:

$ echo | git interpret-trailers

The last line is added because you've asked for it with --trailer r.

Yes, and because the default is to add the trailer at the end.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

I don't think it's currently possible to get the behavior you seem to expect, ie. to define trailer tokens fully (key and value) in your config file but use them only on request.

Yes, because you could define for example a function like this:

reviewed() {
    git interpret-trailers --trailer 'Reviewed-by: Michael S. Tsirkin

<[email protected]>' --in-place "$@"
}

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

So it is kind of easy already to make things requestable.

Not if any commands are configured. interpret-trailers will insist on running them in any case.

If one want something requestable instead of automatic, one should definitely not configure any command.

Then one can't set any values, only keys.

Quoted 10 lines
Quoted 4 lines
Quoted 2 lines

If people really want some configured trailers to be used only on request, it is possible to add a config option for that.

this is not what the documentation says though:

What I meant is that we could create new options called maybe trailer.autocommands and trailer.<token>.autocommands that default to 'true' and if 'false' the command would not be run automatically and the corresponding trailer would not be added.

Quoted 5 lines
Quoted 3 lines

I would say that if people really want to run all trailers while also passing some on command line, *that* should be a config option. Current default violates the principle of least surprise.

Current default is documented and is the most powerful default.

I'm not sure what makes you say that. What makes it the most powerful?

Quoted 40 lines

Yes, it might be surprising though.

Quoted 24 lines
Quoted 24 lines
Quoted 23 lines
Quoted 15 lines
Quoted 4 lines
Quoted 1 line

(BTW, I think you wanted a closing > at the end)

Is this worth fixing? It doesn't look like a behaviour anyone would want...

CC'ing Christian who's done the "trailers" thing.

Personally, I do not think adding any configured trailers without being asked is a sensible behaviour, but it is likely that people already depend on it, as we seem to see "How do I configure to always add this and that trailer?" from time to time. I do not think it is unreasonable to disable the "automatically add everything that is configured" when the command line arguments ask for some specific trailer, but I haven't thought deeply about it.

Quoted 3 lines

An additional (uninformed) observation is that the 'echo' looks like an ugly workaround for the lack of "always use this string as the value" configuration.

Or at least a default.

Quoted 2 lines

Perhaps next to trailer.<token>.command, we
would need trailer.<token>.value?

Quoted 6 lines
Quoted 3 lines

Yeah, that is possible too.
It could be bit redundant if we already have a config option to say if the trailer has to be requested.

Seems unrelated - if one just wants a string, using echo as a command is inefficient and inconvenient.

Efficiency is not very high in the list for this kind of things. Also when these features were developed, many people wanted different powerful things and many people said they could help develop them though very few did help. So if you think trailer.<token>.value is really needed you are welcome to develop it.

Thanks,
Christian.

#9 lore raw
In reply to Christian Couder
Quoted 4 lines · Christian Couder

What I meant is that we could create new options called maybe trailer.autocommands and trailer.<token>.autocommands that default to 'true' and if 'false' the command would not be run automatically and the corresponding trailer would not be added.

I don't think it has to do with commands.
For example, if we add "value" it should behave the same.

So I think a better name is "ifnotlisted", with values "add" and "donothing".

Thoughts?

Signature · 1 line
MST
#10 lore raw
Quoted 11 lines · Michael S. Tsirkin
Quoted 4 lines · Christian Couder

What I meant is that we could create new options called maybe trailer.autocommands and trailer.<token>.autocommands that default to 'true' and if 'false' the command would not be run automatically and the corresponding trailer would not be added.

I don't think it has to do with commands.
For example, if we add "value" it should behave the same.

So I think a better name is "ifnotlisted", with values "add" and "donothing".

Having a negation in the variable name feels wrong. When the token is listed on the command-line and ifnotlisted=donothing, I have to apply a double-negation to guess what would happen (=> "if listed then do something").

I agree that having such variable would be a good thing. It would solve your issue (i.e. "How to I configure a token for quick use from the command-line without applying it unconditionally"), and allow full backward compatibility.

I'd call the option "apply" or perhaps "run", with values 1/true/always = default = current behavior, or "auto" = "apply when asked from the command-line". I'm wondering whether other values could make sense (not to implement it right now, but to keep the design open to further extensions): perhaps apply=ifauthor could mean "apply this trailer to patches I'm the author of" for example.

Signature · 2 lines
Matthieu Moy
http://www-verimag.imag.fr/~moy/
#11 lore raw
Quoted 11 lines · Matthieu Moy
Quoted 9 lines · Michael S. Tsirkin
Quoted 4 lines · Christian Couder

What I meant is that we could create new options called maybe trailer.autocommands and trailer.<token>.autocommands that default to 'true' and if 'false' the command would not be run automatically and the corresponding trailer would not be added.

I don't think it has to do with commands.
For example, if we add "value" it should behave the same.

Quoted 7 lines
Quoted 2 lines

So I think a better name is "ifnotlisted", with values "add" and "donothing".

Having a negation in the variable name feels wrong. When the token is listed on the command-line and ifnotlisted=donothing, I have to apply a double-negation to guess what would happen (=> "if listed then do something").

Isn't this similar to ifmissing?

Quoted 15 lines

I agree that having such variable would be a good thing. It would solve your issue (i.e. "How to I configure a token for quick use from the command-line without applying it unconditionally"), and allow full backward compatibility.

I'd call the option "apply" or perhaps "run", with values 1/true/always = default = current behavior, or "auto" = "apply when asked from the command-line". I'm wondering whether other values could make sense (not to implement it right now, but to keep the design open to further extensions): perhaps apply=ifauthor could mean "apply this trailer to patches I'm the author of" for example.

Signature · 2 lines
Matthieu Moy
http://www-verimag.imag.fr/~moy/