Ignore EOFError when reading a truncated pickle file
If the pickle config file is 0 bytes in length, we may have
crashed (or been aborted) while writing the file out to disk.
Instead of crashing with a backtrace, just treat the file as
though it wasn't present and load off a `git config` fork.
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/git_config.py b/git_config.py
index a2a739a..d33c3b1 100644
--- a/git_config.py
+++ b/git_config.py
@@ -236,6 +236,9 @@
return cPickle.load(fd)
finally:
fd.close()
+ except EOFError:
+ os.remove(self._pickle)
+ return None
except IOError:
os.remove(self._pickle)
return None