Skip to content

Instantly share code, notes, and snippets.

@gerasiov
Created November 16, 2017 10:05
Show Gist options
  • Save gerasiov/bfc52b593e4ab36b1e7247c678ba2c43 to your computer and use it in GitHub Desktop.
Save gerasiov/bfc52b593e4ab36b1e7247c678ba2c43 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import sys
import subprocess
parents = filter(lambda p: p!='-p', sys.stdin.readline().split() )
output = []
for parent in parents:
result=subprocess.check_output(["git", "rev-list", parent] + map(lambda p: "^%s"%p, filter(lambda p: p != parent, parents)))
if result:
output.append(parent)
if len(output) == 0 and len(parents) != 0:
output.append(parents[0])
print(" ".join(map(lambda p: "-p %s"%p, output)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment