[PATCH v4 0/3] push: add "--[no-]force-if-includes"
- From
Srinidhi Kaushik <shrinidhi.kaushik@gmail.com>
- Date
- Sep 19, 2020, 17:03 UTC
- Message-ID
- <20200919170316.5310-1-shrinidhi.kaushik@gmail.com>
- In-Reply-To
- <20200912150459.8282-1-shrinidhi.kaushik@gmail.com>
Add a new option: "--force-if-includes" to "git-push" where forced updates are allowed only if the tip of the remote-tracking ref has been integrated locally, by verifying if the tip of the remote-tracking ref -- on which a local branch has based on -- is reachable from at least one of the "reflog" entries of the branch about to be updated by force on the remote.
This option can be used with "--force-with-lease" with setups where the remote-tracking refs of the repository are implicitly updated in the background to help prevent unintended remote overwrites.
If a local branch is based on a remote ref for a rewrite, and if that remote-tracking ref is updated by a push from another repository after it has been checked out locally, force updating that branch to remote with "--force-with-lease[=<refname>[:<expect>]]" without specifying the "<expect>" value, can cause the update that happened in-between the checkout and forced push to be lost.
Changes since v3:
- Switch to the two-step approach: check the "reflog" the first
time to see if the remote ref exists; if not, go through it one
more time to see if it is reachable (using "in_merge_bases()")
from any of the entries. This is a necessary step as explained
here [1]. - Added back the configuration setting "push.useForceIfIncludes", now
that it does not affect the functionality of "--force-with-lease"
when the expected ref is specified. - Update "remote-curl" and "send-pack" to recognize the new option;
this was missing in the previous patches.- Broke up the patch-set into medium sized commits.
- Clean-up unnecessary function calls.
Srinidhi Kaushik (3): push: add reflog check for "--force-if-includes" push: parse and set flag for "--force-if-includes" t, doc: update tests, reference for "--force-if-includes"
Documentation/config/advice.txt | 9 ++- Documentation/config/push.txt | 5 ++ Documentation/git-push.txt | 20 +++++++ advice.c | 3 + advice.h | 2 + builtin/push.c | 27 +++++++++ builtin/send-pack.c | 11 ++++ remote-curl.c | 14 ++++- remote.c | 97 ++++++++++++++++++++++++++++++++- remote.h | 12 +++- send-pack.c | 1 + t/t5533-push-cas.sh | 53 ++++++++++++++++++ transport-helper.c | 11 ++++ transport.c | 8 +++ transport.h | 15 +++-- 15 files changed, 276 insertions(+), 12 deletions(-)
base-commit: 385c171a018f2747b329bcfa6be8eda1709e5abd
[1]: https://public-inbox.org/git/nycvar.QRO.7.76.6.2009161214030.56@tvgsbejvaqbjf.bet/
-- 2.28.0