- cache_files = __tree_status(tree_id = tree_id)
- rm_files = [x[1] for x in cache_files if x[0] in ['D']]
-
- checkout(tree_id = tree_id, force = True)
- __set_head(tree_id)
-
- # checkout doesn't remove files
- map(os.remove, rm_files)
+ # if the reset refers to the whole tree, switch the HEAD as well
+ if tree_id and not files:
+ __set_head(tree_id)