Skip to content

Commit a762af3

Browse files
committed
remote.h: retire CAS_OPT_NAME
When the "--force-with-lease" option was introduced in 28f5d17 (remote.c: add command line option parser for "--force-with-lease", 2013-07-08), the design discussion revolved around the concept of "compare-and-swap", and it can still be seen in the name used for variables and helper functions. The end-user facing option name ended up to be a bit different, so during the development iteration of the feature, we used this C preprocessor macro to make it easier to rename it later. All of that happened more than 10 years ago, and the flexibility afforded by the CAS_OPT_NAME macro outlived its usefulness. Inline the constant string for the option name, like all other option names in the code. Signed-off-by: Junio C Hamano <[email protected]>
1 parent fb7d80e commit a762af3

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

builtin/push.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ static int push_with_options(struct transport *transport, struct refspec *rs,
393393
if (!is_empty_cas(&cas)) {
394394
if (!transport->smart_options)
395395
die("underlying transport does not support --%s option",
396-
CAS_OPT_NAME);
396+
"force-with-lease");
397397
transport->smart_options->cas = &cas;
398398
}
399399

@@ -604,7 +604,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
604604
OPT_BIT('n' , "dry-run", &flags, N_("dry run"), TRANSPORT_PUSH_DRY_RUN),
605605
OPT_BIT( 0, "porcelain", &flags, N_("machine-readable output"), TRANSPORT_PUSH_PORCELAIN),
606606
OPT_BIT('f', "force", &flags, N_("force updates"), TRANSPORT_PUSH_FORCE),
607-
OPT_CALLBACK_F(0, CAS_OPT_NAME, &cas, N_("<refname>:<expect>"),
607+
OPT_CALLBACK_F(0, "force-with-lease", &cas, N_("<refname>:<expect>"),
608608
N_("require old value of ref to be at this value"),
609609
PARSE_OPT_OPTARG | PARSE_OPT_LITERAL_ARGHELP, parseopt_push_cas_option),
610610
OPT_BIT(0, TRANS_OPT_FORCE_IF_INCLUDES, &flags,

builtin/send-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
207207
OPT_BOOL(0, "stateless-rpc", &stateless_rpc, N_("use stateless RPC protocol")),
208208
OPT_BOOL(0, "stdin", &from_stdin, N_("read refs from stdin")),
209209
OPT_BOOL(0, "helper-status", &helper_status, N_("print status from remote helper")),
210-
OPT_CALLBACK_F(0, CAS_OPT_NAME, &cas, N_("<refname>:<expect>"),
210+
OPT_CALLBACK_F(0, "force-with-lease", &cas, N_("<refname>:<expect>"),
211211
N_("require old value of ref to be at this value"),
212212
PARSE_OPT_OPTARG, parseopt_push_cas_option),
213213
OPT_BOOL(0, TRANS_OPT_FORCE_IF_INCLUDES, &force_if_includes,

remote.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,6 @@ struct ref *get_stale_heads(struct refspec *rs, struct ref *fetch_map);
398398
/*
399399
* Compare-and-swap
400400
*/
401-
#define CAS_OPT_NAME "force-with-lease"
402-
403401
struct push_cas_option {
404402
unsigned use_tracking_for_rest:1;
405403
unsigned use_force_if_includes:1;

0 commit comments

Comments
 (0)