]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/git.py
Get TZ offset from C localtime, given tm_gmtoff
[bup.git] / lib / bup / git.py
index 4825a19820f813227304131ac79374d899000fb2..2fc155f6a49ed8a81ef5b5580d7c19fa231334f4 100644 (file)
@@ -761,7 +761,7 @@ class PackWriter:
 
 
 def _git_date(date):
-    return '%d %s' % (date, time.strftime('%z', time.localtime(date)))
+    return '%d %s' % (date, utc_offset_str(date))
 
 
 def _gitenv(repo_dir = None):
@@ -872,16 +872,25 @@ def rev_parse(committish, repo_dir=None):
 
 
 def update_ref(refname, newval, oldval, repo_dir=None):
-    """Change the commit pointed to by a branch."""
+    """Update a repository reference."""
     if not oldval:
         oldval = ''
-    assert(refname.startswith('refs/heads/'))
+    assert(refname.startswith('refs/heads/') \
+           or refname.startswith('refs/tags/'))
     p = subprocess.Popen(['git', 'update-ref', refname,
                           newval.encode('hex'), oldval.encode('hex')],
                          preexec_fn = _gitenv(repo_dir))
     _git_wait('git update-ref', p)
 
 
+def delete_ref(refname):
+    """Delete a repository reference."""
+    assert(refname.startswith('refs/'))
+    p = subprocess.Popen(['git', 'update-ref', '-d', refname],
+                         preexec_fn = _gitenv())
+    _git_wait('git update-ref', p)
+
+
 def guess_repo(path=None):
     """Set the path value in the global variable "repodir".
     This makes bup look for an existing bup repository, but not fail if a