Fix git cl format when it finds no clang-formattable files.

Currently, if git cl format does not find any clang-formattable files,
either in the path provided on the command line or in the CL as a whole,
then it applies clang-format to all changes in the CL. This CL fixes
this by changing git cl format to not clang-format when it does not find
any changed files that are clang-formattable.

Review URL: https://codereview.chromium.org/1734863002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@298971 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/git_cl.py b/git_cl.py
index 3023213..48d44f5 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -3584,35 +3584,35 @@
   # formatted. This is used to block during the presubmit.
   return_value = 0
 
-  if opts.full:
-    if clang_diff_files:
+  if clang_diff_files:
+    if opts.full:
       cmd = [clang_format_tool]
       if not opts.dry_run and not opts.diff:
         cmd.append('-i')
       stdout = RunCommand(cmd + clang_diff_files, cwd=top_dir)
       if opts.diff:
         sys.stdout.write(stdout)
-  else:
-    env = os.environ.copy()
-    env['PATH'] = str(os.path.dirname(clang_format_tool))
-    try:
-      script = clang_format.FindClangFormatScriptInChromiumTree(
-          'clang-format-diff.py')
-    except clang_format.NotFoundError, e:
-      DieWithError(e)
+    else:
+      env = os.environ.copy()
+      env['PATH'] = str(os.path.dirname(clang_format_tool))
+      try:
+        script = clang_format.FindClangFormatScriptInChromiumTree(
+            'clang-format-diff.py')
+      except clang_format.NotFoundError, e:
+        DieWithError(e)
 
-    cmd = [sys.executable, script, '-p0']
-    if not opts.dry_run and not opts.diff:
-      cmd.append('-i')
+      cmd = [sys.executable, script, '-p0']
+      if not opts.dry_run and not opts.diff:
+        cmd.append('-i')
 
-    diff_cmd = BuildGitDiffCmd('-U0', upstream_commit, clang_diff_files)
-    diff_output = RunGit(diff_cmd)
+      diff_cmd = BuildGitDiffCmd('-U0', upstream_commit, clang_diff_files)
+      diff_output = RunGit(diff_cmd)
 
-    stdout = RunCommand(cmd, stdin=diff_output, cwd=top_dir, env=env)
-    if opts.diff:
-      sys.stdout.write(stdout)
-    if opts.dry_run and len(stdout) > 0:
-      return_value = 2
+      stdout = RunCommand(cmd, stdin=diff_output, cwd=top_dir, env=env)
+      if opts.diff:
+        sys.stdout.write(stdout)
+      if opts.dry_run and len(stdout) > 0:
+        return_value = 2
 
   # Similar code to above, but using yapf on .py files rather than clang-format
   # on C/C++ files