From: Srinidhi Kaushik Date: Sat, 12 Sep 2020 15:04:57 GMT Subject: [PATCH v2 0/2] push: make "--force-with-lease" safer Message-ID: <20200912150459.8282-1-shrinidhi.kaushik@gmail.com> In-Reply-To: <20200904185147.77439-1-shrinidhi.kaushik@gmail.com> The `--force-with-lease[=[:" and "" ref values are explicitly specified. For setups where the remote-tracking refs are implicitly updated by tools that run in the background, not specifying an "" value for force updates may result in loss of remote updates. Let's say, we have a local branch that is based on a remote ref that may be updated implicitly with a background fetch. If we decide to rewrite changes on the remote, and base our local branch on the current tip of the remote-tracking ref. If the remote ref was updated by a push from another user, and it was fetched -- right after the checkout, during rewrite or before push -- in the background, and if we decide to force update our rewritten local changes on the remote with `--force-with-lease[=]` (i.e, without specifying an "" value) to `git-push`, the remote changes pushed from another user during our rewrite may be lost. The new option `--force-if-includes` will allow forcing an update only if the tip of the remote-tracking ref has been integrated locally. Using this along with `--force-with-lease`, during the time of push can help preventing unintended remote overwrites. Srinidhi Kaushik (2): push: add "--[no-]force-if-includes" push: enable "forceIfIncludesWithLease" by default Documentation/config/advice.txt | 4 + Documentation/config/feature.txt | 6 ++ Documentation/config/push.txt | 8 ++ Documentation/git-push.txt | 22 +++++ advice.c | 3 + advice.h | 2 + builtin/push.c | 38 +++++++- builtin/send-pack.c | 13 ++- remote.c | 129 ++++++++++++++++++++++++--- remote.h | 14 ++- send-pack.c | 1 + t/t5533-push-cas.sh | 53 ++++++++++++ t/t5549-push-force-if-includes.sh | 139 ++++++++++++++++++++++++++++++ transport-helper.c | 5 ++ transport.c | 24 +++++- transport.h | 12 +-- 16 files changed, 451 insertions(+), 22 deletions(-) create mode 100755 t/t5549-push-force-if-includes.sh base-commit: 54e85e7af1ac9e9a92888060d6811ae767fea1bc -- 2.28.0