From ba1a4550a02d89ed021d7c9e909fdba8e097888d Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Thu, 6 Oct 2005 10:52:52 +0100 Subject: [PATCH] Fix the caching of the HEAD value 'git pull' also updates the HEAD but StGIT did not flush the cached value causing problems with pulling. Signed-off-by: Catalin Marinas --- stgit/git.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/stgit/git.py b/stgit/git.py index c57063b..5dcb90d 100644 --- a/stgit/git.py +++ b/stgit/git.py @@ -238,9 +238,17 @@ def __set_head(val): """ 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 @@ -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 """ + # 'git pull' updates the HEAD + __clear_head_cache() + args = [repository] if refspec: args.append(refspec) -- 2.11.0