Make git map-branches faster

This change makes git map-branches a little bit faster by avoiding
fetching the revision list of each branch if git map-branches will not
show the tracking info anyway.

Change-Id: I47458871f904004f910aadd7d774bea5193c979e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2695393
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Antonio Sartori <antoniosartori@chromium.org>
diff --git a/git_common.py b/git_common.py
index e8b3588..4463541 100644
--- a/git_common.py
+++ b/git_common.py
@@ -1045,10 +1045,11 @@
     (branch, branch_hash, upstream_branch, tracking_status) = line.split(':')
 
     commits = None
-    base = get_or_create_merge_base(branch)
-    if base:
-      commits_list = run('rev-list', '--count', branch, '^%s' % base, '--')
-      commits = int(commits_list) or None
+    if include_tracking_status:
+      base = get_or_create_merge_base(branch)
+      if base:
+        commits_list = run('rev-list', '--count', branch, '^%s' % base, '--')
+        commits = int(commits_list) or None
 
     behind_match = re.search(r'behind (\d+)', tracking_status)
     behind = int(behind_match.group(1)) if behind_match else None