Fixing cell-build to apply patch only if necessary.

Change-Id: I08dcb74d2e421e4fe12c015b5afba1bf282896be
diff --git a/tools/dev/bin/cell-build b/tools/dev/bin/cell-build
index 3e35eb7..ac6e510 100755
--- a/tools/dev/bin/cell-build
+++ b/tools/dev/bin/cell-build
@@ -19,21 +19,20 @@
     source ~/.bash_aliases
     cd \$ONOS_ROOT
 
-    # Make sure the remote build machine is on the same commit hash as the local one
-    remoteCommit=\$(git log -n 1 | head -n1 | cut -d\  -f2)
-
     # Clean-up the workspace and stash away any changes.
     git clean -f
     git stash
 
+    # Make sure the remote build machine is on the same commit hash as the local one
+    remoteCommit=\$(git log -n 1 | head -n1 | cut -d\  -f2)
     if [ "\$remoteCommit" != "$baseCommit" ]; then
         git checkout master
         git pull
         git checkout $baseCommit
     fi
 
-    # Apply the patch
-    git apply /tmp/$baseCommit.patch
+    # Apply the patch if necessary
+    [ -s /tmp/$baseCommit.patch ] && git apply /tmp/$baseCommit.patch
 
     # Run the build (neutralizing known environment mutations in SSH sessions)
     SHLVL=1 SSH_CLIENT=0 SSH_CONNECTION=0 bazel build onos