X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/blobdiff_plain/fec7f6586a1c4699a1e6bf75f8bd394bed27e222..2fef9462b26126402f26140a02d3e16cdd2d9928:/stgit/git.py diff --git a/stgit/git.py b/stgit/git.py index dd7821e..016bc3a 100644 --- a/stgit/git.py +++ b/stgit/git.py @@ -274,7 +274,7 @@ def rev_parse(git_id): raise GitException, 'Unknown revision: %s' % git_id def branch_exists(branch): - """Existance check for the named branch + """Existence check for the named branch """ for line in _output_lines(['git-rev-parse', '--symbolic', '--all']): if line.strip() == branch: @@ -308,7 +308,7 @@ def switch_branch(name): 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: @@ -599,22 +599,14 @@ def switch(tree_id): __set_head(tree_id) -def reset(files = None, tree_id = None): +def reset(files = None, tree_id = 'HEAD'): """Revert the tree changes relative to the given tree_id. It removes any local changes """ - if not tree_id: - tree_id = get_head() - - cache_files = __tree_status(files, tree_id) - rm_files = [x[1] for x in cache_files if x[0] in ['D']] - checkout(files, tree_id, True) - # checkout doesn't remove files - map(os.remove, rm_files) # if the reset refers to the whole tree, switch the HEAD as well - if not files: + if tree_id and not files: __set_head(tree_id) def pull(repository = 'origin', refspec = None):