From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id 9C7E81FA19 for ; Mon, 14 Nov 2022 10:10:26 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="UVKTDzMB"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236503AbiKNKKG (ORCPT ); Mon, 14 Nov 2022 05:10:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236559AbiKNKJR (ORCPT ); Mon, 14 Nov 2022 05:09:17 -0500 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DA741D0D0 for ; Mon, 14 Nov 2022 02:09:03 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id s5so296312edc.12 for ; Mon, 14 Nov 2022 02:09:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EwQMu7++h86sKW91bWR+cOa+3MQv1XM6ppOlwSorUHA=; b=UVKTDzMBrAcYcklfnK7BaNgkKChNDaTwlsk0SQcqK+T30PjQfVN+FfmQaLm7hotRBM 3iVhXaAXEKkpWhsorEPaxD3n/GPJmQLkhBQ3nSX/MiOvh+JxfWw4fIRE9Xc/AvzSiqIi qHwcKo+tG/hiQGxpQa2zIaiakuQXSpqGaIsu+x2izg9RbZI6tQbmVXQwd0hRgLpVk8q5 RUAsF2hh06UWcLqEmF5lEw8KINYgAREN8MziEk8geVxUnPesv0yJluVwvlng9mloXuLg Xy7+c85hIpu1f5PYUA7nDLVP1P1dr8kQ5QuVnfnGnIiv+LOaz8jr55tdWcRHPrluw879 Vqng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EwQMu7++h86sKW91bWR+cOa+3MQv1XM6ppOlwSorUHA=; b=6GYsfhgPoTaqAGdZbhF5JRiql4or7v62JLE9aY4ikHw/IOwAHLkiCITZorGviBrh9r 5QMKdCTfbNyViSBZjArevvHT3ZOq+RexaC0qeBmFFmLNeeUfwuqYcKzqZ9fkwv0VAtQE coM12LG4/VESX9U1ZoNbVZ8Dr7tckwlhTpB57XhppBfbuHzUJiibt5ioarrwrRhSc/ku TCxU1sRDyIREVw0qvA1czsU+niHBV3X+lzrrBMxlfSJCtRQpBmfnC3SgEF5l2iVmGN+I MQmoB1PbSE/PYlucbn72+I2rHUjvYTXi0Gh9RbIW9xrbicyLikY9ghfNlEeK20OQTPPu UdjQ== X-Gm-Message-State: ANoB5pl4rEtQXmmqUhDol2SOGhT+w4S2MDkAvrucgd8Pbh/L6O4GThVG 2F4AusbI622otgaEgVmgWbF9p471AREmew== X-Google-Smtp-Source: AA0mqf5HOFHSgIxQI3ICFQXcGnUAWxpb+n5JpjG0mJMyw4PExko1d1AUspIcvqD+/z1EkQhFYHqnjg== X-Received: by 2002:a50:ccc7:0:b0:467:cc91:903b with SMTP id b7-20020a50ccc7000000b00467cc91903bmr3737656edj.130.1668420541797; Mon, 14 Nov 2022 02:09:01 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ml21-20020a170906cc1500b007828150a2f1sm4012062ejb.36.2022.11.14.02.09.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 02:09:01 -0800 (PST) From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= To: git@vger.kernel.org Cc: Glen Choo , Taylor Blau , Robert Coup , =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Subject: [PATCH v2 07/10] submodule--helper: convert "{update,clone}" to their own "--super-prefix" Date: Mon, 14 Nov 2022 11:08:47 +0100 Message-Id: X-Mailer: git-send-email 2.38.0.1471.ge4d8947e7aa In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org As with a preceding commit to convert "absorbgitdirs", we can convert "submodule--helper status" to use its own "--super-prefix", instead of relying on the global "--super-prefix" argument to "git". We need to convert both of these away from the global "--super-prefix" at the same time, because "update" will call "clone", but "clone" itself didn't make use of the global "--super-prefix" for displaying paths. It was only on the list of sub-commands that accepted it because "update"'s use of it would set it in its environment. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/submodule--helper.c | 45 ++++++++++++++++--------------------- git.c | 2 +- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 40939b0b18e..e13615eb939 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -131,13 +131,6 @@ static char *get_submodule_displaypath_sp(const char *path, const char *prefix, } } -static char *get_submodule_displaypath(const char *path, const char *prefix) -{ - const char *super_prefix = get_super_prefix(); - - return get_submodule_displaypath_sp(path, prefix, super_prefix); -} - static char *compute_rev_name(const char *sub_path, const char* object_id) { struct strbuf sb = STRBUF_INIT; @@ -446,11 +439,13 @@ static int starts_with_dot_dot_slash(const char *const path) struct init_cb { const char *prefix; + const char *super_prefix; unsigned int flags; }; #define INIT_CB_INIT { 0 } static void init_submodule(const char *path, const char *prefix, + const char *super_prefix, unsigned int flags) { const struct submodule *sub; @@ -458,7 +453,7 @@ static void init_submodule(const char *path, const char *prefix, const char *upd; char *url = NULL, *displaypath; - displaypath = get_submodule_displaypath(path, prefix); + displaypath = get_submodule_displaypath_sp(path, prefix, super_prefix); sub = submodule_from_path(the_repository, null_oid(), path); @@ -534,7 +529,8 @@ static void init_submodule_cb(const struct cache_entry *list_item, void *cb_data { struct init_cb *info = cb_data; - init_submodule(list_item->name, info->prefix, info->flags); + init_submodule(list_item->name, info->prefix, info->super_prefix, + info->flags); } static int module_init(int argc, const char **argv, const char *prefix) @@ -802,6 +798,7 @@ struct summary_cb { int argc; const char **argv; const char *prefix; + const char *super_prefix; unsigned int cached: 1; unsigned int for_status: 1; unsigned int files: 1; @@ -963,7 +960,8 @@ static void generate_submodule_summary(struct summary_cb *info, dst_abbrev = xstrndup(oid_to_hex(&p->oid_dst), 7); } - displaypath = get_submodule_displaypath(p->sm_path, info->prefix); + displaypath = get_submodule_displaypath_sp(p->sm_path, info->prefix, + info->super_prefix); if (!missing_src && !missing_dst) { struct child_process cp_rev_list = CHILD_PROCESS_INIT; @@ -1904,6 +1902,7 @@ static void submodule_update_clone_release(struct submodule_update_clone *suc) struct update_data { const char *prefix; + const char *super_prefix; char *displaypath; enum submodule_update_type update_default; struct object_id suboid; @@ -1979,7 +1978,8 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce, enum submodule_update_type update_type; char *key; const struct update_data *ud = suc->update_data; - char *displaypath = get_submodule_displaypath(ce->name, ud->prefix); + char *displaypath = get_submodule_displaypath_sp(ce->name, ud->prefix, + ud->super_prefix); struct strbuf sb = STRBUF_INIT; int needs_cloning = 0; int need_free_url = 0; @@ -2459,11 +2459,11 @@ static void update_data_to_args(const struct update_data *update_data, { enum submodule_update_type update_type = update_data->update_default; + strvec_pushl(args, "submodule--helper", "update", "--recursive", NULL); if (update_data->displaypath) { strvec_push(args, "--super-prefix"); strvec_pushf(args, "%s/", update_data->displaypath); } - strvec_pushl(args, "submodule--helper", "update", "--recursive", NULL); strvec_pushf(args, "--jobs=%d", update_data->max_jobs); if (update_data->quiet) strvec_push(args, "--quiet"); @@ -2628,8 +2628,9 @@ static int update_submodules(struct update_data *update_data) if (code) goto fail; - update_data->displaypath = get_submodule_displaypath( - update_data->sm_path, update_data->prefix); + update_data->displaypath = get_submodule_displaypath_sp( + update_data->sm_path, update_data->prefix, + update_data->super_prefix); code = update_submodule(update_data); FREE_AND_NULL(update_data->displaypath); fail: @@ -2654,7 +2655,9 @@ static int module_update(int argc, const char **argv, const char *prefix) struct list_objects_filter_options filter_options = LIST_OBJECTS_FILTER_INIT; int ret; + const char *super_prefix = NULL; struct option module_update_options[] = { + OPT__SUPER_PREFIX(&super_prefix), OPT__FORCE(&opt.force, N_("force checkout updates"), 0), OPT_BOOL(0, "init", &opt.init, N_("initialize uninitialized submodules before update")), @@ -2720,6 +2723,7 @@ static int module_update(int argc, const char **argv, const char *prefix) opt.filter_options = &filter_options; opt.prefix = prefix; + opt.super_prefix = super_prefix; if (opt.update_default) opt.update_strategy.type = opt.update_default; @@ -2751,6 +2755,7 @@ static int module_update(int argc, const char **argv, const char *prefix) module_list_active(&list); info.prefix = opt.prefix; + info.super_prefix = super_prefix; if (opt.quiet) info.flags |= OPT_QUIET; @@ -3377,8 +3382,6 @@ static int module_add(int argc, const char **argv, const char *prefix) int cmd_submodule__helper(int argc, const char **argv, const char *prefix) { - const char *cmd = argv[0]; - const char *subcmd; parse_opt_subcommand_fn *fn = NULL; const char *const usage[] = { N_("git submodule--helper "), @@ -3402,16 +3405,6 @@ int cmd_submodule__helper(int argc, const char **argv, const char *prefix) OPT_END() }; argc = parse_options(argc, argv, prefix, options, usage, 0); - subcmd = argv[0]; - - if (strcmp(subcmd, "clone") && strcmp(subcmd, "update") && - get_super_prefix()) - /* - * xstrfmt() rather than "%s %s" to keep the translated - * string identical to git.c's. - */ - die(_("%s doesn't support --super-prefix"), - xstrfmt("'%s %s'", cmd, subcmd)); return fn(argc, argv, prefix); } diff --git a/git.c b/git.c index b1b7e1a837e..2bca22cfd9a 100644 --- a/git.c +++ b/git.c @@ -610,7 +610,7 @@ static struct cmd_struct commands[] = { { "stash", cmd_stash, RUN_SETUP | NEED_WORK_TREE }, { "status", cmd_status, RUN_SETUP | NEED_WORK_TREE }, { "stripspace", cmd_stripspace }, - { "submodule--helper", cmd_submodule__helper, RUN_SETUP | SUPPORT_SUPER_PREFIX }, + { "submodule--helper", cmd_submodule__helper, RUN_SETUP }, { "switch", cmd_switch, RUN_SETUP | NEED_WORK_TREE }, { "symbolic-ref", cmd_symbolic_ref, RUN_SETUP }, { "tag", cmd_tag, RUN_SETUP | DELAY_PAGER_CONFIG }, -- 2.38.0.1471.ge4d8947e7aa