Im trying to use some git commands in python through subprocess, currently I've got this command
git branch -r --merged | grep -v HEAD | xargs -L1 git --no-pager log --pretty=tformat:'%Cgreen%d%Creset %Cblue%ar%Creset' -1
which is giving me back this error b'fatal: malformed object name |\n'
I know why the error is there but im not entirely sure what I can replace the pipe in the git command with, any suggestions would be helpful and appreciated.
Tester code:
import subprocess
def cmd(command):
p = subprocess.Popen(command.split(" "), stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
out, err = p.communicate()
return out.decode("utf-8"), err
def test():
a = "git branch -r --merged | grep -v HEAD | xargs -L1 git --no-pager log --pretty=tformat:'%Cgreen%d%Creset %Cblue%ar%Creset' -1"
t, r = cmd(a)
print(t, r)