Fix force-push without fetch

This commit is contained in:
Anthony Sottile 2018-07-02 09:59:23 -07:00
parent 13c85f374b
commit c294be513d
2 changed files with 28 additions and 4 deletions

View file

@ -105,6 +105,10 @@ def _exe():
)
def _rev_exists(rev):
return not subprocess.call(('git', 'rev-list', '--quiet', rev))
def _pre_push(stdin):
remote = sys.argv[1]
@ -113,7 +117,7 @@ def _pre_push(stdin):
_, local_sha, _, remote_sha = line.split()
if local_sha == Z40:
continue
elif remote_sha != Z40:
elif remote_sha != Z40 and _rev_exists(remote_sha):
opts = ('--origin', local_sha, '--source', remote_sha)
else:
# First ancestor not found in remote