From dc8db675da269827b8a4a70dfba8ad822c1a945d Mon Sep 17 00:00:00 2001 From: Uri Baghin Date: Sun, 29 Sep 2019 00:57:10 +1000 Subject: [PATCH] Parse rejected deletes. --- git/remote.py | 5 ++++- git/test/test_remote.py | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/git/remote.py b/git/remote.py index 4f32540f0..8b1c588d4 100644 --- a/git/remote.py +++ b/git/remote.py @@ -156,7 +156,10 @@ def _from_line(cls, remote, line): if flags & cls.DELETED: from_ref = None else: - from_ref = Reference.from_path(remote.repo, from_ref_string) + if from_ref_string == "(delete)": + from_ref = None + else: + from_ref = Reference.from_path(remote.repo, from_ref_string) # commit handling, could be message or commit info old_commit = None diff --git a/git/test/test_remote.py b/git/test/test_remote.py index e87b60dff..77e3ffbfd 100644 --- a/git/test/test_remote.py +++ b/git/test/test_remote.py @@ -385,6 +385,14 @@ def _assert_push_and_pull(self, remote, rw_repo, remote_repo): progress.make_assertion() self._do_test_push_result(res, remote) + # rejected stale delete + force_with_lease = "%s:0000000000000000000000000000000000000000" % new_head.path + res = remote.push(":%s" % new_head.path, force_with_lease=force_with_lease) + self.assertTrue(res[0].flags & PushInfo.ERROR) + self.assertTrue(res[0].flags & PushInfo.REJECTED) + self.assertIsNone(res[0].local_ref) + self._do_test_push_result(res, remote) + # delete new branch on the remote end and locally res = remote.push(":%s" % new_head.path) self._do_test_push_result(res, remote)