patman: Allow setting the current directory when sending

Plumb a current-working-directory (cwd) through from send all the way to
the command gitutil libraries. This will allow better testing of this
functionality, since we can use a test directory.

Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py
index 2975881..5df06b1 100644
--- a/tools/patman/checkpatch.py
+++ b/tools/patman/checkpatch.py
@@ -187,7 +187,8 @@
     return result
 
 
-def check_patch(fname, verbose=False, show_types=False, use_tree=False):
+def check_patch(fname, verbose=False, show_types=False, use_tree=False,
+                cwd=None):
     """Run checkpatch.pl on a file and parse the results.
 
     Args:
@@ -196,6 +197,7 @@
             parsed
         show_types: Tell checkpatch to show the type (number) of each message
         use_tree (bool): If False we'll pass '--no-tree' to checkpatch.
+        cwd (str): Path to use for patch files (None to use current dir)
 
     Returns:
         namedtuple containing:
@@ -217,7 +219,8 @@
         args.append('--no-tree')
     if show_types:
         args.append('--show-types')
-    output = command.output(*args, fname, raise_on_error=False)
+    output = command.output(*args, os.path.join(cwd or '', fname),
+                            raise_on_error=False)
 
     return check_patch_parse(output, verbose)
 
@@ -240,7 +243,7 @@
     line_str = '' if line is None else '%d' % line
     return '%s:%s: %s: %s\n' % (fname, line_str, msg_type, msg)
 
-def check_patches(verbose, args, use_tree):
+def check_patches(verbose, args, use_tree, cwd):
     '''Run the checkpatch.pl script on each patch'''
     error_count, warning_count, check_count = 0, 0, 0
     col = terminal.Color()
@@ -248,7 +251,8 @@
     with concurrent.futures.ThreadPoolExecutor(max_workers=16) as executor:
         futures = []
         for fname in args:
-            f = executor.submit(check_patch, fname, verbose, use_tree=use_tree)
+            f = executor.submit(check_patch, fname, verbose, use_tree=use_tree,
+                                cwd=cwd)
             futures.append(f)
 
         for fname, f in zip(args, futures):