gclient: Reset the fetch config also when --force is passed.

The update_scripts step doesn't set '--reset'
Additionally, if there was no fetch config, don't fail trying to unset it.

Tbr: agable@chromium.org
No-Try: True
Bug: 862547
Change-Id: I90886ca7d1dd20ae59b378a5998de47dc67c60f9
Reviewed-on: https://chromium-review.googlesource.com/1137693
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
diff --git a/git_cache.py b/git_cache.py
index 16b49cb..6554da8 100755
--- a/git_cache.py
+++ b/git_cache.py
@@ -316,7 +316,13 @@
       cwd = self.mirror_path
 
     if reset_fetch_config:
-      self.RunGit(['config', '--unset-all', 'remote.origin.fetch'], cwd=cwd)
+      try:
+        self.RunGit(['config', '--unset-all', 'remote.origin.fetch'], cwd=cwd)
+      except subprocess.CalledProcessError as e:
+        # If exit code was 5, it means we attempted to unset a config that
+        # didn't exist. Ignore it.
+        if e.returncode != 5:
+          raise
 
     # Don't run git-gc in a daemon.  Bad things can happen if it gets killed.
     try: