summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2019-09-11 03:58:36 -0400
committerDavid Pursehouse <dpursehouse@collab.net>2019-09-12 04:16:51 +0000
commit9100f7fadd6cf67cb37421247c6cc3d2357b4f49 (patch)
treebaa5cbc16a34bc04eb41ca7a5bd5b89c53763e1c
parent01d6c3c0c5cfb9ccf6b60d4db78852dfbf1e3c39 (diff)
downloadgit-repo-9100f7fadd6cf67cb37421247c6cc3d2357b4f49.tar.gz
repo: decode/encode all the subprocess streams
We use subprocess a lot in the wrapper, but we don't always read or write the streams directly. When we do, make sure we convert to/from bytes before trying to use the content. Change-Id: I318bcc8e7427998348e359f60c3b49e151ffbdae Reported-by: Michael Scott <mike@foundries.io> Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/236612 Reviewed-by: Michael Scott <mike@foundries.io> Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Michael Scott <mike@foundries.io>
-rwxr-xr-xrepo11
1 files changed, 6 insertions, 5 deletions
diff --git a/repo b/repo
index e7379956..0888e44b 100755
--- a/repo
+++ b/repo
@@ -505,7 +505,7 @@ def SetupGnuPG(quiet):
505 print(file=sys.stderr) 505 print(file=sys.stderr)
506 return False 506 return False
507 507
508 proc.stdin.write(MAINTAINER_KEYS) 508 proc.stdin.write(MAINTAINER_KEYS.encode('utf-8'))
509 proc.stdin.close() 509 proc.stdin.close()
510 510
511 if proc.wait() != 0: 511 if proc.wait() != 0:
@@ -584,6 +584,7 @@ def _DownloadBundle(url, local, quiet):
584 cwd=local, 584 cwd=local,
585 stdout=subprocess.PIPE) 585 stdout=subprocess.PIPE)
586 for line in proc.stdout: 586 for line in proc.stdout:
587 line = line.decode('utf-8')
587 m = re.compile(r'^url\.(.*)\.insteadof (.*)$').match(line) 588 m = re.compile(r'^url\.(.*)\.insteadof (.*)$').match(line)
588 if m: 589 if m:
589 new_url = m.group(1) 590 new_url = m.group(1)
@@ -676,7 +677,7 @@ def _Verify(cwd, branch, quiet):
676 stdout=subprocess.PIPE, 677 stdout=subprocess.PIPE,
677 stderr=subprocess.PIPE, 678 stderr=subprocess.PIPE,
678 cwd=cwd) 679 cwd=cwd)
679 cur = proc.stdout.read().strip() 680 cur = proc.stdout.read().strip().decode('utf-8')
680 proc.stdout.close() 681 proc.stdout.close()
681 682
682 proc.stderr.read() 683 proc.stderr.read()
@@ -708,10 +709,10 @@ def _Verify(cwd, branch, quiet):
708 stderr=subprocess.PIPE, 709 stderr=subprocess.PIPE,
709 cwd=cwd, 710 cwd=cwd,
710 env=env) 711 env=env)
711 out = proc.stdout.read() 712 out = proc.stdout.read().decode('utf-8')
712 proc.stdout.close() 713 proc.stdout.close()
713 714
714 err = proc.stderr.read() 715 err = proc.stderr.read().decode('utf-8')
715 proc.stderr.close() 716 proc.stderr.close()
716 717
717 if proc.wait() != 0: 718 if proc.wait() != 0:
@@ -861,7 +862,7 @@ def _SetDefaultsTo(gitdir):
861 'HEAD'], 862 'HEAD'],
862 stdout=subprocess.PIPE, 863 stdout=subprocess.PIPE,
863 stderr=subprocess.PIPE) 864 stderr=subprocess.PIPE)
864 REPO_REV = proc.stdout.read().strip() 865 REPO_REV = proc.stdout.read().strip().decode('utf-8')
865 proc.stdout.close() 866 proc.stdout.close()
866 867
867 proc.stderr.read() 868 proc.stderr.read()