From 272113558e2bab6e6a4f4a235cbe655b1c5d066c Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Tue, 2 Dec 2014 12:39:36 +0200 Subject: 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 --- gbp/git/repository.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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}. -- cgit v1.2.3