mbox series

[v7,0/3] push: add "--[no-]force-if-includes"

Message ID 20200926114626.28823-1-shrinidhi.kaushik@gmail.com (mailing list archive)
Headers show
Series push: add "--[no-]force-if-includes" | expand

Message

Srinidhi Kaushik Sept. 26, 2020, 11:46 a.m. UTC
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 v5:
  - In the previous patch, the stopping condition for "reflog"
    iteration used the commit date of the remote ref. That has
    been changed to use the the timestamp of the latest entry
    of the remote ref's "reflog"; calls "in_merge_bases_many()"
    are batched when the number of commits collected in the list
    is more than 8.

  - Add more tests for t5533 to include scenarios where forced
    updates should be allowed for "pull --rebase" and local
    rebase operations.

  - Reword commit messages, fix typos, and update documentation
    to use "`" where necessary.

Changes since v6:
  - Compilation failed because there was an argument missing when
    calling "print_ref_status()"; it has been updated.

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   |   6 ++
 Documentation/git-push.txt      |  26 ++++-
 advice.c                        |   3 +
 advice.h                        |   2 +
 builtin/push.c                  |  27 +++++
 builtin/send-pack.c             |  12 +++
 remote-curl.c                   |  14 ++-
 remote.c                        | 185 ++++++++++++++++++++++++++++++--
 remote.h                        |  12 ++-
 send-pack.c                     |   1 +
 t/t5533-push-cas.sh             | 129 ++++++++++++++++++++++
 transport-helper.c              |  10 ++
 transport.c                     |   8 ++
 transport.h                     |  15 ++-
 15 files changed, 442 insertions(+), 17 deletions(-)

base-commit: 9bc233ae1cf19a49e51842c7959d80a675dbd1c0
--
2.28.0