]> git.proxmox.com Git - mirror_frr.git/blob - tools/checkpatch.sh
da23d266a11e973c5d5aa176342d425e2bfe0539
[mirror_frr.git] / tools / checkpatch.sh
1 #!/bin/bash
2 # Check a patch for style errors.
3 # Usage:
4 # ./checkpatch.sh <patch>
5 checkpatch="./checkpatch.pl --no-tree -f"
6
7 git status | grep "working directory clean"
8 if [ $? -ne 0 ]; then
9 echo "[!] git working directory must be clean."
10 exit 1
11 fi
12
13 mkdir -p f1 f2
14 bash -c "cd .. && git apply $1 2> /dev/null"
15 mod=$(git ls-files -m .. | grep ".*\.[ch]")
16 cp $mod f1/
17 git reset --hard
18 cp $mod f2/
19 for file in f1/*; do
20 $checkpatch $file > "$file"_cp 2> /dev/null
21 done
22 for file in f2/*; do
23 $checkpatch $file > "$file"_cp 2> /dev/null
24 done
25 for file in f1/*_cp; do
26 diff $file f2/$(basename $file) | grep -A3 "ERROR\|WARNING"
27 done
28 rm -rf f1 f2