]> git.puffer.fish Git - mirror/frr.git/commitdiff
tools: improve checkpatch.sh 1756/head
authorQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 15 Feb 2018 18:37:03 +0000 (13:37 -0500)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 22 Feb 2018 17:54:42 +0000 (12:54 -0500)
* Send reports to stderr; this allows you to get just the end result by
  redirecting stderr
* Don't attempt to copy nonexistent files

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

index 3536df79a9916f8c6cb0e8248a7dc38bbff7da18..f55692096fc45159956dd3853db6611704425a77 100755 (executable)
@@ -45,10 +45,19 @@ echo $mod
 if [ -z "$mod" ]; then
   echo "There doesn't seem to be any changes."
 else
-  cp $tree/$mod /tmp/f1/
+  echo "Copying source to temp directory..."
+  for file in $mod; do
+    echo "$tree/$file --> /tmp/f1/$file"
+    cp $tree/$file /tmp/f1/
+  done
   git -C $tree reset --hard
   git -C $tree clean -fd
-  cp $tree/$mod /tmp/f2/
+  for file in $mod; do
+    if [ -f $tree/$file ]; then
+      echo "$tree/$file --> /tmp/f2/$file"
+      cp $tree/$file /tmp/f2/
+    fi
+  done
   echo "Running style checks..."
   for file in /tmp/f1/*; do
     echo "$checkpatch $file > $file _cp"
@@ -60,12 +69,12 @@ else
   done
   echo "Done."
   for file in /tmp/f1/*_cp; do
-    echo "Report for $(basename $file _cp)"
-    echo "==============================================="
+    echo "Report for $(basename $file _cp)" 1>&2
+    echo "===============================================" 1>&2
     if [ -a /tmp/f2/$(basename $file) ]; then
-      diff $file /tmp/f2/$(basename $file) | grep -v "normally be const" | grep -A3 "ERROR\|WARNING"
+      diff $file /tmp/f2/$(basename $file) | grep -v "normally be const" | grep -A3 "ERROR\|WARNING" 1>&2
     else
-      cat $file | grep -v "normally be const" | grep -A3 "ERROR\|WARNING"
+      cat $file | grep -v "normally be const" | grep -A3 "ERROR\|WARNING" 1>&2
     fi
     if [ "$?" -eq "0" ]; then
       stat=1