if not files:
files = []
- if rev2:
+ if rev1 and rev2:
diff_str = _output(['git-diff-tree', '-p', rev1, rev2] + files)
- else:
+ elif rev1 or rev2:
refresh_index()
- diff_str = _output(['git-diff-index', '-p', rev1] + files)
+ if rev2:
+ diff_str = _output(['git-diff-index', '-p', '-R', rev2] + files)
+ else:
+ diff_str = _output(['git-diff-index', '-p', rev1] + files)
+ else:
+ diff_str = ''
if out_fd:
out_fd.write(diff_str)
__set_head(tree_id)
-def reset(tree_id = None):
+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()
- cache_files = __tree_status(tree_id = tree_id)
+ cache_files = __tree_status(files, 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(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:
+ __set_head(tree_id)
+
def pull(repository = 'origin', refspec = None):
"""Pull changes from the remote repository. At the moment, just
use the 'git pull' command