backports: add git diff support to lib/bpgit.py
authorLuis R. Rodriguez <mcgrof@do-not-panic.com>
Wed, 2 Apr 2014 11:38:16 +0000 (11:38 +0000)
committerLuis R. Rodriguez <mcgrof@do-not-panic.com>
Wed, 9 Apr 2014 01:16:21 +0000 (18:16 -0700)
This will be used later for proving SmPL patches against
legacy patch series.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
lib/bpgit.py

index f56e377a96429bee490a8150ca88762f48263816..f4b53c4c672ad0d70aba1a83c125eabe15a1abca 100644 (file)
@@ -328,3 +328,15 @@ def reset(opts=[], tree=None):
                                close_fds=True, universal_newlines=True, cwd=tree)
     process.wait()
     _check(process)
+
+def diff(tree=None, extra_args=None):
+    cmd = ['git', 'diff', '--color=always'] + extra_args
+
+    process = subprocess.Popen(cmd,
+                               stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
+                               close_fds=True, universal_newlines=True, cwd=tree)
+    stdout = process.communicate()[0]
+    process.wait()
+    _check(process)
+
+    return stdout