The following command runs as expected in the shell:
git log --since=yesterday.midnight --before=today.midnight --format= --name-status
When translated into the following python code however it fails:
git = subprocess.Popen(['git', 'log', '--since=yesterday.midnight', '--before=today.midnight', '--format= --name-status'], stdout=subprocess.PIPE)
Error:
fatal: invalid --pretty format: --name-status
The closest answer I can find to this is regarding solving a problem on Windows (I'm on a Mac) here: How to use subprocess when multiple arguments contain spaces?
From the above answer I tried the following variations of quoting but none of them worked:
git = subprocess.Popen(['git', 'log', '--since=yesterday.midnight', '--before=today.midnight', '"--format= --name-status"'], stdout=subprocess.PIPE)
fatal: ambiguous argument '"--format= --name-status"': unknown revision or path not in the working tree.
git = subprocess.Popen(['git', 'log', '--since=yesterday.midnight', '--before=today.midnight', '--format=" --name-status"'], stdout=subprocess.PIPE)
fatal: invalid --pretty format: " --name-status"
git = subprocess.Popen(['git', 'log', '--since=yesterday.midnight', '--before=today.midnight', '--format= "--name-status"'], stdout=subprocess.PIPE)
fatal: invalid --pretty format: "--name-status"
Using "" instead of "" in the same positions as above resulted in the exact same errors as above.
My underlying need is to generate list of all files added and modified yesterday.
I just learned the subprocess syntax a couple days ago so there may also be a better way to go about this. My script runs the command then calls git.stdout.read().splitlines() to produce a list for follow-on manipulation and partitioning of the results.
Appreciate any help, thanks.