chiark / gitweb /
Fix the caching of the HEAD value
authorCatalin Marinas <catalin.marinas@gmail.com>
Thu, 6 Oct 2005 09:52:52 +0000 (10:52 +0100)
committerCatalin Marinas <catalin.marinas@gmail.com>
Thu, 6 Oct 2005 09:52:52 +0000 (10:52 +0100)
'git pull' also updates the HEAD but StGIT did not flush the cached value
causing problems with pulling.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
stgit/git.py

index c57063b9eacae5ed82da7a6530eeb59167d6dc0e..5dcb90db33249a80adb4d532a48f57510bb1aac5 100644 (file)
@@ -238,9 +238,17 @@ def __set_head(val):
     """
     global __head
 
     """
     global __head
 
-    __head = val
-    if __run('git-update-ref HEAD', [val]) != 0:
-        raise GitException, 'Could not update HEAD to "%s".' % val
+    if not __head or __head != val:
+        if __run('git-update-ref HEAD', [val]) != 0:
+            raise GitException, 'Could not update HEAD to "%s".' % val
+        __head = val
+
+def __clear_head_cache():
+    """Sets the __head to None so that a re-read is forced
+    """
+    global __head
+
+    __head = None
 
 def rev_parse(git_id):
     """Parse the string and return a verified SHA1 id
 
 def rev_parse(git_id):
     """Parse the string and return a verified SHA1 id
@@ -507,6 +515,9 @@ def pull(repository = 'origin', refspec = None):
     """Pull changes from the remote repository. At the moment, just
     use the 'git pull' command
     """
     """Pull changes from the remote repository. At the moment, just
     use the 'git pull' command
     """
+    # 'git pull' updates the HEAD
+    __clear_head_cache()
+
     args = [repository]
     if refspec:
         args.append(refspec)
     args = [repository]
     if refspec:
         args.append(refspec)