From 49e316b9485e69d13a10aea4b97c4a1cfe65ee70 Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Fri, 18 Nov 2005 16:13:05 +0000 Subject: [PATCH] Allow 'stg status --reset' to work on individual files It is useful to be able to only reset some files. This patch allows this. Signed-off-by: Catalin Marinas --- stgit/commands/status.py | 9 +++++++-- stgit/git.py | 12 +++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/stgit/commands/status.py b/stgit/commands/status.py index bd3edfb..b8f0623 100644 --- a/stgit/commands/status.py +++ b/stgit/commands/status.py @@ -67,8 +67,13 @@ def func(parser, options, args): """Show the tree status """ if options.reset: - resolved_all() - git.reset() + if args: + for f in args: + resolved(f) + git.reset(args) + else: + resolved_all() + git.reset() else: git.status(args, options.modified, options.new, options.deleted, options.conflict, options.unknown, options.noexclude) diff --git a/stgit/git.py b/stgit/git.py index abdd2fc..b19f75f 100644 --- a/stgit/git.py +++ b/stgit/git.py @@ -598,22 +598,24 @@ def switch(tree_id): __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 -- 2.11.0