summaryrefslogtreecommitdiff
path: root/builtin/send-pack.c
diff options
context:
space:
mode:
authorLibravatar Srinidhi Kaushik <shrinidhi.kaushik@gmail.com>2020-10-03 17:40:45 +0530
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-10-03 09:59:19 -0700
commit3b990aa645d1169b7373d12cbf1511ca4633e349 (patch)
tree392838f3dc148baa81116708924b44a3e900b778 /builtin/send-pack.c
parentpush: add reflog check for "--force-if-includes" (diff)
downloadtgif-3b990aa645d1169b7373d12cbf1511ca4633e349.tar.xz
push: parse and set flag for "--force-if-includes"
The previous commit added the necessary machinery to implement the "--force-if-includes" protection, when "--force-with-lease" is used without giving exact object the remote still ought to have. Surface the feature by adding a command line option and a configuration variable to enable it. - Add a flag: "TRANSPORT_PUSH_FORCE_IF_INCLUDES" to indicate that the new option was passed from the command line of via configuration settings; update command line and configuration parsers to set the new flag accordingly. - Introduce a new configuration option "push.useForceIfIncludes", which is equivalent to setting "--force-if-includes" in the command line. - Update "remote-curl" to recognize and pass this option to "send-pack" when enabled. - Update "advise" to catch the reject reason "REJECT_REF_NEEDS_UPDATE", set when the ref status is "REF_STATUS_REJECT_REMOTE_UPDATED" and (optionally) print a help message when the push fails. - The new option is a "no-op" in the following scenarios: * When used without "--force-with-lease". * When used with "--force-with-lease", and if the expected commit on the remote side is specified as an argument. Signed-off-by: Srinidhi Kaushik <shrinidhi.kaushik@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/send-pack.c')
-rw-r--r--builtin/send-pack.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/builtin/send-pack.c b/builtin/send-pack.c
index 516cba7336..a7e01667b0 100644
--- a/builtin/send-pack.c
+++ b/builtin/send-pack.c
@@ -178,6 +178,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
int progress = -1;
int from_stdin = 0;
struct push_cas_option cas = {0};
+ int force_if_includes = 0;
struct packet_reader reader;
struct option options[] = {
@@ -203,6 +204,8 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
OPT_CALLBACK_F(0, CAS_OPT_NAME, &cas, N_("<refname>:<expect>"),
N_("require old value of ref to be at this value"),
PARSE_OPT_OPTARG, parseopt_push_cas_option),
+ OPT_BOOL(0, TRANS_OPT_FORCE_IF_INCLUDES, &force_if_includes,
+ N_("require remote updates to be integrated locally")),
OPT_END()
};
@@ -304,6 +307,9 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
if (!is_empty_cas(&cas))
apply_push_cas(&cas, remote, remote_refs);
+ if (!is_empty_cas(&cas) && force_if_includes)
+ cas.use_force_if_includes = 1;
+
set_ref_status_for_push(remote_refs, args.send_mirror,
args.force_update);