From cc14fa9820a4c9fb7a403bbe1264856c6437bf96 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 29 Nov 2011 12:32:56 -0800 Subject: [PATCH] Improve error handling when reading loose refs When repo is trying to figure out branches the repository has by traversing refs/heads, add exception handling for readline. Change-Id: If3b2a3720c6496f52f629aa9a2539f186d6ec882 --- git_refs.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/git_refs.py b/git_refs.py index ac8ed0c1..0e3cc820 100644 --- a/git_refs.py +++ b/git_refs.py @@ -139,13 +139,15 @@ class GitRefs(object): def _ReadLoose1(self, path, name): try: fd = open(path, 'rb') - mtime = os.path.getmtime(path) - except OSError: - return - except IOError: + except: return + try: - id = fd.readline() + try: + mtime = os.path.getmtime(path) + id = fd.readline() + except: + return finally: fd.close()