Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSrinidhi Kaushik <shrinidhi.kaushik@gmail.com>2020-10-03 15:10:45 +0300
committerJunio C Hamano <gitster@pobox.com>2020-10-03 19:59:19 +0300
commit3b990aa645d1169b7373d12cbf1511ca4633e349 (patch)
tree392838f3dc148baa81116708924b44a3e900b778 /remote-curl.c
parent99a1f9ae10816c2527d7197a5dde714f980b712b (diff)
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 'remote-curl.c')
-rw-r--r--remote-curl.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/remote-curl.c b/remote-curl.c
index 32cc4a0c55..0290b04891 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -44,7 +44,8 @@ struct options {
from_promisor : 1,
atomic : 1,
- object_format : 1;
+ object_format : 1,
+ force_if_includes : 1;
const struct git_hash_algo *hash_algo;
};
static struct options options;
@@ -131,6 +132,14 @@ static int set_option(const char *name, const char *value)
string_list_append(&cas_options, val.buf);
strbuf_release(&val);
return 0;
+ } else if (!strcmp(name, TRANS_OPT_FORCE_IF_INCLUDES)) {
+ if (!strcmp(value, "true"))
+ options.force_if_includes = 1;
+ else if (!strcmp(value, "false"))
+ options.force_if_includes = 0;
+ else
+ return -1;
+ return 0;
} else if (!strcmp(name, "cloning")) {
if (!strcmp(value, "true"))
options.cloning = 1;
@@ -1318,6 +1327,9 @@ static int push_git(struct discovery *heads, int nr_spec, const char **specs)
strvec_push(&args, cas_option->string);
strvec_push(&args, url.buf);
+ if (options.force_if_includes)
+ strvec_push(&args, "--force-if-includes");
+
strvec_push(&args, "--stdin");
for (i = 0; i < nr_spec; i++)
packet_buf_write(&preamble, "%s\n", specs[i]);