Make the untracked+ignored warning accurate

If you have too many bytes of untracked+ignored data in your repo then
gclient sync will fail, confidently telling you how many bytes of this
type you have. The problem is, it lies. It reports the level as soon as
it is exceeded, even though it has not finished totaling up the file
sizes. This change makes the reporting accurate.

I noticed this problem because "gclient sync" told me I had 1049.9 MB
of untracked data. I deleted some and it then said I had 1563.9 MB of
untracked data. Hmmm.

Bug: 376099
Change-Id: I797a4279ad666d83c4a5fbd54bdf7ddbf0e7ad84
Reviewed-on: https://chromium-review.googlesource.com/850854
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: Aaron Gable <agable@chromium.org>
diff --git a/git_common.py b/git_common.py
index 59a904b..7ce0edb 100644
--- a/git_common.py
+++ b/git_common.py
@@ -435,25 +435,25 @@
     if limit_mb > 0:
       if s.lstat == '?':
         untracked_bytes += os.stat(os.path.join(root_path, f)).st_size
-      if untracked_bytes > limit_mb * MB:
-        die("""\
-          You appear to have too much untracked+unignored data in your git
-          checkout: %.1f / %d MB.
+  if limit_mb > 0 and untracked_bytes > limit_mb * MB:
+    die("""\
+      You appear to have too much untracked+unignored data in your git
+      checkout: %.1f / %d MB.
 
-          Run `git status` to see what it is.
+      Run `git status` to see what it is.
 
-          In addition to making many git commands slower, this will prevent
-          depot_tools from freezing your in-progress changes.
+      In addition to making many git commands slower, this will prevent
+      depot_tools from freezing your in-progress changes.
 
-          You should add untracked data that you want to ignore to your repo's
-            .git/info/exclude
-          file. See `git help ignore` for the format of this file.
+      You should add untracked data that you want to ignore to your repo's
+        .git/info/exclude
+      file. See `git help ignore` for the format of this file.
 
-          If this data is indended as part of your commit, you may adjust the
-          freeze limit by running:
-            git config %s <new_limit>
-          Where <new_limit> is an integer threshold in megabytes.""",
-          untracked_bytes / (MB * 1.0), limit_mb, key)
+      If this data is indended as part of your commit, you may adjust the
+      freeze limit by running:
+        git config %s <new_limit>
+      Where <new_limit> is an integer threshold in megabytes.""",
+      untracked_bytes / (MB * 1.0), limit_mb, key)
 
   try:
     run('commit', '--no-verify', '-m', FREEZE + '.indexed')