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

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Thu Apr 26 11:40:39 UTC 2018


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.

Regards,

Tvrtko


More information about the dim-tools mailing list