X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/blobdiff_plain/2406f7d16cad24d396b3e8ea5605813f4011b5a6..f46f4413587c2941a555aa6014c3e306bbd67fd6:/stgit/git.py diff --git a/stgit/git.py b/stgit/git.py index 2399996..907c82d 100644 --- a/stgit/git.py +++ b/stgit/git.py @@ -644,12 +644,13 @@ def checkout(files = None, tree_id = None, force = False): if __run(checkout_cmd, files) != 0: raise GitException, 'Failed git-checkout-index' -def switch(tree_id): +def switch(tree_id, keep = False): """Switch the tree to the given id """ - refresh_index() - if __run('git-read-tree -u -m', [get_head(), tree_id]) != 0: - raise GitException, 'git-read-tree failed (local changes maybe?)' + if not keep: + refresh_index() + if __run('git-read-tree -u -m', [get_head(), tree_id]) != 0: + raise GitException, 'git-read-tree failed (local changes maybe?)' __set_head(tree_id)