Re: linux-next: Signed-off-by missing for commits in the net-next tree

From: Stephen Rothwell
Date: Sun Dec 09 2018 - 19:48:58 EST


Hi Dave,

On Sun, 09 Dec 2018 16:31:52 -0800 (PST) David Miller <davem@xxxxxxxxxxxxx> wrote:
>
> From: Sabrina Dubroca <sd@xxxxxxxxxxxxxxx>
> Date: Mon, 10 Dec 2018 00:27:22 +0100
>
> > Maybe Stephen's script to detect those missing sign-offs could be run
> > as a commit/apply hook by David? This happens regularly, sometimes
> > dropping more than just a sign-off.
>
> Yeah, that would probably be a good idea, maybe something even on the
> git.kernel.org side that won't let me push if I'm sending commits that
> have this problem.

That is fine as a last resort, but it is probably less disruptive to
find these things before you try to push i.e. as part of the "apply the
patch" otherwise you could end up having to rebase a whole lot of later
commits.

Anyway, here's my current version of my script. It just takes a commit
range (anything you can pass to "git log"). You may want to drop the
gitk invocation at the end.

--------------------------------------------------------------------
#!/bin/bash

if [ "$#" -lt 1 ]; then
printf "Usage: %s <commit range>\n", "$0" 1>&2
exit 1
fi

commits=$(git rev-list --no-merges "$@")
if [ -z "$commits" ]; then
printf "No commits\n"
exit 0
fi

author_missing=
committer_missing=

print_commits()
{
local t="$1"

shift

s=
is='is'
its='its'
[ "$#" -gt 1 ] && {
s='s'
is='are'
its='their'
}
printf "Commit%s\n\n" "$s"
git log --no-walk --pretty='format: %h ("%s")' "$@"
printf "\n%s missing a Signed-off-by from %s %s%s.\n" "$is" "$its" "$t" "$s"
printf "\n"
}

for c in $commits; do
ae=$(git log -1 --format='<%ae>%n<%aE>%n %an %n %aN ' "$c" | sort -u)
ce=$(git log -1 --format='<%ce>%n<%cE>%n %cn %n %cN ' "$c" | sort -u)
msg=$(git log -1 --format='%b' "$c")
sob=$(echo "$msg" | sed -En 's/^\s*Signed-off-by:?\s*/ /ip')

am=false
cm=false
grep -i -F -q "$ae" <<<"$sob" ||
am=true
grep -i -F -q "$ce" <<<"$sob" ||
cm=true
"$am" && author_missing+=" $c"
"$cm" && committer_missing+=" $c"
done

if [ "$author_missing" ]; then
print_commits "author" $author_missing
fi
if [ "$committer_missing" ]; then
print_commits "committer" $committer_missing
fi

exec gitk "$@"
--------------------------------------------------------------------

--
Cheers,
Stephen Rothwell

Attachment: pgp1nHwoxcoFq.pgp
Description: OpenPGP digital signature