I am using a git command to get an ID from log history and then trying to pipe into into another command. The first one works fine but everything else is not. Here is my code:
import subprocess as sb
commit_id = sb.Popen(['git', 'merge-base' ,'FETCH_HEAD', 'HEAD'], stdout=sb.PIPE)
test=commit_id.communicate()[0]
print(test)
sb.Popen(['git' , 'diff' ,'--name-status' ,test, 'HEAD'])
It prints b'0bf694cea03670b318eeef8369dc0a0e0c761b29\n' and then gives an error.
Here is the error I am getting:
fatal: ambiguous argument '0bf694cea03670b318eeef8369dc0a0e0c761b29
': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
I'm not sure where I'm going wrong
Here are the git commands I am trying to implement. They work fine from Linux command line:
git merge-base FETCH_HEAD HEAD /this returns the commit id
git diff --name-status commit_id HEAD /this returns changed files
git diff --src-prefix 'Original:' --dst-prefix 'New:' commit_id filename /this returns lines changed in files