]>
git.proxmox.com Git - mirror_frr.git/blob - tools/checkpatch.sh
2 # Check a patch for style errors.
3 usage
="./checkpatch.sh <patch> <tree>"
6 checkpatch
="$tree/tools/checkpatch.pl --no-tree -f"
12 if [[ -z "$1" ||
-z "$2" ]]; then
17 # remove temp directories
18 rm -rf /tmp
/f1
/tmp
/f2
21 if git
-C $tree status
--porcelain |
egrep --silent '^(\?\?|.[DM])'; then
22 echo "Detected dirty tree, caching state..."
24 git
-C $tree config gc.auto
0;
25 td
=$
(git
-C $tree status
-z |
grep -z "^[ARM]D" | cut
-z -d' ' -f2- |
tr '\0' '\n')
26 INDEX
=$
(git
-C $tree write-tree
)
28 WORKTREE
=$
(git
-C $tree write-tree
)
29 echo "Saved index to $INDEX"
30 echo "Saved working tree to $WORKTREE"
34 if git
-C $tree status
--porcelain |
egrep --silent '^(\?\?|.[DM])'; then
35 echo "[!] git working directory must be clean."
39 git
-C $tree reset --hard
40 git
-C $tree apply
< $patch
41 mkdir
-p /tmp
/f1
/tmp
/f2
42 mod
=$
(git
-C $tree ls-files
-m |
grep ".*\.[ch]" |
grep -v $ignore)
43 mod
+=" $(git -C $tree ls-files --others --exclude-standard | grep '.*\.[ch]' | grep -v $ignore)"
45 if [ -z "$mod" ]; then
46 echo "There doesn't seem to be any changes."
48 cp $tree/$mod /tmp
/f
1/
49 git
-C $tree reset --hard
50 git
-C $tree clean
-fd
51 cp $tree/$mod /tmp
/f
2/
52 echo "Running style checks..."
53 for file in /tmp
/f
1/*; do
54 echo "$checkpatch $file > $file _cp"
55 $checkpatch $file > "$file"_cp
2> /dev
/null
57 for file in /tmp
/f
2/*; do
58 echo "$checkpatch $file > $file _cp"
59 $checkpatch $file > "$file"_cp
2> /dev
/null
62 for file in /tmp
/f
1/*_cp
; do
63 echo "Report for $(basename $file _cp)"
64 echo "==============================================="
65 if [ -a /tmp
/f
2/$
(basename $file) ]; then
66 diff $file /tmp
/f
2/$
(basename $file) |
grep -v "normally be const" |
grep -A3 "ERROR\|WARNING"
68 cat $file |
grep -v "normally be const" |
grep -A3 "ERROR\|WARNING"
70 if [ "$?" -eq "0" ]; then
76 # restore working tree
77 if [ $dirty -eq 1 ]; then
78 git
-C $tree read-tree
$WORKTREE;
79 git
-C $tree checkout-index
-af;
80 git
-C $tree read-tree
$INDEX;
84 git
-C $tree config
--unset gc.auto
;