From 99d65bb609233b393746f13635602db0b9d28163 Mon Sep 17 00:00:00 2001 From: John Stumpo Date: Wed, 11 Aug 2010 02:06:42 -0400 Subject: [PATCH] Make the git version checker look at packed refs if there is no loose ref. --- src/Version.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Version.py b/src/Version.py index 896779e6e..ac496c1a5 100644 --- a/src/Version.py +++ b/src/Version.py @@ -40,8 +40,15 @@ def _getTagLine(): if VFS.isdir('/gameroot/.git'): # HEAD is in the form "ref: refs/heads/master\n" headref = VFS.open('/gameroot/.git/HEAD').read()[5:].strip() - # The ref is in the form "sha1-hash\n" - headhash = VFS.open('/gameroot/.git/' + headref).read().strip() + if VFS.isfile('/gameroot/.git/' + headref): + # The ref is in the form "sha1-hash\n" + headhash = VFS.open('/gameroot/.git/' + headref).read().strip() + else: + # It's a packed ref. + for line in VFS.open('/gameroot/.git/packed-refs'): + if line.strip().endswith(headref): + headhash = line[:40] + break shortref = re.sub('^refs/(heads/)?', '', headref) return 'development (git %s %s)' % (shortref, headhash[:7])