]> git.proxmox.com Git - mirror_frr.git/commitdiff
tools: enable stylechecker to handle new files
authorQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 23 Jan 2018 19:35:46 +0000 (14:35 -0500)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 23 Jan 2018 22:06:06 +0000 (17:06 -0500)
Since the tool is entirely diff based, it was having some issues diffing
things that didn't exist.

Also made it a bit smarter about ignoring kernel-specific style nits we
don't really care about.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
tools/checkpatch.sh

index adbd3c7ebd60bf7f48e01ad13cc61087639445bd..42ea8dbb3819b96efa93f7117840dfcb78432ab3 100755 (executable)
@@ -13,15 +13,18 @@ if [[ -z "$1" || -z "$2" ]]; then
   exit 0
 fi
 
+# remove temp directories
+rm -rf /tmp/f1 /tmp/f2
+
 # save working tree
 if git -C $tree status --porcelain | egrep --silent '^(\?\?|.[DM])'; then
   echo "Detected dirty tree, caching state..."
   dirty=1
   git -C $tree config gc.auto 0;
   td=$(git -C $tree status -z | grep -z "^[ARM]D" | cut -z -d' ' -f2- | tr '\0' '\n')
-  INDEX=`git -C $tree write-tree`
+  INDEX=$(git -C $tree write-tree)
   git -C $tree add -f .
-  WORKTREE=`git -C $tree write-tree`
+  WORKTREE=$(git -C $tree write-tree)
   echo "Saved index to $INDEX"
   echo "Saved working tree to $WORKTREE"
 fi
@@ -36,11 +39,14 @@ git -C $tree reset --hard
 git -C $tree apply < $patch
 mkdir -p /tmp/f1 /tmp/f2
 mod=$(git -C $tree ls-files -m | grep ".*\.[ch]" | grep -v $ignore)
+mod+=" $(git -C $tree ls-files --others --exclude-standard | grep '.*\.[ch]' | grep -v $ignore)"
+echo $mod
 if [ -z "$mod" ]; then
   echo "There doesn't seem to be any changes."
 else
   cp $tree/$mod /tmp/f1/
   git -C $tree reset --hard
+  git -C $tree clean -fd
   cp $tree/$mod /tmp/f2/
   echo "Running style checks..."
   for file in /tmp/f1/*; do
@@ -56,12 +62,11 @@ else
     echo "Report for $(basename $file _cp)"
     echo "==============================================="
     if [ -a /tmp/f2/$(basename $file) ]; then
-      diff $file /tmp/f2/$(basename $file) | grep -A3 "ERROR\|WARNING"
+      diff $file /tmp/f2/$(basename $file) | grep -v "normally be const" | grep -A3 "ERROR\|WARNING"
     else
-      cat $file
+      cat $file | grep -v "normally be const" | grep -A3 "ERROR\|WARNING"
     fi
   done
-  rm -rf /tmp/f1 /tmp/f2
 fi
 
 # restore working tree