format-code: add '--no-diff' option

When running on uncommitted content, it is helpful to avoid the
output `git diff` since it is known that this will fail.  Add the
option so that users can run the script and format their whole
repository even on uncommitted content.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Iea6c8c35eb99ab0598085e0c9cfb1edff29c7690
diff --git a/scripts/format-code.sh b/scripts/format-code.sh
index 7cd070e..2132317 100755
--- a/scripts/format-code.sh
+++ b/scripts/format-code.sh
@@ -10,22 +10,28 @@
 #
 function display_help()
 {
-    echo "usage: format-code.sh [-h | --help] "
+    echo "usage: format-code.sh [-h | --help] [--no-diff]"
     echo "                      [<path>]"
     echo
     echo "Format and lint a repository."
     echo
     echo "Arguments:"
+    echo "    --no-diff      Don't show final diff output"
     echo "    path           Path to git repository (default to pwd)"
 }
 
-eval set -- "$(getopt -o 'h' --long 'help' -n 'format-code.sh' -- "$@")"
+eval set -- "$(getopt -o 'h' --long 'help,no-diff' -n 'format-code.sh' -- "$@")"
 while true; do
     case "$1" in
         '-h'|'--help')
             display_help && exit 0
             ;;
 
+        '--no-diff')
+            OPTION_NO_DIFF=1
+            shift
+            ;;
+
         '--')
             shift
             break
@@ -227,17 +233,21 @@
     "do_$op"
 done
 
-echo -e "    ${BLUE}Result differences...${NORMAL}"
-if ! git --no-pager diff --exit-code ; then
-    echo -e "Format: ${RED}FAILED${NORMAL}"
-    exit 1
-else
-    echo -e "Format: ${GREEN}PASSED${NORMAL}"
+if [ -z "$OPTION_NO_DIFF" ]; then
+    echo -e "    ${BLUE}Result differences...${NORMAL}"
+    if ! git --no-pager diff --exit-code ; then
+        echo -e "Format: ${RED}FAILED${NORMAL}"
+        exit 1
+    else
+        echo -e "Format: ${GREEN}PASSED${NORMAL}"
+    fi
 fi
 
 # Sometimes your situation is terrible enough that you need the flexibility.
 # For example, phosphor-mboxd.
 if [[ -f "format-code.sh" ]]; then
     ./format-code.sh
-    git --no-pager diff --exit-code
+    if [ -z "$OPTION_NO_DIFF" ]; then
+        git --no-pager diff --exit-code
+    fi
 fi