raise GitException, 'Could not update HEAD to "%s".' % val
__head = val
+ # only allow SHA1 hashes
+ assert(len(__head) == 40)
+
def __clear_head_cache():
"""Sets the __head to None so that a re-read is forced
"""
if not branch_exists(new_head):
raise GitException, 'Branch "%s" does not exist' % name
- tree_id = rev_parse(new_head + '^0')
+ tree_id = rev_parse(new_head + '^{commit}')
if tree_id != get_head():
refresh_index()
if __run('git-read-tree -u -m', [get_head(), tree_id]) != 0:
__set_head(tree_id)
-def reset(files = None, tree_id = 'HEAD'):
+def reset(files = None, tree_id = None):
"""Revert the tree changes relative to the given tree_id. It removes
any local changes
"""
+ if not tree_id:
+ tree_id = get_head()
+
checkout(files, tree_id, True)
# if the reset refers to the whole tree, switch the HEAD as well
- if tree_id and not files:
+ if not files:
__set_head(tree_id)
def pull(repository = 'origin', refspec = None):