Srinidhi Kaushik <shrinidhi.kaushik@xxxxxxxxx> writes: > Adds 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. s/Adds/Add/; > Introduces a new configuration option "push.useForceIfIncludes", which > is equivalent to setting "--force-if-includes" in the command line. s/Introduces/Introduce/; (I won't repeat). > > Updates "remote-curl" to recognize and pass this option to "send-pack" > when enabled. > > Updates "advise" to catch the reject reason "REJECT_REF_NEEDS_UPDATE", > which is set when the ref status is "REF_STATUS_REJECT_REMOTE_UPDATED" > and (optionally) print a help message when the push fails. All of the above say what were done. A summarizing sentence before all of the above would make the proposed commit log message perfect, perhaps: The previous step 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 ... to indicate that ... - Introduce a configuration option ... - Update 'remote-curl' to ... ... Also, in the proposed log message for [1/3], especially near its end, how "--force-if-includes" interacts with "--force-with-lease" was described. The description should be added to the log message of this change, as it is what introduces the end-user facing feature. The description can also be in the log for [1/3] as well, but not having it here for [2/3] is unfriendly to the readers. > diff --git a/builtin/send-pack.c b/builtin/send-pack.c > index 4d76727edb..9289c0eecb 100644 > --- a/builtin/send-pack.c > +++ b/builtin/send-pack.c > @@ -159,6 +159,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}; > + unsigned int force_if_includes = 0; I think OPT_BOOL takes a pointer to int, not unsigned, as it is OPT_SET_INT in disguise, and you can see that a near-by 'progress' that also is fed to OPT_BOOL() is 'int' so you can mimic it. > @@ -184,6 +185,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() > }; > diff --git a/remote.h b/remote.h > index 38ab8539e2..72c374d539 100644 > --- a/remote.h > +++ b/remote.h > @@ -350,4 +350,10 @@ int parseopt_push_cas_option(const struct option *, const char *arg, int unset); > int is_empty_cas(const struct push_cas_option *); > void apply_push_cas(struct push_cas_option *, struct remote *, struct ref *); > > +/* > + * Sets "use_force_if_includes" for "compare-and-swap" > + * when "--force-if-includes" is specified. > + */ > +void push_set_force_if_includes(struct push_cas_option *); Let's not add this helper function. Instead just open-code a single liner at its two callers. It makes it easier to read and understand the flow and the logic in cmd_push() and cmd_send_pack(). > diff --git a/transport-helper.c b/transport-helper.c > index e547e21199..2a4436dd79 100644 > --- a/transport-helper.c > +++ b/transport-helper.c > @@ -868,6 +868,12 @@ static void set_common_push_options(struct transport *transport, > if (set_helper_option(transport, TRANS_OPT_ATOMIC, "true") != 0) > die(_("helper %s does not support --atomic"), name); > > + /* If called with "--force-if-includes". */ The comment does not add any value as you are already using a descriptive constant name. Drop it to follow suit of existing if statements nearby. > + if (flags & TRANSPORT_PUSH_FORCE_IF_INCLUDES) > + if (set_helper_option(transport, TRANS_OPT_FORCE_IF_INCLUDES, "true") != 0) > + die(_("helper %s does not support --%s"), > + name, TRANS_OPT_FORCE_IF_INCLUDES); > + > if (flags & TRANSPORT_PUSH_OPTIONS) { > struct string_list_item *item; > for_each_string_list_item(item, transport->push_options) Thanks.