diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2013-04-02 21:08:35 +0200 |
---|---|---|
committer | Johannes Berg <johannes@sipsolutions.net> | 2013-04-02 21:09:33 +0200 |
commit | a9d49afaac48dc2e7f9b7c695cc3907826bf6c25 (patch) | |
tree | d3d90062241a3e40bb143105d4fc6b38704047c9 /lib | |
parent | 615208f7215e478d5eaea0ee985ab886be980551 (diff) |
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 <rev> 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 <johannes@sipsolutions.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/git.py | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -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) |