im currently working on a program, which should control a git repository through pexpect.
Simple commands like
git diff --name-status ...
WARNING: terminal is not fully functional
my_bash = pexpect.spawn('/bin/bash', cwd="/home/xxx/clone_repo/local.repo/")
my_bash.logfile = sys.stdout
my_bash.sendline(git diff --name-status branch1 branch2)
I get the following error message: WARNING: terminal is not fully functional.
That's a warning, not an error.
Can i run pexpect with a more functional terminal for example?
You could (see, e.g., https://github.com/docker/docker/issues/8631; note that it's critical that you mention details like OS and environment; I am just guessing here)—but unless you are writing tests that must behave like a human being interacting on a terminal, you should not bother. To drive Git from programs, use the parts of Git that are designed to be program-driven. Instead of
git diff, run
git diff-tree, for instance:
my_bash = pexpect.spawn('/bin/bash', cwd="/home/xxx/clone_repo/local.repo/") my_bash.logfile = sys.stdout my_bash.sendline('git diff --name-status branch1 branch2')
you can do this:
proc = subprocess.Popen(['git', 'diff-tree', '-r', '--name-status', 'branch1', 'branch2'], shell=False, cwd='/home/xxx/clone_repo/local.repo') out, err = proc.communicate() status = proc.wait()
and then work with the results from this. You get more direct control over the program, and by using
git diff-tree, which is a "plumbing command", you get output that is designed to be machine-readable. See Which are the plumbing and porcelain commands?
shell=False you also guard against a common security issue.)