From a9d49afaac48dc2e7f9b7c695cc3907826bf6c25 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 2 Apr 2013 21:08:35 +0200 Subject: add ability to read source files from git Instead of having to have a checked-out kernel tree the script can now read the files from a git revision when passed the --git-revision argument. In this case the kerneldir is taken as the git tree to use. This helps when generating for multiple different trees. Note that due to the need to invoke git many times this is considerably slower than copying from a checkout. If taking into account the time to create the checkout it's still faster though. Signed-off-by: Johannes Berg --- lib/git.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'lib') diff --git a/lib/git.py b/lib/git.py index 50179b5d..d7d7baf6 100644 --- a/lib/git.py +++ b/lib/git.py @@ -61,3 +61,27 @@ def commit_all(message, tree=None): stdout = process.communicate()[0] process.wait() _check(process) + +def ls_tree(rev, files, tree=None): + process = subprocess.Popen(['git', 'ls-tree', '-z', '-r', rev, '--', ] + list(files), + stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + close_fds=True, universal_newlines=True, cwd=tree) + stdout = process.communicate()[0] + files = stdout.split('\0') + ret = [] + for f in files: + if not f: + continue + meta, f = f.split('\t', 1) + meta = meta.split() + meta.append(f) + ret.append(meta) + process.wait() + _check(process) + return ret + +def get_blob(blob, outf, tree=None): + process = subprocess.Popen(['git', 'show', blob], + stdout=outf, close_fds=True, cwd=tree) + process.wait() + _check(process) -- cgit v1.2.3