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

Tvrtko Ursulin tursulin at ursulin.net
Thu Apr 26 11:37:22 UTC 2018


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
 
-- 
2.14.1



More information about the dim-tools mailing list