[PATCH] dim: Check whether committer is the author more thoroughly

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Thu Sep 27 10:38:03 UTC 2018


Forgot about this old patch/thread...

On 26/04/2018 12:58, Daniel Vetter wrote:
> On Thu, Apr 26, 2018 at 1:40 PM, Tvrtko Ursulin
> <tvrtko.ursulin at linux.intel.com> wrote:
>> On 26/04/2018 12:37, Tvrtko Ursulin wrote:
>>>
>>> From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
>>>
>>> For patch authors and committers with multiple email addresses, it is good
>>> to check all 'From:' lines before deciding to add a Signed-off-by line.
>>> This prevents adding duplicate S-o-B's in those cases.
>>>
>>> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
>>> ---
>>>    dim | 21 +++++++++++++++++----
>>>    1 file changed, 17 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/dim b/dim
>>> index 091dff8518ed..b587a4d1bccf 100755
>>> --- a/dim
>>> +++ b/dim
>>> @@ -824,6 +824,22 @@ function dim_push
>>>          dim_push_branch $(git_current_branch) "$@"
>>>    }
>>>    +function is_own_patch
>>> +{
>>> +       patch="$1"
>>> +       committer_email="$2"
>>> +
>>> +       grep "From:" $patch | while read patch_from; do
>>> +               [[ "$patch_from" == *"$committer_email"* ]] && exit 99
>>> +       done
>>> +
>>> +       if [ $? -eq 99 ]; then
>>> +               return 0
>>> +       else
>>> +               return 1
>>> +       fi
>>> +}
>>> +
>>>    function apply_patch #patch_file
>>>    {
>>>          local patch message_id committer_email patch_from sob rv
>>> @@ -833,10 +849,7 @@ function apply_patch #patch_file
>>>          message_id=$(message_get_id $patch)
>>>          committer_email=$(git_committer_email)
>>>    -     patch_from=$(grep "From:" "$patch" | head -1)
>>> -       if [[ "$patch_from" != *"$committer_email"* ]] ; then
>>> -               sob=-s
>>> -       fi
>>> +       is_own_patch "$patch" "$committer_email" || sob=-s
>>>          git am --scissors -3 $sob "$@" $patch
>>>
>>
>>
>> Alternatively (and much simpler) we could grep for the actual S-o-B tag with
>> committer's email? Or there was a reason we started with 'From:' grepping,
>> can't remember.
> 
> Accident of history most likely, but in other places we do check the
> git author vs. the git committer, and require that both put their sob
> on the patch (e.g. in dim push).
> 
> While it's still an mbox From: == git author.
> 
> So this might work, but not sure you can push it without again upsetting dim.
> 
> I also find the multiple sob I occasionally put on my patches amusing :-)

... but I still carry this locally.

Is it a viable extension/improvement for dim? How would it upset it?

Btw I am not completely happy with the exit 99 trick but don't have 
enough bash skills to come up with a better way.

Regards,

Tvrtko


More information about the dim-tools mailing list