summaryrefslogtreecommitdiff
path: root/maintainer_old/git-checkpatch
blob: 0a34125f4e10d4a0e1e8e0bfa8811234e38b6a3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash

ldir=/home/cmaiolino/Source/tools/maintainer
source $ldir/djwong-git

# Run the checkpatch script on every commit in the list.

if [ "$#" -gt 1 ] || [ "$1" = "--help" ]; then
	echo "Usage: $0 <commit range>" 1>&2
	exit 1
fi
commit_range="$(commit_range_from_arg "$1")" || exit 1

readarray -t commits < <(git rev-list --reverse --no-merges "${commit_range}")
if [ "${#commits[@]}" -eq 0 ]; then
	echo 'No commits?'
	exit 1
fi

debug=1
test -n "${DBG}" && debug=1
bad=0
for commit_id in "${commits[@]}"; do
	range="${commit_id}^1..${commit_id}"
	oneline="$(git log --oneline "${range}")"

	# Dump commit in full format so we get committer
	git log --format=full "${range}" | \
		awk -f "$ldir/checkpatch.awk" \
				-v "commit_id=${commit_id}" \
				-v "debug=${debug}" \
				-v "oneline=${oneline}"
	test $? -eq 0 || bad=1
done

test "${bad}" -eq 0