{"thread":{"id":"60636","subject":"[PATCH] remote.h: retire CAS_OPT_NAME","startedAt":"2023-12-19T19:26:30Z","lastAt":"2023-12-19T19:26:30Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"485828","messageId":"xmqq5y0uc7tq.fsf@gitster.g","threadId":"60636","inReplyTo":null,"subject":"[PATCH] remote.h: retire CAS_OPT_NAME","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-12-19T19:26:25Z","receivedAt":"2023-12-19T19:26:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"When the \"--force-with-lease\" option was introduced in 28f5d176\n(remote.c: add command line option parser for \"--force-with-lease\",\n2013-07-08), the design discussion revolved around the concept of\n\"compare-and-swap\", and it can still be seen in the name used for\nvariables and helper functions.  The end-user facing option name\nended up to be a bit different, so during the development iteration\nof the feature, we used this C preprocessor macro to make it easier\nto rename it later.\n\nAll of that happened more than 10 years ago, and the flexibility\nafforded by the CAS_OPT_NAME macro outlived its usefulness.  Inline\nthe constant string for the option name, like all other option names\nin the code.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/push.c      | 4 ++--\n builtin/send-pack.c | 2 +-\n remote.h            | 2 --\n 3 files changed, 3 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/push.c b/builtin/push.c\nindex dbdf609daf..e740dd93e3 100644\n--- a/builtin/push.c\n+++ b/builtin/push.c\n@@ -393,7 +393,7 @@ static int push_with_options(struct transport *transport, struct refspec *rs,\n \tif (!is_empty_cas(&cas)) {\n \t\tif (!transport->smart_options)\n \t\t\tdie(\"underlying transport does not support --%s option\",\n-\t\t\t    CAS_OPT_NAME);\n+\t\t\t    \"force-with-lease\");\n \t\ttransport->smart_options->cas = &cas;\n \t}\n \n@@ -604,7 +604,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)\n \t\tOPT_BIT('n' , \"dry-run\", &flags, N_(\"dry run\"), TRANSPORT_PUSH_DRY_RUN),\n \t\tOPT_BIT( 0,  \"porcelain\", &flags, N_(\"machine-readable output\"), TRANSPORT_PUSH_PORCELAIN),\n \t\tOPT_BIT('f', \"force\", &flags, N_(\"force updates\"), TRANSPORT_PUSH_FORCE),\n-\t\tOPT_CALLBACK_F(0, CAS_OPT_NAME, &cas, N_(\"<refname>:<expect>\"),\n+\t\tOPT_CALLBACK_F(0, \"force-with-lease\", &cas, N_(\"<refname>:<expect>\"),\n \t\t\t       N_(\"require old value of ref to be at this value\"),\n \t\t\t       PARSE_OPT_OPTARG | PARSE_OPT_LITERAL_ARGHELP, parseopt_push_cas_option),\n \t\tOPT_BIT(0, TRANS_OPT_FORCE_IF_INCLUDES, &flags,\ndiff --git a/builtin/send-pack.c b/builtin/send-pack.c\nindex 4784143004..87e5269e9f 100644\n--- a/builtin/send-pack.c\n+++ b/builtin/send-pack.c\n@@ -207,7 +207,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOL(0, \"stateless-rpc\", &stateless_rpc, N_(\"use stateless RPC protocol\")),\n \t\tOPT_BOOL(0, \"stdin\", &from_stdin, N_(\"read refs from stdin\")),\n \t\tOPT_BOOL(0, \"helper-status\", &helper_status, N_(\"print status from remote helper\")),\n-\t\tOPT_CALLBACK_F(0, CAS_OPT_NAME, &cas, N_(\"<refname>:<expect>\"),\n+\t\tOPT_CALLBACK_F(0, \"force-with-lease\", &cas, N_(\"<refname>:<expect>\"),\n \t\t  N_(\"require old value of ref to be at this value\"),\n \t\t  PARSE_OPT_OPTARG, parseopt_push_cas_option),\n \t\tOPT_BOOL(0, TRANS_OPT_FORCE_IF_INCLUDES, &force_if_includes,\ndiff --git a/remote.h b/remote.h\nindex 73638cefeb..9ba7f7d3e2 100644\n--- a/remote.h\n+++ b/remote.h\n@@ -398,8 +398,6 @@ struct ref *get_stale_heads(struct refspec *rs, struct ref *fetch_map);\n /*\n  * Compare-and-swap\n  */\n-#define CAS_OPT_NAME \"force-with-lease\"\n-\n struct push_cas_option {\n \tunsigned use_tracking_for_rest:1;\n \tunsigned use_force_if_includes:1;\n-- \n2.43.0-121-g624eb90fa8\n\n"}]}