summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2014-12-02 12:39:36 +0200
committerTzafrir Cohen <tzafrir@debian.org>2015-03-26 14:21:24 +0200
commit272113558e2bab6e6a4f4a235cbe655b1c5d066c (patch)
treecedefb15ba6ee7515ba6577945267d3ff3af0c4e
parent1e0a0392bb6c0bc739842ff2ac08da30f17b49a6 (diff)
GitRepository: implemet checkout_files() method
Makes it possible to only checkout certain files from a branch, instead of switching to the branch. Add a new method instead of extending checkout() in order to keep it consistent. That is, otherwise checkout() would have totally different outcome depending on whether paths were defined of not. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rw-r--r--gbp/git/repository.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py
index 689430f..848fd57 100644
--- a/gbp/git/repository.py
+++ b/gbp/git/repository.py
@@ -925,6 +925,19 @@ class GitRepository(object):
"""
self._git_command("checkout", ["--quiet", treeish])
+ def checkout_files(self, treeish, paths):
+ """
+ Checkout files from a treeish. Branch will not be changed.
+
+ @param treeish: the treeish from which to check out files
+ @type treeish: C{str}
+ @param paths: list of files to checkout
+ @type treeish: C{list} of C{str}
+ """
+ args = GitArgs("--quiet", treeish)
+ args.add_true(paths, '--', paths)
+ self._git_command("checkout", args.args)
+
def has_treeish(self, treeish):
"""
Check if the repository has the treeish object I{treeish}.