From patchwork Thu Feb 10 09:28:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12741597 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA6FFC433F5 for ; Thu, 10 Feb 2022 09:28:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238522AbiBJJ2x (ORCPT ); Thu, 10 Feb 2022 04:28:53 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237964AbiBJJ2t (ORCPT ); Thu, 10 Feb 2022 04:28:49 -0500 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8AEBD95 for ; Thu, 10 Feb 2022 01:28:50 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id iy10-20020a17090b16ca00b001b8a7ed5b2cso5800143pjb.7 for ; Thu, 10 Feb 2022 01:28:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc:content-transfer-encoding; bh=CB41Hx9KQblKQQyGOHxaQcsrTVonFagZUhdzStudoQs=; b=FhZo3LOxdYdDZ5zDafUm5VvtLg816sVE1lD2di+nbpf1qa9T4s3VFt7IGDD83a6Hcz 53LE6kW+zbHnq3DeJcd2JC0V8G7cbaY1zuRtoh7O3lgsdvsRNJdCbElhCe6/r+UxuHHt 80RaQqv5aoZaBgbgWey1uBZX8cF1Uw8evQERAwkGL4hM+xGUkkuw2eLSe3P2fRtCGM0I Txl63hi547eTWR28Lm4TaFpKePt6ld4SdlIxKFHTkX9Quks1ZUT4DdnSXn2V05klqhIf BpUqw3SBqZkXOkF95DTK9V42nYp/k2oN9M3ql26eLyQujn0ewS5m3OS92kcAB+uaJC0F OcXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=CB41Hx9KQblKQQyGOHxaQcsrTVonFagZUhdzStudoQs=; b=U/m43t8q/Khf1eXVCo2FhflcX3X0UU3LjpNFC/oLbUttZl021cGFE0TcTVoFDU5ms9 SbZzjb8r6VpKminKMCzvYKU/uLwpUpkMDPGlRfwYxtWBY5vYJ76038twtI1gIE5piVhE Le8Oo0wG+9jhUpic2LGso5FYVPamUmJPYOZ3XfTuhEqot42oam0PKOmsE3pp14k4WdTE 8JSUNzw8bwnEpgFE8zJMHlZUSiahscEB3fSL9yFd4GnbPX4s9VdInWEw9ummRHHdRCoG C3e0Fme+mUplOVxBUhW0OJrrShJXBWhM2Cl+x13LotABJ1dWmV1G8823A3K6uPYU1V1q Kbwg== X-Gm-Message-State: AOAM530UGl7XiDkCOcvQTzyNll0Beky4O6eKBjuskviLnTAbmmy6ckge orpwMHwY0lfWe8/lf2ebihjr2wechvzCOgKHadG6eaHel8mTxB7jcdXme3Vau1hXwu2n8SdpHh0 gvDe60iD0KztVjeefKXDb1qgYmyiAd/Wh/9TWg1VYl8WbfNsm+ngfNfJKPfA9Y00= X-Google-Smtp-Source: ABdhPJxffx9g93mKZQZ1Lc93kLCMXaYsDQ8Saw39X7GpG8mxFo72Xnbe7o4FtrNSUWEsnXlQ2Fm5DCcZjst5vA== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a65:564f:: with SMTP id m15mr5398076pgs.368.1644485330012; Thu, 10 Feb 2022 01:28:50 -0800 (PST) Date: Thu, 10 Feb 2022 17:28:14 +0800 In-Reply-To: <20220210092833.55360-1-chooglen@google.com> Message-Id: <20220210092833.55360-2-chooglen@google.com> Mime-Version: 1.0 References: <20220208083952.35036-1-chooglen@google.com> <20220210092833.55360-1-chooglen@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH v7 01/20] submodule--helper: get remote names from any repository From: Glen Choo To: git@vger.kernel.org Cc: Glen Choo , Junio C Hamano , Atharva Raykar , Christian Couder , Emily Shaffer , Jonathan Nieder , Kaartic Sivaraam , pc44800@gmail.com, Shourya Shukla , " =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= " Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Atharva Raykar `get_default_remote()` retrieves the name of a remote by resolving the refs from of the current repository's ref store. Thus in order to use it for retrieving the remote name of a submodule, we have to start a new subprocess which runs from the submodule directory. Let's instead introduce a function called `repo_get_default_remote()` which takes any repository object and retrieves the remote accordingly. `get_default_remote()` is then defined as a call to `repo_get_default_remote()` with 'the_repository' passed to it. Now that we have `repo_get_default_remote()`, we no longer have to start a subprocess that called `submodule--helper get-default-remote` from within the submodule directory. So let's make a function called `get_default_remote_submodule()` which takes a submodule path, and returns the default remote for that submodule, all within the same process. We can now use this function to save an unnecessary subprocess spawn in `sync_submodule()`, and also in the next patch, which will require this functionality. Mentored-by: Christian Couder Mentored-by: Shourya Shukla Helped-by: Glen Choo Signed-off-by: Atharva Raykar Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- builtin/submodule--helper.c | 39 +++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index c5d3fc3817..4c7c1e1432 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -29,11 +29,14 @@ typedef void (*each_submodule_fn)(const struct cache_entry *list_item, void *cb_data); -static char *get_default_remote(void) +static char *repo_get_default_remote(struct repository *repo) { char *dest = NULL, *ret; struct strbuf sb = STRBUF_INIT; - const char *refname = resolve_ref_unsafe("HEAD", 0, NULL, NULL); + struct ref_store *store = get_main_ref_store(repo); + int ignore_errno; + const char *refname = refs_resolve_ref_unsafe(store, "HEAD", 0, NULL, + NULL, &ignore_errno); if (!refname) die(_("No such ref: %s"), "HEAD"); @@ -46,7 +49,7 @@ static char *get_default_remote(void) die(_("Expecting a full ref name, got %s"), refname); strbuf_addf(&sb, "branch.%s.remote", refname); - if (git_config_get_string(sb.buf, &dest)) + if (repo_config_get_string(repo, sb.buf, &dest)) ret = xstrdup("origin"); else ret = dest; @@ -55,6 +58,19 @@ static char *get_default_remote(void) return ret; } +static char *get_default_remote_submodule(const char *module_path) +{ + struct repository subrepo; + + repo_submodule_init(&subrepo, the_repository, module_path, null_oid()); + return repo_get_default_remote(&subrepo); +} + +static char *get_default_remote(void) +{ + return repo_get_default_remote(the_repository); +} + static int print_default_remote(int argc, const char **argv, const char *prefix) { char *remote; @@ -1341,9 +1357,8 @@ static void sync_submodule(const char *path, const char *prefix, { const struct submodule *sub; char *remote_key = NULL; - char *sub_origin_url, *super_config_url, *displaypath; + char *sub_origin_url, *super_config_url, *displaypath, *default_remote; struct strbuf sb = STRBUF_INIT; - struct child_process cp = CHILD_PROCESS_INIT; char *sub_config_path = NULL; if (!is_submodule_active(the_repository, path)) @@ -1382,21 +1397,15 @@ static void sync_submodule(const char *path, const char *prefix, if (!is_submodule_populated_gently(path, NULL)) goto cleanup; - prepare_submodule_repo_env(&cp.env_array); - cp.git_cmd = 1; - cp.dir = path; - strvec_pushl(&cp.args, "submodule--helper", - "print-default-remote", NULL); - strbuf_reset(&sb); - if (capture_command(&cp, &sb, 0)) + default_remote = get_default_remote_submodule(path); + if (!default_remote) die(_("failed to get the default remote for submodule '%s'"), path); - strbuf_strip_suffix(&sb, "\n"); - remote_key = xstrfmt("remote.%s.url", sb.buf); + remote_key = xstrfmt("remote.%s.url", default_remote); + free(default_remote); - strbuf_reset(&sb); submodule_to_gitdir(&sb, path); strbuf_addstr(&sb, "/config"); From patchwork Thu Feb 10 09:28:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12741598 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F86CC433EF for ; Thu, 10 Feb 2022 09:28:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238528AbiBJJ2z (ORCPT ); Thu, 10 Feb 2022 04:28:55 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238520AbiBJJ2v (ORCPT ); Thu, 10 Feb 2022 04:28:51 -0500 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C182B1089 for ; Thu, 10 Feb 2022 01:28:52 -0800 (PST) Received: by mail-pf1-x449.google.com with SMTP id t24-20020aa79398000000b004e025989ac7so3947672pfe.18 for ; Thu, 10 Feb 2022 01:28:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc:content-transfer-encoding; bh=sPmqUnovKFAKLuQYhu1Sg3pAOs7Z4qVb4uilqbLBvJ8=; b=K+QKzzZZU2VBcuahZCqqbpiwqKT9qjOrVEFyBDFiR9KSWqnWAUtKvLUmmIoLZwZnJm dI36vzZn2xTXcjOGizcKpOFABkakvyspHJjf+pb7lLTsuMFAvcJncSBYjRZUQ5VQ5MVa wxMQtOgIMDFJ9Sg9MP/o4rwVuvTg+bDqmYfaM1GI21tCIR2TWwDZ/thamE4EeyWA0c9U qZqY75fLELft6BLVi3YRqiAUT2zTZaSd0HRdoMr3o3WZnWp7kMA8krQqUt3krWgAgFYr LXCNzMvb3xiwgdk4rLBn7h8gm/iPCLp2GD+CLcmKD8KoF7y8Z4hJIr+TsF4blCu9C3p3 /afQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=sPmqUnovKFAKLuQYhu1Sg3pAOs7Z4qVb4uilqbLBvJ8=; b=CamAUnK+K1SK9fRtxrst6ZHUGDRHYtQMsshFr1KeGFJ2AKwXmjfYn7/pGUhpnnItym DQSiR4R3beHQAP/Ve4onP5W8/7172g71MIRw+lYou0gz3eoNrYVOgawfeCj1B0RF0XDU bpGSNrZALDmNe8UZuPdmne+bVlm2q9NaEu82jAIcLhaHiA/yUPtwb1wA2a1mfqS6rosG wNkU7voycMbgC0+YN6nuJdNOIh5U/lVN2bP324Dbpm4xcPUDshgDJVCJzXk0PKnjTT8n RRf8YGwczPoNANqz1l3zbLek7I7JNG4Jd5GqknPvWzWJ0ojMT+fBc+37boCFVVRejbrv MWdQ== X-Gm-Message-State: AOAM530/Mmv5IKBBPwRr6HbukazM8ToQ+9b53v+1T1dql6CPxNF2UvlA 3c56V1OzGUe/p7E7uKrynk01Ur7ERHS5W9YAARSYUAybW7XyKsqo3zkNc53gyxr3+BEJ3hbhLcr U4T5BkheREij0Fm+mgrGKYvkmT/q3lY9Zlhns6G8UG4eClbQzu0nwELCpkhcDxBM= X-Google-Smtp-Source: ABdhPJzijBL/fc/Er3m1Wr4jKosD7DYBoRz/bp5PEIPXzGQoL2xhLm4ZKZw5V+DWcByrjh6wAPSlJREwAxkZ0Q== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:aa7:8018:: with SMTP id j24mr6544788pfi.59.1644485332215; Thu, 10 Feb 2022 01:28:52 -0800 (PST) Date: Thu, 10 Feb 2022 17:28:15 +0800 In-Reply-To: <20220210092833.55360-1-chooglen@google.com> Message-Id: <20220210092833.55360-3-chooglen@google.com> Mime-Version: 1.0 References: <20220208083952.35036-1-chooglen@google.com> <20220210092833.55360-1-chooglen@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH v7 02/20] submodule--helper: refactor get_submodule_displaypath() From: Glen Choo To: git@vger.kernel.org Cc: Glen Choo , Junio C Hamano , Atharva Raykar , Christian Couder , Emily Shaffer , Jonathan Nieder , Kaartic Sivaraam , pc44800@gmail.com, Shourya Shukla , " =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= " Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Atharva Raykar We create a function called `do_get_submodule_displaypath()` that generates the display path required by several submodule functions, and takes a custom superprefix parameter, instead of reading it from the environment. We then redefine the existing `get_submodule_displaypath()` function as a call to this new function, where the superprefix is obtained from the environment. Mentored-by: Christian Couder Mentored-by: Shourya Shukla Signed-off-by: Atharva Raykar Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- builtin/submodule--helper.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 4c7c1e1432..5efceb9d46 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -261,11 +261,8 @@ static int resolve_relative_url_test(int argc, const char **argv, const char *pr return 0; } -/* the result should be freed by the caller. */ -static char *get_submodule_displaypath(const char *path, const char *prefix) +static char *do_get_submodule_displaypath(const char *path, const char *prefix, const char *super_prefix) { - const char *super_prefix = get_super_prefix(); - if (prefix && super_prefix) { BUG("cannot have prefix '%s' and superprefix '%s'", prefix, super_prefix); @@ -281,6 +278,13 @@ static char *get_submodule_displaypath(const char *path, const char *prefix) } } +/* the result should be freed by the caller. */ +static char *get_submodule_displaypath(const char *path, const char *prefix) +{ + const char *super_prefix = get_super_prefix(); + return do_get_submodule_displaypath(path, prefix, super_prefix); +} + static char *compute_rev_name(const char *sub_path, const char* object_id) { struct strbuf sb = STRBUF_INIT; From patchwork Thu Feb 10 09:28:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12741599 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80E99C433F5 for ; Thu, 10 Feb 2022 09:28:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238535AbiBJJ2z (ORCPT ); Thu, 10 Feb 2022 04:28:55 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238516AbiBJJ2x (ORCPT ); Thu, 10 Feb 2022 04:28:53 -0500 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1440BD95 for ; Thu, 10 Feb 2022 01:28:55 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id z12-20020a17090a1fcc00b001b63e477f9fso3562096pjz.3 for ; Thu, 10 Feb 2022 01:28:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc:content-transfer-encoding; bh=d5OdSxOJpSIJ8Imz8Plwa6pJa7oLeJV7xRwU926Etao=; b=V1tyAzdPkHIDoMqtjfESXGklX4nmMlnKZilnXmirRRT1m6fWpEEF2IeWw74FZeVdon +ySsmrDcxRsdJSgMG5dFesn5cnGxTTWylweMY6r4zHrybMUErBaYodu2j/9oTab0VT/+ AZvDdRs/MqF4hdZ1LD6aouWO+SEU0nGcMsd/j1rwmQaACIa7MLT0UwPtx3lGOfUVPq3/ QSOZymB6AByR27yBAXzzsOxOI0fk62bnGHcBHNgs97S4Eg9RXaHCWlgLXq4qlLiabax0 4g9iYD40ppsQhFe+UQ/PJax88ERscufRlnCCftCfo3wAdpxrNiKLnc4UUCSMDGDwJGYw AjJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=d5OdSxOJpSIJ8Imz8Plwa6pJa7oLeJV7xRwU926Etao=; b=CNxsbh1P+pBukl4dD4/Ti66vnaFmena/mXKYBmX9bJNT3PSvF5QCROn/PtdQqLFVYs ErHcqwz2TBg4agfWKMb+Z2Itm/X/Ypei8o50klX50s7K/0f/+iLSpC2UnI9Nz8APdhxE IxciXmnhTds+xr5GJV/+2yGWjsDKgpxOy7L3G1ojKO86Ugz0bNQDva3hs7kK+bVn+J4N YdAXNCtHVEA4bB+kFydjf5fJ6YM1nwgfY3JAE6wOUyesZ43OcQqRlrzi9jRYJ1T9Ivnj T25OCdFXxuv5Ua+ZZPQlZKB6S7KzDofZb4xxQy7C7qNIAkGsNTObmMV7YeYEPl7XO3yp JaaA== X-Gm-Message-State: AOAM533k2OSOM7iDyHCUfEYoLvRC3lG2VSr/Bw52gruuJ0nMk2juMqnY tPCUaEVhtPMZ+etOTalcFplhf0LGMjQX8JkDO8AfOo+rfwGbkzeqKG8kPz4kx/LNBxhGB+rOz5t +O4HhkG7Gl4cJ/2O2fPeXdZYE/vn15OuCvTGINEiIqtVQ2p4ZjGr/XVxn+8Mcav0= X-Google-Smtp-Source: ABdhPJwsQWl26Xaf0eoRg43T22iSSnycrFIqyp3D+ycEnoq31YSMI1J+zID9baT1LPz1oNI6ytfi4IoDaZM97w== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a05:6a00:1d9f:: with SMTP id z31mr6433395pfw.38.1644485334390; Thu, 10 Feb 2022 01:28:54 -0800 (PST) Date: Thu, 10 Feb 2022 17:28:16 +0800 In-Reply-To: <20220210092833.55360-1-chooglen@google.com> Message-Id: <20220210092833.55360-4-chooglen@google.com> Mime-Version: 1.0 References: <20220208083952.35036-1-chooglen@google.com> <20220210092833.55360-1-chooglen@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH v7 03/20] submodule--helper: allow setting superprefix for init_submodule() From: Glen Choo To: git@vger.kernel.org Cc: Glen Choo , Junio C Hamano , Atharva Raykar , Christian Couder , Emily Shaffer , Jonathan Nieder , Kaartic Sivaraam , pc44800@gmail.com, Shourya Shukla , " =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= " Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Atharva Raykar We allow callers of the `init_submodule()` function to optionally override the superprefix from the environment. We need to enable this option because in our conversion of the update command that will follow, the '--init' option will be handled through this API. We will need to change the superprefix at that time to ensure the display paths show correctly in the output messages. Mentored-by: Christian Couder Mentored-by: Shourya Shukla Signed-off-by: Atharva Raykar Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- builtin/submodule--helper.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 5efceb9d46..09cda67c1e 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -606,18 +606,22 @@ static int module_foreach(int argc, const char **argv, const char *prefix) struct init_cb { const char *prefix; + const char *superprefix; unsigned int flags; }; #define INIT_CB_INIT { 0 } static void init_submodule(const char *path, const char *prefix, - unsigned int flags) + const char *superprefix, unsigned int flags) { const struct submodule *sub; struct strbuf sb = STRBUF_INIT; char *upd = NULL, *url = NULL, *displaypath; - displaypath = get_submodule_displaypath(path, prefix); + /* try superprefix from the environment, if it is not passed explicitly */ + if (!superprefix) + superprefix = get_super_prefix(); + displaypath = do_get_submodule_displaypath(path, prefix, superprefix); sub = submodule_from_path(the_repository, null_oid(), path); @@ -691,7 +695,7 @@ static void init_submodule(const char *path, const char *prefix, 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->superprefix, info->flags); } static int module_init(int argc, const char **argv, const char *prefix) From patchwork Thu Feb 10 09:28:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12741600 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAC75C433F5 for ; Thu, 10 Feb 2022 09:29:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238516AbiBJJ25 (ORCPT ); Thu, 10 Feb 2022 04:28:57 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238531AbiBJJ2z (ORCPT ); Thu, 10 Feb 2022 04:28:55 -0500 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1801F10B2 for ; Thu, 10 Feb 2022 01:28:57 -0800 (PST) Received: by mail-pf1-x449.google.com with SMTP id z144-20020a627e96000000b004e057a71cf5so2971088pfc.21 for ; Thu, 10 Feb 2022 01:28:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc:content-transfer-encoding; bh=1q5oLNtDReJ7p0+YX28Bu8psSH2hz+Z8tqtHbnD/3Rs=; b=i7X3v+eWhFCq70yj5diBqXk8uluc04X8836ruTfmGQL1ME8caGV3xsEKx5vyznEQG5 P3RQttYun4soRMYCeSDLWeWcdXUedQRnNK0Yla3g77rtikbfeSVdWL45a/Kus69ETOJ6 dOt7UunOQLFDgKvkxF+4Fl175usplW/hDpZFa7iByojY0bPoD+RbcukGCqOKXH3FsXE/ M6vU098j9UVSqoXlYHvpOV2A2qfOAuFAxntvKidXalse6GRcZ2q0sUHftPaxZk4dsZje U1AK9xm+L8GgkdsETct7c+sjtKU0dQ62dz/PftGaOiTiScyysDoMIeNkT9NaOu1E082n A10w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=1q5oLNtDReJ7p0+YX28Bu8psSH2hz+Z8tqtHbnD/3Rs=; b=4FBLAGl682jAoZvKqV3mIisJJdXnGIjDeLCv0PYRkHkGlY0mgC4hnkaQsq0cVkZhT6 6jsomu5r7Y2mGirLhE0IAzgo3kOKsiXKNOzH+1nvNOdymxBv0JHmb6x9cPaCCjofAJMn O7iIrjZmJI1Mn2uj7skiT/flV9YebXZd2JyxIGRxCzTrzyLf8HtDWJWRugMP4hw6H9Xg Uagl85Dd8I46zy5x+/F+4ikG2qvEib0YoAmp9CT+lgYyIL+pP/5VOb7qUk6KCuKxuoyw Sk+74QkYlL+y7T6ecMiV7NuvcX4MoHI924r0qnWnoB4R6NsUPQ5IdtOOyn0cPJcuW97R SRDA== X-Gm-Message-State: AOAM533sMm5XxUsWuYKvSyYSu/MdvWijZDXIeV9q1hhRa60h2BhNJyhB kgazskgPNgvtzOA7Fhgp/U8GfIfir1hdMYxJ1r9IuurCAyvsz7SRpOz7+zIL42lD8WwO1R68iUN t1goq4ugzTCciHiXaxwXLd5IkXlXhBEYG8fXtG8lPuhNCiq046NUUbU51bBA2HOA= X-Google-Smtp-Source: ABdhPJyvkqC3jLzTu6e5T6xTqEIIxE4urWr6yq3ydJi8f3aJJ3hRBECYv6O0orbxQw2G4HE2VeDf2aZaQ0E/SA== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a17:902:e885:: with SMTP id w5mr6502827plg.147.1644485336379; Thu, 10 Feb 2022 01:28:56 -0800 (PST) Date: Thu, 10 Feb 2022 17:28:17 +0800 In-Reply-To: <20220210092833.55360-1-chooglen@google.com> Message-Id: <20220210092833.55360-5-chooglen@google.com> Mime-Version: 1.0 References: <20220208083952.35036-1-chooglen@google.com> <20220210092833.55360-1-chooglen@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH v7 04/20] submodule--helper: run update using child process struct From: Glen Choo To: git@vger.kernel.org Cc: Glen Choo , Junio C Hamano , Atharva Raykar , Christian Couder , Emily Shaffer , Jonathan Nieder , Kaartic Sivaraam , pc44800@gmail.com, Shourya Shukla , " =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= " Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Atharva Raykar We switch to using the run-command API function that takes a 'struct child process', since we are using a lot of the options. This will also make it simple to switch over to using 'capture_command()' when we start handling the output of the command completely in C. Mentored-by: Christian Couder Mentored-by: Shourya Shukla Signed-off-by: Atharva Raykar Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- builtin/submodule--helper.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 09cda67c1e..db71e6f4ec 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2344,47 +2344,45 @@ static int fetch_in_submodule(const char *module_path, int depth, int quiet, str static int run_update_command(struct update_data *ud, int subforce) { - struct strvec args = STRVEC_INIT; - struct strvec child_env = STRVEC_INIT; + struct child_process cp = CHILD_PROCESS_INIT; char *oid = oid_to_hex(&ud->oid); int must_die_on_failure = 0; - int git_cmd; switch (ud->update_strategy.type) { case SM_UPDATE_CHECKOUT: - git_cmd = 1; - strvec_pushl(&args, "checkout", "-q", NULL); + cp.git_cmd = 1; + strvec_pushl(&cp.args, "checkout", "-q", NULL); if (subforce) - strvec_push(&args, "-f"); + strvec_push(&cp.args, "-f"); break; case SM_UPDATE_REBASE: - git_cmd = 1; - strvec_push(&args, "rebase"); + cp.git_cmd = 1; + strvec_push(&cp.args, "rebase"); if (ud->quiet) - strvec_push(&args, "--quiet"); + strvec_push(&cp.args, "--quiet"); must_die_on_failure = 1; break; case SM_UPDATE_MERGE: - git_cmd = 1; - strvec_push(&args, "merge"); + cp.git_cmd = 1; + strvec_push(&cp.args, "merge"); if (ud->quiet) - strvec_push(&args, "--quiet"); + strvec_push(&cp.args, "--quiet"); must_die_on_failure = 1; break; case SM_UPDATE_COMMAND: - git_cmd = 0; - strvec_push(&args, ud->update_strategy.command); + cp.use_shell = 1; + strvec_push(&cp.args, ud->update_strategy.command); must_die_on_failure = 1; break; default: BUG("unexpected update strategy type: %s", submodule_strategy_to_string(&ud->update_strategy)); } - strvec_push(&args, oid); + strvec_push(&cp.args, oid); - prepare_submodule_repo_env(&child_env); - if (run_command_v_opt_cd_env(args.v, git_cmd ? RUN_GIT_CMD : RUN_USING_SHELL, - ud->sm_path, child_env.v)) { + cp.dir = xstrdup(ud->sm_path); + prepare_submodule_repo_env(&cp.env_array); + if (run_command(&cp)) { switch (ud->update_strategy.type) { case SM_UPDATE_CHECKOUT: printf(_("Unable to checkout '%s' in submodule path '%s'"), From patchwork Thu Feb 10 09:28:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12741601 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58C4EC433F5 for ; Thu, 10 Feb 2022 09:29:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238545AbiBJJ3E (ORCPT ); Thu, 10 Feb 2022 04:29:04 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238530AbiBJJ25 (ORCPT ); Thu, 10 Feb 2022 04:28:57 -0500 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2362510CB for ; Thu, 10 Feb 2022 01:28:59 -0800 (PST) Received: by mail-pl1-x649.google.com with SMTP id e7-20020a170902ef4700b0014d2b420f1fso1151578plx.17 for ; Thu, 10 Feb 2022 01:28:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc:content-transfer-encoding; bh=EN32OlSdIPLW/h0ox/yybskI+VjrxA2w7zI+99muzsA=; b=sP99KIU6E9j2NUgDojm8tt+ROeXuhZt3qKM2UygduZTczCfQlS/K0iMG9IY2ZIz55F LQsqi2jJh1d59BZcD+0dceoJng+HfenSFLGzrfqotuys5GFH9tGh/D2wNhF6k/KNFPgf zv07bSj/gfFeu7TMx9T2wfcUSCMxiEf1eusY0vHEcfEBBHsrlUHENQHYk1Y7eX78/TcR HjnUEBkreVB25J32DrhPUbN1IeLVWd7xaEU8iy41utQvuJ/nr1HuroFJBHLhy5IpoC7a vm8yPhkjGTgvw3krn0dbc9ivm1uTiPhX3qdp6CH2iW6PhxzFS73Nqii4bAQXJ9K8JdH0 6+Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=EN32OlSdIPLW/h0ox/yybskI+VjrxA2w7zI+99muzsA=; b=oNmKk4crkr0qs8EJ1BpS9g1FKSCSQazWYoYTdtdRsKWYpu4g26zUlYa5IhPct9oMNB t4ylAk60MiXtfpDson/ksqEzcF0FelDFBt5olJ7gX7IcsU+qSSe29kG/0NIZkuPhkBv1 zIhzGW+fLBkPUjMjc/FgRc8ke7mfqQMZ2L8PF8XPMuV+L+GihdTpSIZaJckZDXFJA9+T N3l3DTDylnnpMd6epJcQq5oK3WA4W6tJOD08kvc5ytSuSUJTWXaABwckW/bo8sXVr5EG 5hKQGaTvyy8h6rox5z0R9xb7ZAfNxK2hw/fhYCp81dd+aQpQOKsKDMdicJRUs6XTMyq6 ECgA== X-Gm-Message-State: AOAM531WHntjgg00QE8gk1L+yEltTNrtM4ZzQLaA7BEnVB66Jc7uyfr4 Pzh9QodA0Kfw5enE/iQGidnJLIui3Yb6Cr1vvm0JbdzQ/vgPuI3AhqDFNn/SQ/xsCWD2L0mfgcX 9NAs/mlQerfweCevBAyQwQDO/3M/Qv33H81GbhVWRiCvFLr9MA+Bj0rrp0xGch0Y= X-Google-Smtp-Source: ABdhPJy5JGCOi11QNUYC38pI1obUoVz5yddwa/6oQxBR3X5ZA1DebZcskE18gJeLt1CJ8Y2W4Coxhr40oGJrwg== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a63:dd0f:: with SMTP id t15mr5426654pgg.12.1644485338481; Thu, 10 Feb 2022 01:28:58 -0800 (PST) Date: Thu, 10 Feb 2022 17:28:18 +0800 In-Reply-To: <20220210092833.55360-1-chooglen@google.com> Message-Id: <20220210092833.55360-6-chooglen@google.com> Mime-Version: 1.0 References: <20220208083952.35036-1-chooglen@google.com> <20220210092833.55360-1-chooglen@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH v7 05/20] builtin/submodule--helper.c: reformat designated initializers From: Glen Choo To: git@vger.kernel.org Cc: Glen Choo , Junio C Hamano , Atharva Raykar , Christian Couder , Emily Shaffer , Jonathan Nieder , Kaartic Sivaraam , pc44800@gmail.com, Shourya Shukla , " =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= " Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Atharva Raykar The second hunk here will make a subsequent commit's diff smaller, and let's do the first and third hunks while we're at it so that we consistently format all of these. Signed-off-by: Atharva Raykar Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- builtin/submodule--helper.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index db71e6f4ec..9f79bdf4d5 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1654,7 +1654,10 @@ struct module_clone_data { unsigned int require_init: 1; int single_branch; }; -#define MODULE_CLONE_DATA_INIT { .reference = STRING_LIST_INIT_NODUP, .single_branch = -1 } +#define MODULE_CLONE_DATA_INIT { \ + .reference = STRING_LIST_INIT_NODUP, \ + .single_branch = -1, \ +} struct submodule_alternate_setup { const char *submodule_name; @@ -2047,7 +2050,9 @@ struct update_data { unsigned int nofetch: 1; unsigned int just_cloned: 1; }; -#define UPDATE_DATA_INIT { .update_strategy = SUBMODULE_UPDATE_STRATEGY_INIT } +#define UPDATE_DATA_INIT { \ + .update_strategy = SUBMODULE_UPDATE_STRATEGY_INIT, \ +} static void next_submodule_warn_missing(struct submodule_update_clone *suc, struct strbuf *out, const char *displaypath) @@ -3013,7 +3018,9 @@ struct add_data { unsigned int progress: 1; unsigned int dissociate: 1; }; -#define ADD_DATA_INIT { .depth = -1 } +#define ADD_DATA_INIT { \ + .depth = -1, \ +} static void append_fetch_remotes(struct strbuf *msg, const char *git_dir_path) { From patchwork Thu Feb 10 09:28:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12741602 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43ADAC433EF for ; Thu, 10 Feb 2022 09:29:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238531AbiBJJ3F (ORCPT ); Thu, 10 Feb 2022 04:29:05 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238554AbiBJJ3D (ORCPT ); Thu, 10 Feb 2022 04:29:03 -0500 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 355D910B4 for ; Thu, 10 Feb 2022 01:29:01 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id n9-20020a17090a73c900b001b5cafefa27so3886405pjk.2 for ; Thu, 10 Feb 2022 01:29:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc:content-transfer-encoding; bh=KtVdYHgHYdpKDN+uE8Vjf4NJtM9JXHAqmyaEt4fA0kc=; b=pw/0TI7pPN7ykV8RxavbqU7Wdqjv7uoIv8yGt7TRLiHVUCEHNDD6+C3ss6JjM56g0S gpzatP0zKIbhNrQrp04WfGuviqVS3cchtVwrDo+4cPXEb7zDPjLfgWLerJYhzVrlTBjM 60z5iylJzHWqimQqBuV5W6euF50stTW6iXl533s/vDEmlsXy8KSJw94cKP7qCHwKP2wc HihZxLIS//UdZuX6pgzN7tUsGqsGNh97l3t6NO/dzT3Kq76jFEsOSXYzB8YAslyqBUTW +WCyguQbycRdT7+0ZT8SnZj35GjadDWuexyZVtLw7jVjWglHiHyumsOZF4NHpPyaUs4f 9EnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=KtVdYHgHYdpKDN+uE8Vjf4NJtM9JXHAqmyaEt4fA0kc=; b=pZL+iqWuDyAYyYCG0UdC3j0gghlJ7mJJ4R+s0K3HVKRdYJM+MTTDwdYKsAiAms6fD3 4Zm+LmN+ZPr7VmhUKGezjnIoMcZuESi0tkIyeaweUFuDUqiseUfXEX6abZtw3L/JM3Di zbknHnAjGnDs35p0b1DQyQzuyK2mcziBjtn5f2aWfRBTVwyyNfqHivYk7TtRL1ydY+iG fCkgrxnLI8XEhlfI+5rgCSEQVHldrhq5C1sdKe7x75RvAKk0w2ticJrg6MewK59fsRxj jtYhrewlNWOk7hgeCL5xlmvPPM6aW+TTZWTJ8dLbXjDjfzTlou4JlRrNYhHea3dPA7QR Krzg== X-Gm-Message-State: AOAM530vpg33rhpJzr6yxMzhOHap4kWdlGVeIm15t3ZzsrzdhwPGLNo6 ZduwEAOt2h2sWBoVAmeLbUCpA6VGxaJDFwUvTnWlGRiLLa0JdvyDgnQKlmgkK8szFV6VugkHbiv 87Qi03ujTGsPsZ1T13z4GZE9RFL2rKwGsmRmaeq7yG+TPbCksC4EGVD5QXZZlle8= X-Google-Smtp-Source: ABdhPJxuQNGZTPYr2MsA0p/mbDOwksW83wlo/Jpu6mzV9kgNfjyYnEr5rqyqQbtV4mbQo6IxHuR2Zn72D8YoCQ== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a62:15c5:: with SMTP id 188mr6715954pfv.84.1644485340625; Thu, 10 Feb 2022 01:29:00 -0800 (PST) Date: Thu, 10 Feb 2022 17:28:19 +0800 In-Reply-To: <20220210092833.55360-1-chooglen@google.com> Message-Id: <20220210092833.55360-7-chooglen@google.com> Mime-Version: 1.0 References: <20220208083952.35036-1-chooglen@google.com> <20220210092833.55360-1-chooglen@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH v7 06/20] builtin/submodule--helper.c: rename option variables to "opt" From: Glen Choo To: git@vger.kernel.org Cc: Glen Choo , Junio C Hamano , Atharva Raykar , Christian Couder , Emily Shaffer , Jonathan Nieder , Kaartic Sivaraam , pc44800@gmail.com, Shourya Shukla , " =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= " Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Ævar Arnfjörð Bjarmason Rename the "suc" variable in update_clone() to "opt", and do the same for the "update_data" variable in run_update_procedure(). The only reason for this change is to make the subsequent commit's diff smaller, by doing this rename we can "anchor" the diff better, as it "borrow" most of the options declared here as-is as far as the diff rename detection is concerned. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- builtin/submodule--helper.c | 74 ++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 9f79bdf4d5..c2d4fd0347 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2517,36 +2517,36 @@ static int update_clone(int argc, const char **argv, const char *prefix) { const char *update = NULL; struct pathspec pathspec; - struct submodule_update_clone suc = SUBMODULE_UPDATE_CLONE_INIT; + struct submodule_update_clone opt = SUBMODULE_UPDATE_CLONE_INIT; struct option module_update_clone_options[] = { OPT_STRING(0, "prefix", &prefix, N_("path"), N_("path into the working tree")), - OPT_STRING(0, "recursive-prefix", &suc.recursive_prefix, + OPT_STRING(0, "recursive-prefix", &opt.recursive_prefix, N_("path"), N_("path into the working tree, across nested " "submodule boundaries")), OPT_STRING(0, "update", &update, N_("string"), N_("rebase, merge, checkout or none")), - OPT_STRING_LIST(0, "reference", &suc.references, N_("repo"), + OPT_STRING_LIST(0, "reference", &opt.references, N_("repo"), N_("reference repository")), - OPT_BOOL(0, "dissociate", &suc.dissociate, + OPT_BOOL(0, "dissociate", &opt.dissociate, N_("use --reference only while cloning")), - OPT_STRING(0, "depth", &suc.depth, "", + OPT_STRING(0, "depth", &opt.depth, "", N_("create a shallow clone truncated to the " "specified number of revisions")), - OPT_INTEGER('j', "jobs", &suc.max_jobs, + OPT_INTEGER('j', "jobs", &opt.max_jobs, N_("parallel jobs")), - OPT_BOOL(0, "recommend-shallow", &suc.recommend_shallow, + OPT_BOOL(0, "recommend-shallow", &opt.recommend_shallow, N_("whether the initial clone should follow the shallow recommendation")), - OPT__QUIET(&suc.quiet, N_("don't print cloning progress")), - OPT_BOOL(0, "progress", &suc.progress, + OPT__QUIET(&opt.quiet, N_("don't print cloning progress")), + OPT_BOOL(0, "progress", &opt.progress, N_("force cloning progress")), - OPT_BOOL(0, "require-init", &suc.require_init, + OPT_BOOL(0, "require-init", &opt.require_init, N_("disallow cloning into non-empty directory")), - OPT_BOOL(0, "single-branch", &suc.single_branch, + OPT_BOOL(0, "single-branch", &opt.single_branch, N_("clone only one branch, HEAD or --branch")), OPT_END() }; @@ -2555,32 +2555,32 @@ static int update_clone(int argc, const char **argv, const char *prefix) N_("git submodule--helper update-clone [--prefix=] [...]"), NULL }; - suc.prefix = prefix; + opt.prefix = prefix; - update_clone_config_from_gitmodules(&suc.max_jobs); - git_config(git_update_clone_config, &suc.max_jobs); + update_clone_config_from_gitmodules(&opt.max_jobs); + git_config(git_update_clone_config, &opt.max_jobs); argc = parse_options(argc, argv, prefix, module_update_clone_options, git_submodule_helper_usage, 0); if (update) - if (parse_submodule_update_strategy(update, &suc.update) < 0) + if (parse_submodule_update_strategy(update, &opt.update) < 0) die(_("bad value for update parameter")); - if (module_list_compute(argc, argv, prefix, &pathspec, &suc.list) < 0) + if (module_list_compute(argc, argv, prefix, &pathspec, &opt.list) < 0) return 1; if (pathspec.nr) - suc.warn_if_uninitialized = 1; + opt.warn_if_uninitialized = 1; - return update_submodules(&suc); + return update_submodules(&opt); } static int run_update_procedure(int argc, const char **argv, const char *prefix) { int force = 0, quiet = 0, nofetch = 0, just_cloned = 0; char *prefixed_path, *update = NULL; - struct update_data update_data = UPDATE_DATA_INIT; + struct update_data opt = UPDATE_DATA_INIT; struct option options[] = { OPT__QUIET(&quiet, N_("suppress output for update by rebase or merge")), @@ -2589,20 +2589,20 @@ static int run_update_procedure(int argc, const char **argv, const char *prefix) N_("don't fetch new objects from the remote site")), OPT_BOOL(0, "just-cloned", &just_cloned, N_("overrides update mode in case the repository is a fresh clone")), - OPT_INTEGER(0, "depth", &update_data.depth, N_("depth for shallow fetch")), + OPT_INTEGER(0, "depth", &opt.depth, N_("depth for shallow fetch")), OPT_STRING(0, "prefix", &prefix, N_("path"), N_("path into the working tree")), OPT_STRING(0, "update", &update, N_("string"), N_("rebase, merge, checkout or none")), - OPT_STRING(0, "recursive-prefix", &update_data.recursive_prefix, N_("path"), + OPT_STRING(0, "recursive-prefix", &opt.recursive_prefix, N_("path"), N_("path into the working tree, across nested " "submodule boundaries")), - OPT_CALLBACK_F(0, "oid", &update_data.oid, N_("sha1"), + OPT_CALLBACK_F(0, "oid", &opt.oid, N_("sha1"), N_("SHA1 expected by superproject"), PARSE_OPT_NONEG, parse_opt_object_id), - OPT_CALLBACK_F(0, "suboid", &update_data.suboid, N_("subsha1"), + OPT_CALLBACK_F(0, "suboid", &opt.suboid, N_("subsha1"), N_("SHA1 of submodule's HEAD"), PARSE_OPT_NONEG, parse_opt_object_id), OPT_END() @@ -2618,27 +2618,27 @@ static int run_update_procedure(int argc, const char **argv, const char *prefix) if (argc != 1) usage_with_options(usage, options); - update_data.force = !!force; - update_data.quiet = !!quiet; - update_data.nofetch = !!nofetch; - update_data.just_cloned = !!just_cloned; - update_data.sm_path = argv[0]; + opt.force = !!force; + opt.quiet = !!quiet; + opt.nofetch = !!nofetch; + opt.just_cloned = !!just_cloned; + opt.sm_path = argv[0]; - if (update_data.recursive_prefix) - prefixed_path = xstrfmt("%s%s", update_data.recursive_prefix, update_data.sm_path); + if (opt.recursive_prefix) + prefixed_path = xstrfmt("%s%s", opt.recursive_prefix, opt.sm_path); else - prefixed_path = xstrdup(update_data.sm_path); + prefixed_path = xstrdup(opt.sm_path); - update_data.displaypath = get_submodule_displaypath(prefixed_path, prefix); + opt.displaypath = get_submodule_displaypath(prefixed_path, prefix); - determine_submodule_update_strategy(the_repository, update_data.just_cloned, - update_data.sm_path, update, - &update_data.update_strategy); + determine_submodule_update_strategy(the_repository, opt.just_cloned, + opt.sm_path, update, + &opt.update_strategy); free(prefixed_path); - if (!oideq(&update_data.oid, &update_data.suboid) || update_data.force) - return do_run_update_procedure(&update_data); + if (!oideq(&opt.oid, &opt.suboid) || opt.force) + return do_run_update_procedure(&opt); return 3; } From patchwork Thu Feb 10 09:28:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12741603 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 262B0C433FE for ; Thu, 10 Feb 2022 09:29:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238570AbiBJJ3H (ORCPT ); Thu, 10 Feb 2022 04:29:07 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238567AbiBJJ3D (ORCPT ); Thu, 10 Feb 2022 04:29:03 -0500 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 724A510F4 for ; Thu, 10 Feb 2022 01:29:03 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id hi22-20020a17090b30d600b001b8b33cf0efso3896556pjb.1 for ; Thu, 10 Feb 2022 01:29:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc:content-transfer-encoding; bh=puu5AcCYsaaMCyP0Miw6o/BQAKwD83xVxXobDV0qE4M=; b=ae7YbC3m88t3k0G55nIaWnGfebWPCzor2XmEqpBlibQnUZz+dPZ6mMMXOkA4ih0g8y 0BgsWf6qCw5IMivXg3Prs9FJewDA+dF9vwvOE7qK+bHBmH95TVS40tIFtciuJy4c9Js8 UUSrKZcjxj5Xt1eo3qdrj68nsPJXPnZy1N/A56s8M7o5iCevJ4wse++gGtvygXxQtzVP 1oB/Bt4LY2wbLIsNCATW3TPqH9y2Nsue53OIYrdlIMQucfS5BxOyQTP4oBPv09r1DaC7 KGgMSUhIelYccaSMfoA7itG9pxI2tUKvuwE0zSX2Izj9Vrg4sjBhmeFNoRmqh5cxncOv Ecgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=puu5AcCYsaaMCyP0Miw6o/BQAKwD83xVxXobDV0qE4M=; b=coCEbUPYWRT0XYgKW+MO7WkgjYn/tp2AYiYuk/R8iiOqXxZVv2ulpZQIjWbuYpuZI/ 2pyFYLiS/Bq0j3zD599B+jrqqtdbtU3TGH25MQF050b7+v/grvYjJnEmSBM5sm/hwE4S T31FCW7bplzKbiUJzwG+tLf1BFBIaEsuv/059J3BiNDi4YcIVKvlTU/CWH05/YlSpnJO 5SfvUbjosYpcPF9iU1NCOXAKMf4BQ/T+N9AOzcFxdOu2HX0itLd7i8+qq9IY+F7hP/ZP qW0th6tdKxC7ucAuDP3QZzDa28J2KQNQySlJSGTsI0qaQzi3xaH9qJV7Vl+27BZSCTvi SpTA== X-Gm-Message-State: AOAM531fyiupUY29jt8Qm6L6kqzpGnQJ+2GAW67hLW8ZZtbwtHxc8bcv 4uZGyO3ln4aDUvoKpJHT3dArAyLvMMIfiSg7RAXUEOiNWnhwRX9eFIdnM9L0f+daPjDJdIneHI8 nZH2p3lqzGUlNGx+RgaKLHovB4K/bCbWuP58NToLo6ZW7pAO8KOL3bsW93O4JmMY= X-Google-Smtp-Source: ABdhPJzBcmigvrQG5c0i/f5vLjwk/sqVjNFC0vRhKCagI/Vg77BkoKHn0qzj9BJJB+gKGYlefHCPhI08P7qO7A== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a05:6a00:15d5:: with SMTP id o21mr6725653pfu.9.1644485342844; Thu, 10 Feb 2022 01:29:02 -0800 (PST) Date: Thu, 10 Feb 2022 17:28:20 +0800 In-Reply-To: <20220210092833.55360-1-chooglen@google.com> Message-Id: <20220210092833.55360-8-chooglen@google.com> Mime-Version: 1.0 References: <20220208083952.35036-1-chooglen@google.com> <20220210092833.55360-1-chooglen@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH v7 07/20] submodule--helper: don't use bitfield indirection for parse_options() From: Glen Choo To: git@vger.kernel.org Cc: Glen Choo , Junio C Hamano , Atharva Raykar , Christian Couder , Emily Shaffer , Jonathan Nieder , Kaartic Sivaraam , pc44800@gmail.com, Shourya Shukla , " =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= " Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Ævar Arnfjörð Bjarmason Do away with the indirection of local variables added in c51f8f94e5b (submodule--helper: run update procedures from C, 2021-08-24). These were only needed because in C you can't get a pointer to a single bit, so we were using intermediate variables instead. This will also make a subsequent large commit's diff smaller. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- builtin/submodule--helper.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index c2d4fd0347..4a0890954e 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2045,10 +2045,10 @@ struct update_data { struct object_id suboid; struct submodule_update_strategy update_strategy; int depth; - unsigned int force: 1; - unsigned int quiet: 1; - unsigned int nofetch: 1; - unsigned int just_cloned: 1; + unsigned int force; + unsigned int quiet; + unsigned int nofetch; + unsigned int just_cloned; }; #define UPDATE_DATA_INIT { \ .update_strategy = SUBMODULE_UPDATE_STRATEGY_INIT, \ @@ -2578,16 +2578,17 @@ static int update_clone(int argc, const char **argv, const char *prefix) static int run_update_procedure(int argc, const char **argv, const char *prefix) { - int force = 0, quiet = 0, nofetch = 0, just_cloned = 0; char *prefixed_path, *update = NULL; struct update_data opt = UPDATE_DATA_INIT; struct option options[] = { - OPT__QUIET(&quiet, N_("suppress output for update by rebase or merge")), - OPT__FORCE(&force, N_("force checkout updates"), 0), - OPT_BOOL('N', "no-fetch", &nofetch, + OPT__QUIET(&opt.quiet, + N_("suppress output for update by rebase or merge")), + OPT__FORCE(&opt.force, N_("force checkout updates"), + 0), + OPT_BOOL('N', "no-fetch", &opt.nofetch, N_("don't fetch new objects from the remote site")), - OPT_BOOL(0, "just-cloned", &just_cloned, + OPT_BOOL(0, "just-cloned", &opt.just_cloned, N_("overrides update mode in case the repository is a fresh clone")), OPT_INTEGER(0, "depth", &opt.depth, N_("depth for shallow fetch")), OPT_STRING(0, "prefix", &prefix, @@ -2618,10 +2619,6 @@ static int run_update_procedure(int argc, const char **argv, const char *prefix) if (argc != 1) usage_with_options(usage, options); - opt.force = !!force; - opt.quiet = !!quiet; - opt.nofetch = !!nofetch; - opt.just_cloned = !!just_cloned; opt.sm_path = argv[0]; if (opt.recursive_prefix) From patchwork Thu Feb 10 09:28:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12741604 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5A93C433F5 for ; Thu, 10 Feb 2022 09:29:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238582AbiBJJ3I (ORCPT ); Thu, 10 Feb 2022 04:29:08 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238539AbiBJJ3E (ORCPT ); Thu, 10 Feb 2022 04:29:04 -0500 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECE46D95 for ; Thu, 10 Feb 2022 01:29:05 -0800 (PST) Received: by mail-pl1-x649.google.com with SMTP id q16-20020a170902edd000b0014d6be8d4b7so1147405plk.18 for ; Thu, 10 Feb 2022 01:29:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc:content-transfer-encoding; bh=PcDPigmq9mq3SJk3g82pK/HsmEj4Qxy6w2HHVzWfTMo=; b=tCD2rhtnU1sWsQ85nQhQgx5Npnxzzxp5ycw2c5D+6F6rI+Z1hreUYLXSA390/HNbs2 lTN8qnU/6CHsAAgNO0sAjYk3jBZ/hP/uXMeI4E5wRycsGoGrnaR0YQoOmVh04AFDO41E g4vu+lWvJOT1ZFsA/Avf0AKiR20GKf12qv37G06TWUFKWqzEfgWKsgKSyRzQ9cM8flqC o34/kEsAwGL4o2vPYhoDbq+K0OXT/LW9SSM1LOVmrtPx+X6FUFf308obYvx3nTQInPT6 Es9MB9MJou4bFzXWtPtf+5SqeDvUzi350Lc0dVQ2L/sFNjVK3lPS438beaDICQSK8cph B90A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=PcDPigmq9mq3SJk3g82pK/HsmEj4Qxy6w2HHVzWfTMo=; b=s5oRpHX1x4yQwUlnAt6gzpNV3b/V7AGzYq5Vs30R8M3yDJDTcD7xbIAntC2h+1CDOi fa+sahM+bGSHIKTW5ULYimMOiaWZVMoaZ+o7K82ieGRcu39W7QuEq5r0zzabYHBkOhuR Sy1Ycn/A1/ujp8OOT7npKIp3uXwDETuNNpnkOLdsqHBcEoza9eZ5iKdUhE1gMfQ2yN1v z+xDsiktYAbISRyJBiGzeD560qBlW+Qf5tCVRGJPD4FQrCnXy5oy5WPiLLpPWtIfwGFK oMqrmIQbmHHYv067UI9W9QgFxAVQqYF14LdOUavQrsHEOuM/9oXf84oMqnqKrmvJUkF2 m20A== X-Gm-Message-State: AOAM530r2Ueo2TP2F2tki8Md2+VX38kSBgZmWdvOwYe5MXsKJgiSQibE B3MHZ3RBfD9gBafav+p3a7WWRI60aQdiE5MamzismyZJrL2VhUTP9jKKIHULque8C5Ev8pmCqHQ mLZd4MMDJpr1eJD4yLEyBsraWt9+R05oJlzc0jZcF81LBANP9L9/KqSRirKgFXgU= X-Google-Smtp-Source: ABdhPJynbpgKJkJRu+7TpJ99CaB/ts5LTAOcOjUX4/dOAfguvkMEpEn+M2jBEf2b9bpM0xmKWGUU+OcmsIFS1A== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a17:90b:4a52:: with SMTP id lb18mr659947pjb.92.1644485345023; Thu, 10 Feb 2022 01:29:05 -0800 (PST) Date: Thu, 10 Feb 2022 17:28:21 +0800 In-Reply-To: <20220210092833.55360-1-chooglen@google.com> Message-Id: <20220210092833.55360-9-chooglen@google.com> Mime-Version: 1.0 References: <20220208083952.35036-1-chooglen@google.com> <20220210092833.55360-1-chooglen@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH v7 08/20] submodule tests: test for init and update failure output From: Glen Choo To: git@vger.kernel.org Cc: Glen Choo , Junio C Hamano , Atharva Raykar , Christian Couder , Emily Shaffer , Jonathan Nieder , Kaartic Sivaraam , pc44800@gmail.com, Shourya Shukla , " =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= " Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Ævar Arnfjörð Bjarmason Amend some submodule tests to test for the failure output of "git submodule [update|init]". The lack of such tests hid a regression in an earlier version of a subsequent commit. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- t/t7406-submodule-update.sh | 14 ++++++++++++-- t/t7408-submodule-reference.sh | 14 +++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh index 11cccbb333..7764c1c3cb 100755 --- a/t/t7406-submodule-update.sh +++ b/t/t7406-submodule-update.sh @@ -205,8 +205,18 @@ test_expect_success 'submodule update should fail due to local changes' ' (cd submodule && compare_head ) && - test_must_fail git submodule update submodule - ) + test_must_fail git submodule update submodule 2>../actual.raw + ) && + sed "s/^> //" >expect <<-\EOF && + > error: Your local changes to the following files would be overwritten by checkout: + > file + > Please commit your changes or stash them before you switch branches. + > Aborting + > fatal: Unable to checkout OID in submodule path '\''submodule'\'' + EOF + sed -e "s/checkout $SQ[^$SQ]*$SQ/checkout OID/" actual && + test_cmp expect actual + ' test_expect_success 'submodule update should throw away changes with --force ' ' (cd super && diff --git a/t/t7408-submodule-reference.sh b/t/t7408-submodule-reference.sh index a3892f494b..c3a4545510 100755 --- a/t/t7408-submodule-reference.sh +++ b/t/t7408-submodule-reference.sh @@ -193,7 +193,19 @@ test_expect_success 'missing nested submodule alternate fails clone and submodul cd supersuper-clone && check_that_two_of_three_alternates_are_used && # update of the submodule fails - test_must_fail git submodule update --init --recursive + cat >expect <<-\EOF && + fatal: submodule '\''sub'\'' cannot add alternate: path ... does not exist + Failed to clone '\''sub'\''. Retry scheduled + fatal: submodule '\''sub-dissociate'\'' cannot add alternate: path ... does not exist + Failed to clone '\''sub-dissociate'\''. Retry scheduled + fatal: submodule '\''sub'\'' cannot add alternate: path ... does not exist + Failed to clone '\''sub'\'' a second time, aborting + fatal: Failed to recurse into submodule path ... + EOF + test_must_fail git submodule update --init --recursive 2>err && + grep -e fatal: -e ^Failed err >actual.raw && + sed -e "s/path $SQ[^$SQ]*$SQ/path .../" actual && + test_cmp expect actual ) ' From patchwork Thu Feb 10 09:28:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12741605 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CD00C433FE for ; Thu, 10 Feb 2022 09:29:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238661AbiBJJ3S (ORCPT ); Thu, 10 Feb 2022 04:29:18 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238562AbiBJJ3G (ORCPT ); Thu, 10 Feb 2022 04:29:06 -0500 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC559D95 for ; Thu, 10 Feb 2022 01:29:07 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id q12-20020a17090a2e0c00b001b874772fecso3566332pjd.2 for ; Thu, 10 Feb 2022 01:29:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=aOKoxMtNyA0xhNibVJgaFQ9E2qSM8PrWwJbEr/7dtj0=; b=DoDhPy2WJQ/naaT++aIqcJzdzALnNm0X2NwEmXY7MNLKWkyOW6vFVhFL13cKdq6c2t q4FAtM3Ug5mSjw1xIa89fKTIV62TPYOntOsbiL8jwk2tqgBfScnYYT1nhulnDGaCwQ0p 8QSoW4YR+mx9KXjhEFEhvxi8tFuo8KaCGppgqxHqkYBvawpXgpSNHIEXc5MFo2rDydeU iz+Cd1VTcFZtmjnw2evZqVXqmPkrz1UEdhfgOmu6/EppUO6xoFZcbe06kULVTSitUWdQ Lj0lW5nrwHcrm13tVD/hXCyzQMKp9PdIzfvks7nFisXTn++9jraHqtPeGPLbEBp3QvmO JBXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=aOKoxMtNyA0xhNibVJgaFQ9E2qSM8PrWwJbEr/7dtj0=; b=wDlBX0LtTye8CNQfChgTMJ8ABFmZRNXQsyHeN17BsdKKtM0sldfvIAI8+w1HHDosQ3 DjuaO7wHcNCPp83DfLTpuuAQjBo1jrmKQIw6IUAS2zv1Erz5FBlVErru10p0a9glFW+e mD8TagJZ3atmW4eQ37m9VvhhjXDa6bZV5fuv1YveEb2zNWaFCJ8AkxTJKA7QhvEMFs5N QIBHPG9ZwZT1YdeQAz0KxoQ1dMhUEU9ZynNSt0E91r6WObCss8uXNbhwCVePXeeUiJH9 ykdpR39enE09dDocCOdJV3KAP7JC7DUrPe4nkM3YEnZE2coK2EFHAcXCTu4lTVhzOlRj c3cQ== X-Gm-Message-State: AOAM5334lihAGD44T2l53gjKT6LlAYPxEPxcLtgJxl3jdUhOOjBHu0bp jD698S6N2upvwhuUFRWTOUI+HzQ9895ljITOuenOiubji+emjGqPHCjUjMppCRkEaofoiVSpszL c8Rh7pt89QsO18cUr+I6vqfOu+irsxV94XZih+D9UGfw0KmHYQTL4RUFoo6CGSws= X-Google-Smtp-Source: ABdhPJxvafrG5Ndsuz6CuEjgnbH4KnLaNYMQWPZjEzF5wbjY4Rew8gxCnsbdbrC/CdEdFRuQqYX+va+QqeUCvA== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a17:90a:5206:: with SMTP id v6mr1832459pjh.220.1644485347156; Thu, 10 Feb 2022 01:29:07 -0800 (PST) Date: Thu, 10 Feb 2022 17:28:22 +0800 In-Reply-To: <20220210092833.55360-1-chooglen@google.com> Message-Id: <20220210092833.55360-10-chooglen@google.com> Mime-Version: 1.0 References: <20220208083952.35036-1-chooglen@google.com> <20220210092833.55360-1-chooglen@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH v7 09/20] submodule--helper: remove update-module-mode From: Glen Choo To: git@vger.kernel.org Cc: Glen Choo , Junio C Hamano , Atharva Raykar , Christian Couder , Emily Shaffer , Jonathan Nieder , Kaartic Sivaraam , pc44800@gmail.com, Shourya Shukla , " =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= " Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This is dead code - it has not been used since c51f8f94e5 (submodule--helper: run update procedures from C, 2021-08-24). Signed-off-by: Glen Choo --- builtin/submodule--helper.c | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 4a0890954e..e0cc1c1b79 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1965,29 +1965,6 @@ static void determine_submodule_update_strategy(struct repository *r, free(key); } -static int module_update_module_mode(int argc, const char **argv, const char *prefix) -{ - const char *path, *update = NULL; - int just_cloned; - struct submodule_update_strategy update_strategy = { .type = SM_UPDATE_CHECKOUT }; - - if (argc < 3 || argc > 4) - die("submodule--helper update-module-clone expects []"); - - just_cloned = git_config_int("just_cloned", argv[1]); - path = argv[2]; - - if (argc == 4) - update = argv[3]; - - determine_submodule_update_strategy(the_repository, - just_cloned, path, update, - &update_strategy); - fputs(submodule_strategy_to_string(&update_strategy), stdout); - - return 0; -} - struct update_clone_data { const struct submodule *sub; struct object_id oid; @@ -3388,7 +3365,6 @@ static struct cmd_struct commands[] = { {"name", module_name, 0}, {"clone", module_clone, 0}, {"add", module_add, SUPPORT_SUPER_PREFIX}, - {"update-module-mode", module_update_module_mode, 0}, {"update-clone", update_clone, 0}, {"run-update-procedure", run_update_procedure, 0}, {"ensure-core-worktree", ensure_core_worktree, 0}, From patchwork Thu Feb 10 09:28:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12741607 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C5ECC433EF for ; Thu, 10 Feb 2022 09:29:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238573AbiBJJ3Z (ORCPT ); Thu, 10 Feb 2022 04:29:25 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238583AbiBJJ3I (ORCPT ); Thu, 10 Feb 2022 04:29:08 -0500 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F29E010E3 for ; Thu, 10 Feb 2022 01:29:09 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id z12-20020a17090a1fcc00b001b63e477f9fso3562461pjz.3 for ; Thu, 10 Feb 2022 01:29:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=9tSCNhbr0674my1WC8Aj0WZhf1LgKShpcEo/fODt+ps=; b=hDCtHZj+1PvZHPlvP5Onnxyotv2cJuNsgXGUocNcXkBDr04gOa9A++Ce4bLqZZPK6s suUdk4VNon44RXYsibQXS1ZNoEyIR3DHt48JEfbvKnoJoE5dyO7tJRIH31Ut8687fd3g NsihRaGpFWYZIYrexA/66BK5hvhck6P95DSHxbERcgbrKFfvjj+c4TI722V5wIZh3AxI bNjfgBXCN7ICv2JuUCkYoU+9X+fYvQQUEaG7gLrAxJ4DONOxnub7douRPk7sO++ZxXh4 wsaTLoABE4Tq7v7gYKht5wjh044JmigSrRS9L3k+MMago/eOpc87rzty/d5v2GISjamq vhqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=9tSCNhbr0674my1WC8Aj0WZhf1LgKShpcEo/fODt+ps=; b=PoBPhOgdo/1oLvEUhZYvroNdB5kqMz4O7sm8WbNF46Noq3SQp8GZuMai1WL82lpikO TWWUbSv7eC1cVzUS6nPA+U9S6udLpjuZN7Qef9cjDNpVNunbolfQAbwOKkigWrYGG7lb WxtDFESg1vAk2jY6QwbJYVi1rukAx3laSd88FUqY2qcWYDpWpQSVBLlJ4dbdHxQkDHgR u7fMvRuXIripDpGzViBvqRn92UnFy/ekmuH6zp62iHA29KfJwEmdKuTL40aeUN0uTwPR 2syJVvi+0ISYeD/2dHi4zb7zHSjBUUwR7qwSd2FL8du9kqUdLxmA4QjHj3yASNqJ0ngN LJSA== X-Gm-Message-State: AOAM532ceuqD+180sVGvM3IML6adcchL+//d3hETnhq7aabPl/h4DoAw +SqbCXULCN41Rt9GwF6U4ZGiw0xIersKYLltupNmbvmgL8SJjlDTjiUztP0EpHu0Zam/+vlz5b2 aPd1UjUD5tu03myiVlRFaxqYXeB+jhRTgKxvYKStv3i/Up7hD8yTNNnD7NY0DRTw= X-Google-Smtp-Source: ABdhPJz5XszzSiKI5+MoDiXrJM6vQ+rah2vRpZrYAq/f8+RSuIwbUV1lLDxBG9UlFcdJyQI52PFHhnjP4LYCzA== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a17:90b:4c8e:: with SMTP id my14mr318568pjb.0.1644485349049; Thu, 10 Feb 2022 01:29:09 -0800 (PST) Date: Thu, 10 Feb 2022 17:28:23 +0800 In-Reply-To: <20220210092833.55360-1-chooglen@google.com> Message-Id: <20220210092833.55360-11-chooglen@google.com> Mime-Version: 1.0 References: <20220208083952.35036-1-chooglen@google.com> <20220210092833.55360-1-chooglen@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH v7 10/20] submodule--helper: reorganize code for sh to C conversion From: Glen Choo To: git@vger.kernel.org Cc: Glen Choo , Junio C Hamano , Atharva Raykar , Christian Couder , Emily Shaffer , Jonathan Nieder , Kaartic Sivaraam , pc44800@gmail.com, Shourya Shukla , " =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= " Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Introduce a function, update_submodule2(), that performs an update for one submodule. This function will implement the functionality of run-update-procedure and its surrounding shell code in submodule.sh. Signed-off-by: Glen Choo --- builtin/submodule--helper.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index e0cc1c1b79..0b5120734a 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2553,6 +2553,11 @@ static int update_clone(int argc, const char **argv, const char *prefix) return update_submodules(&opt); } +/* + * NEEDSWORK: Use a forward declaration to avoid moving + * run_update_procedure() (which will be removed soon). + */ +static int update_submodule2(struct update_data *update_data); static int run_update_procedure(int argc, const char **argv, const char *prefix) { char *prefixed_path, *update = NULL; @@ -2610,11 +2615,7 @@ static int run_update_procedure(int argc, const char **argv, const char *prefix) &opt.update_strategy); free(prefixed_path); - - if (!oideq(&opt.oid, &opt.suboid) || opt.force) - return do_run_update_procedure(&opt); - - return 3; + return update_submodule2(&opt); } static int resolve_relative_path(int argc, const char **argv, const char *prefix) @@ -2978,6 +2979,15 @@ static int module_set_branch(int argc, const char **argv, const char *prefix) return !!ret; } +/* NEEDSWORK: this is a temporary name until we delete update_submodule() */ +static int update_submodule2(struct update_data *update_data) +{ + if (!oideq(&update_data->oid, &update_data->suboid) || update_data->force) + return do_run_update_procedure(update_data); + + return 3; +} + struct add_data { const char *prefix; const char *branch; From patchwork Thu Feb 10 09:28:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12741606 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E751C433EF for ; Thu, 10 Feb 2022 09:29:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238591AbiBJJ3X (ORCPT ); Thu, 10 Feb 2022 04:29:23 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238596AbiBJJ3R (ORCPT ); Thu, 10 Feb 2022 04:29:17 -0500 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFB1710F7 for ; Thu, 10 Feb 2022 01:29:12 -0800 (PST) Received: by mail-pl1-x64a.google.com with SMTP id y3-20020a1709029b8300b0014c8bcb70a1so1174284plp.3 for ; Thu, 10 Feb 2022 01:29:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=C4m91dacx6CAhzX4YyT26sMDoIhe7B1orAVRP6TgaLI=; b=Yi+2Wa25Qibj0JXSuPlxjGpIcbxlj9ouU6mwYmVglMmXO6H5OSB/9kPlr5TZRZLKPd EfN62VCh2nNNcy3U6R8ARrTAaAIMqdXbkekZ9jlzY3OwFw0Nt9VBXvE4Pn03wllntmXN Absqw8CfGcJinRCXBNr4RlWf7v/xZR7EAPQiAYE6BY9+rhW5/THuIIRyN9F/D2FDGqa9 Q8t5Ue83pjYDVcR2tVqTJPnakapMopk9kpDW9HQHsVnZ3/Iz2LZmcObWbeDCVLq74kq3 X5WezFeZxxpXThukOUrr/TDH3MDfkOYtBKuhmfNal/GRiM+C9l8jqaLd6XaZThgX+/dv 8KVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=C4m91dacx6CAhzX4YyT26sMDoIhe7B1orAVRP6TgaLI=; b=Zk7O0I9nCikn991ejHA25U9inOCnsZ6fpTmCeiZW/H0IWPuNDhFR9hcuYYY6y8+T6a GW1ulA/V+RUj0OrW4DQfcoy7+SQRfMTwmgBOoLnTzVAaMvsPy6NwVCip5AkOj6VfT5kl Q4LKERsONzryArqmJkj8m4NRc+SQgEdOSYSqy5vK35Eo4zKV8UAEuoyV/dutGzcvG4dQ JM8bws/aCRPE64qP5meYRJRnzHM4Jo4FqqB+eJ//jUfNu1l8KkWwuYGXvCrNKdOztuvb QAgLemFj6Hix4et3Uw7iOJvm2DKuqOm+tzBoEy/50xeBzEhZU+Gl/z6IyOyCBbQLA7mc ngfQ== X-Gm-Message-State: AOAM531/3up3JJ8S3vr6xgSz0yuxPBXzwte7WKfdUWujHthaB0T3gIX3 yxARlvPn6fhMC2FRSCjKlJp2ITbA37Xn9DhBDTKpNDnzaqIwKsKD2fxlJ/7KUk18PfpwkDBHWki BPEXG7XOOtu44phA7IZHITC8rlCDfns+cfX/QUAjvzWJFLcvrYy89xC6x/EDwVac= X-Google-Smtp-Source: ABdhPJyNrMQP/w/PPwknhh7wRxIQ3pDEHGTI8ndyHQEof/wON8vuDVI+vaRft/35N7LYHovkF8XPjhIVriy0QQ== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a63:3197:: with SMTP id x145mr976218pgx.618.1644485351490; Thu, 10 Feb 2022 01:29:11 -0800 (PST) Date: Thu, 10 Feb 2022 17:28:24 +0800 In-Reply-To: <20220210092833.55360-1-chooglen@google.com> Message-Id: <20220210092833.55360-12-chooglen@google.com> Mime-Version: 1.0 References: <20220208083952.35036-1-chooglen@google.com> <20220210092833.55360-1-chooglen@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH v7 11/20] submodule--helper run-update-procedure: remove --suboid From: Glen Choo To: git@vger.kernel.org Cc: Glen Choo , Junio C Hamano , Atharva Raykar , Christian Couder , Emily Shaffer , Jonathan Nieder , Kaartic Sivaraam , pc44800@gmail.com, Shourya Shukla , " =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= " Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Teach run-update-procedure to determine the oid of the submodule's HEAD instead of doing it in git-subomdule.sh. Signed-off-by: Glen Choo --- builtin/submodule--helper.c | 12 +++++++++--- git-submodule.sh | 8 +------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 0b5120734a..a26477ce04 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2585,9 +2585,6 @@ static int run_update_procedure(int argc, const char **argv, const char *prefix) OPT_CALLBACK_F(0, "oid", &opt.oid, N_("sha1"), N_("SHA1 expected by superproject"), PARSE_OPT_NONEG, parse_opt_object_id), - OPT_CALLBACK_F(0, "suboid", &opt.suboid, N_("subsha1"), - N_("SHA1 of submodule's HEAD"), PARSE_OPT_NONEG, - parse_opt_object_id), OPT_END() }; @@ -2982,6 +2979,15 @@ static int module_set_branch(int argc, const char **argv, const char *prefix) /* NEEDSWORK: this is a temporary name until we delete update_submodule() */ static int update_submodule2(struct update_data *update_data) { + /* NEEDSWORK: fix the style issues e.g. braces */ + if (update_data->just_cloned) { + oidcpy(&update_data->suboid, null_oid()); + } else { + if (resolve_gitlink_ref(update_data->sm_path, "HEAD", &update_data->suboid)) + die(_("Unable to find current revision in submodule path '%s'"), + update_data->displaypath); + } + if (!oideq(&update_data->oid, &update_data->suboid) || update_data->force) return do_run_update_procedure(update_data); diff --git a/git-submodule.sh b/git-submodule.sh index 652861aa66..d48c314f01 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -391,14 +391,9 @@ cmd_update() displaypath=$(git submodule--helper relative-path "$prefix$sm_path" "$wt_prefix") - if test $just_cloned -eq 1 + if test $just_cloned -eq 0 then - subsha1= - else just_cloned= - subsha1=$(sanitize_submodule_env; cd "$sm_path" && - git rev-parse --verify HEAD) || - die "fatal: $(eval_gettext "Unable to find current revision in submodule path '\$displaypath'")" fi if test -n "$remote" @@ -426,7 +421,6 @@ cmd_update() ${update:+--update "$update"} \ ${prefix:+--recursive-prefix "$prefix"} \ ${sha1:+--oid "$sha1"} \ - ${subsha1:+--suboid "$subsha1"} \ "--" \ "$sm_path") From patchwork Thu Feb 10 09:28:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12741608 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8230C433F5 for ; Thu, 10 Feb 2022 09:29:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238701AbiBJJ3c (ORCPT ); Thu, 10 Feb 2022 04:29:32 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238628AbiBJJ3S (ORCPT ); Thu, 10 Feb 2022 04:29:18 -0500 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E505110E for ; Thu, 10 Feb 2022 01:29:14 -0800 (PST) Received: by mail-pf1-x44a.google.com with SMTP id d5-20020a623605000000b004e01ccd08abso3971639pfa.10 for ; Thu, 10 Feb 2022 01:29:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=AIDjye1DDOnT7iBsdjGhA08VwNJHQSPMOfgmMBSCDP8=; b=O3RvFqCvr+EHzFYElBUqzmK1Ba0QEa82fs/evF7XgtxezSQ4JS/Ilsi4Hk0WXhsowM AAnSgfBOlyxrSJqeql38UatHlE68nPbqyVjScYjCVvaxVyVlg5gKBKftGLoiqVFLhWgF RrqS5hpdUsyN0lGdQJCcf4vlyAusiPau9yvjUaHynPTQAbVltbfqV1FyCafYUIsjqfy0 cWrn0KU+zsXEkhzcSWBycUmHZl3gKEUFXckVDGXW/NmHHv/lUHbMRXxBsb2UQ7/RqvTX VVSso+N7rrwWnAJnAsiaAd9vZ4BFzOI/6wvG4oWOpf9v7KJjt/aroghMA6ppaOk8noeY lxgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=AIDjye1DDOnT7iBsdjGhA08VwNJHQSPMOfgmMBSCDP8=; b=triy1WLvo5GAzJYr6zFxqKLUg4/pHzhVRU1Zz7JFgfkrWNyfDmoAwIrVpcoi1v2k53 75XMNcSG7I2BPOzceJiTZyYBaO1eAQQcdcg34pc5lk/DcgRMSE4UW1s4Ujtu7tywpa50 FIQ5ROBlxGZhZjTaAGTVJq2DhwRwv7CoFDvDr6wpEgNkq2lHBvqou209/jscUMSvomrE m33YTOq8Ox9RJ/R74CHaFsDt8Pk40zdX5FmgIV1ccnOrJCV2SBzDsmI3odOw0Fpe/3x2 nO/tICrgzsw+iYPlTkBZd/X4ksSlNU3en6PkBPCTDXoqXSAwSH5RtPnxDutcja4f6Brw UH4w== X-Gm-Message-State: AOAM532yVJUdVgQfOnAXX1IkK5m1M8Fd/NGMsOFbTBo47lniMadElYz8 Xod1yUwWuoerbswo3g/ebUkS/CIPzrZ7APwIefvK6qec8RqAMc/HOte77rQfvi4qB3z9jx2u4TO 9YdT0Jmru5434WyTk8Dy1l4T9C3W+pIMRzbdg6GuyWgIa0La2DTG0mgZOG27duI8= X-Google-Smtp-Source: ABdhPJxZuJ802/Zj/Y9d3QqZa2oCYfLSONBBptZ3vVT5d9GMHl6tRfHv3BwGranih2yJkrycCXFPWc0A+nJA9w== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a17:90b:1d88:: with SMTP id pf8mr1816948pjb.162.1644485353654; Thu, 10 Feb 2022 01:29:13 -0800 (PST) Date: Thu, 10 Feb 2022 17:28:25 +0800 In-Reply-To: <20220210092833.55360-1-chooglen@google.com> Message-Id: <20220210092833.55360-13-chooglen@google.com> Mime-Version: 1.0 References: <20220208083952.35036-1-chooglen@google.com> <20220210092833.55360-1-chooglen@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH v7 12/20] submodule--helper run-update-procedure: learn --remote From: Glen Choo To: git@vger.kernel.org Cc: Glen Choo , Junio C Hamano , Atharva Raykar , Christian Couder , Emily Shaffer , Jonathan Nieder , Kaartic Sivaraam , pc44800@gmail.com, Shourya Shukla , " =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= " Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Teach run-update-procedure to handle --remote instead of parsing --remote in git-submodule.sh. As a result, "git submodule--helper print-default-remote" has no more callers, so remove it. Signed-off-by: Glen Choo --- builtin/submodule--helper.c | 39 ++++++++++++++++++++++--------------- git-submodule.sh | 30 +--------------------------- 2 files changed, 24 insertions(+), 45 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index a26477ce04..15ae986692 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -71,21 +71,6 @@ static char *get_default_remote(void) return repo_get_default_remote(the_repository); } -static int print_default_remote(int argc, const char **argv, const char *prefix) -{ - char *remote; - - if (argc != 1) - die(_("submodule--helper print-default-remote takes no arguments")); - - remote = get_default_remote(); - if (remote) - printf("%s\n", remote); - - free(remote); - return 0; -} - static int starts_with_dot_slash(const char *str) { return str[0] == '.' && is_dir_sep(str[1]); @@ -2026,6 +2011,7 @@ struct update_data { unsigned int quiet; unsigned int nofetch; unsigned int just_cloned; + unsigned int remote; }; #define UPDATE_DATA_INIT { \ .update_strategy = SUBMODULE_UPDATE_STRATEGY_INIT, \ @@ -2585,6 +2571,8 @@ static int run_update_procedure(int argc, const char **argv, const char *prefix) OPT_CALLBACK_F(0, "oid", &opt.oid, N_("sha1"), N_("SHA1 expected by superproject"), PARSE_OPT_NONEG, parse_opt_object_id), + OPT_BOOL(0, "remote", &opt.remote, + N_("use SHA-1 of submodule's remote tracking branch")), OPT_END() }; @@ -2988,6 +2976,25 @@ static int update_submodule2(struct update_data *update_data) update_data->displaypath); } + if (update_data->remote) { + char *remote_name = get_default_remote_submodule(update_data->sm_path); + const char *branch = remote_submodule_branch(update_data->sm_path); + char *remote_ref = xstrfmt("refs/remotes/%s/%s", remote_name, branch); + + if (!update_data->nofetch) { + if (fetch_in_submodule(update_data->sm_path, update_data->depth, + 0, NULL)) + die(_("Unable to fetch in submodule path '%s'"), + update_data->sm_path); + } + + if (resolve_gitlink_ref(update_data->sm_path, remote_ref, &update_data->oid)) + die(_("Unable to find %s revision in submodule path '%s'"), + remote_ref, update_data->sm_path); + + free(remote_ref); + } + if (!oideq(&update_data->oid, &update_data->suboid) || update_data->force) return do_run_update_procedure(update_data); @@ -3389,10 +3396,10 @@ static struct cmd_struct commands[] = { {"foreach", module_foreach, SUPPORT_SUPER_PREFIX}, {"init", module_init, SUPPORT_SUPER_PREFIX}, {"status", module_status, SUPPORT_SUPER_PREFIX}, - {"print-default-remote", print_default_remote, 0}, {"sync", module_sync, SUPPORT_SUPER_PREFIX}, {"deinit", module_deinit, 0}, {"summary", module_summary, SUPPORT_SUPER_PREFIX}, + /* NEEDSWORK: remote-branch is also obsolete */ {"remote-branch", resolve_remote_submodule_branch, 0}, {"push-check", push_check, 0}, {"absorb-git-dirs", absorb_git_dirs, SUPPORT_SUPER_PREFIX}, diff --git a/git-submodule.sh b/git-submodule.sh index d48c314f01..29fd69250d 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -246,20 +246,6 @@ cmd_deinit() git ${wt_prefix:+-C "$wt_prefix"} submodule--helper deinit ${GIT_QUIET:+--quiet} ${force:+--force} ${deinit_all:+--all} -- "$@" } -# usage: fetch_in_submodule [] [] -# Because arguments are positional, use an empty string to omit -# but include . -fetch_in_submodule () ( - sanitize_submodule_env && - cd "$1" && - if test $# -eq 3 - then - echo "$3" | git fetch ${GIT_QUIET:+--quiet} --stdin ${2:+"$2"} - else - git fetch ${GIT_QUIET:+--quiet} ${2:+"$2"} - fi -) - # # Update each submodule path to correct revision, using clone and checkout as needed # @@ -396,21 +382,6 @@ cmd_update() just_cloned= fi - if test -n "$remote" - then - branch=$(git submodule--helper remote-branch "$sm_path") - if test -z "$nofetch" - then - # Fetch remote before determining tracking $sha1 - fetch_in_submodule "$sm_path" $depth || - die "fatal: $(eval_gettext "Unable to fetch in submodule path '\$sm_path'")" - fi - remote_name=$(sanitize_submodule_env; cd "$sm_path" && git submodule--helper print-default-remote) - sha1=$(sanitize_submodule_env; cd "$sm_path" && - git rev-parse --verify "${remote_name}/${branch}") || - die "fatal: $(eval_gettext "Unable to find current \${remote_name}/\${branch} revision in submodule path '\$sm_path'")" - fi - out=$(git submodule--helper run-update-procedure \ ${wt_prefix:+--prefix "$wt_prefix"} \ ${GIT_QUIET:+--quiet} \ @@ -421,6 +392,7 @@ cmd_update() ${update:+--update "$update"} \ ${prefix:+--recursive-prefix "$prefix"} \ ${sha1:+--oid "$sha1"} \ + ${remote:+--remote} \ "--" \ "$sm_path") From patchwork Thu Feb 10 09:28:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12741609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FDC9C433FE for ; Thu, 10 Feb 2022 09:29:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238564AbiBJJ3f (ORCPT ); Thu, 10 Feb 2022 04:29:35 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238653AbiBJJ3S (ORCPT ); Thu, 10 Feb 2022 04:29:18 -0500 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 600A11120 for ; Thu, 10 Feb 2022 01:29:16 -0800 (PST) Received: by mail-pl1-x649.google.com with SMTP id f9-20020a170902684900b0014cd6059ecdso1170758pln.7 for ; Thu, 10 Feb 2022 01:29:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=IQ/TmO04ivwY6jOcn7+5hzTvbedJJB/armLAxZ1CAiA=; b=lDL2XJHPZWB58mDLyrgrZprr9cQ8Ev8at+pfRuT6ANUHroJQ95shOGOcUw2luj7R3p T5ynFnNIgDyY4e3wASvqOx1J8ecON3f2qKDkalfIhRJN1YjguTIou33lviCCmMl2h7O0 n9P55ynOht4emSfDXczQArcDwNGmM79EbH0SB+PzQPmOhJDCKsi6SnGSpIHRZZPUW1/T k7H4iRAQ6IRcxcSkW3Dfl3Rx5ioKkOusOMjAzWzpoK/zd9g/qCebuUiJTArjNmiKTUGp yHkZqcB6szAD2X/1PFlJ58LHHb0IC0EezOrElxN0q4I01OdQ23FgY6FUXpstIlPPvI80 3D0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=IQ/TmO04ivwY6jOcn7+5hzTvbedJJB/armLAxZ1CAiA=; b=z3fRBPX303B8u8PggmVlfa8SQQyxkkv+AjhlHKXd+dW49NQhg4v4WwdgSbJy6BpsOV 8ykMqjzB0wpqjgO6mFdXn3cZW/Jd5it2qwQ40mo582sYN36Owvnabmjv4vVlkSc6SFxf hL6Pef4FwufDTKmArEsvpjgAPfNoNJ/Dq9rP6Xn3GWyzJCBsGGaI53p4C5a/mu5YUyaC iQyUVD1NnJiF5UgNrlL4IypInvEJE6j8ihlic73MY6av/DlYJzknO8pw5gwUt17Xtnyf qvcct0r6cD19YOLKJn52dXei9u66quxnwe7wy7LzTHQIxI0LMMQJDYCU8ot4//c2u85E KCnQ== X-Gm-Message-State: AOAM532OoL0j+srqFOHw/mQnZzrmivh9OSXnfedutW6LCZ3yC9zEbqKw 2i4WGHsaBb0YOsK7EfQmXGcVlGD46/RG33G/icDC83AsbLgtnsNHxvWyX4rstvobD7A7R/sNowa BZX9YNhl34FRqi9EMNSmc1e4+z91ETvhqFwAPpb7hGN2PO1p5JWFSpzFN754LLQg= X-Google-Smtp-Source: ABdhPJwK+VK7OP/KdxUsnDmSQ6ZPXqvhjoYvK3UKwzqaplyQTX1lceTHSyL9yLGVgJ/8r9JWDh5FFA8c/fsLkg== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a17:903:120e:: with SMTP id l14mr6661107plh.124.1644485355791; Thu, 10 Feb 2022 01:29:15 -0800 (PST) Date: Thu, 10 Feb 2022 17:28:26 +0800 In-Reply-To: <20220210092833.55360-1-chooglen@google.com> Message-Id: <20220210092833.55360-14-chooglen@google.com> Mime-Version: 1.0 References: <20220208083952.35036-1-chooglen@google.com> <20220210092833.55360-1-chooglen@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH v7 13/20] submodule--helper: remove ensure-core-worktree From: Glen Choo To: git@vger.kernel.org Cc: Glen Choo , Junio C Hamano , Atharva Raykar , Christian Couder , Emily Shaffer , Jonathan Nieder , Kaartic Sivaraam , pc44800@gmail.com, Shourya Shukla , " =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= " Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Move the logic of "git submodule--helper ensure-core-worktree" into run-update-procedure. Since the ensure-core-worktree command is obsolete, remove it. Signed-off-by: Glen Choo --- builtin/submodule--helper.c | 13 +++---------- git-submodule.sh | 2 -- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 15ae986692..a05aea5cd6 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2746,17 +2746,11 @@ static int push_check(int argc, const char **argv, const char *prefix) return 0; } -static int ensure_core_worktree(int argc, const char **argv, const char *prefix) +static void ensure_core_worktree(const char *path) { - const char *path; const char *cw; struct repository subrepo; - if (argc != 2) - BUG("submodule--helper ensure-core-worktree "); - - path = argv[1]; - if (repo_submodule_init(&subrepo, the_repository, path, null_oid())) die(_("could not get a repository handle for submodule '%s'"), path); @@ -2776,8 +2770,6 @@ static int ensure_core_worktree(int argc, const char **argv, const char *prefix) free(abs_path); strbuf_release(&sb); } - - return 0; } static int absorb_git_dirs(int argc, const char **argv, const char *prefix) @@ -2967,6 +2959,8 @@ static int module_set_branch(int argc, const char **argv, const char *prefix) /* NEEDSWORK: this is a temporary name until we delete update_submodule() */ static int update_submodule2(struct update_data *update_data) { + ensure_core_worktree(update_data->sm_path); + /* NEEDSWORK: fix the style issues e.g. braces */ if (update_data->just_cloned) { oidcpy(&update_data->suboid, null_oid()); @@ -3390,7 +3384,6 @@ static struct cmd_struct commands[] = { {"add", module_add, SUPPORT_SUPER_PREFIX}, {"update-clone", update_clone, 0}, {"run-update-procedure", run_update_procedure, 0}, - {"ensure-core-worktree", ensure_core_worktree, 0}, {"relative-path", resolve_relative_path, 0}, {"resolve-relative-url-test", resolve_relative_url_test, 0}, {"foreach", module_foreach, SUPPORT_SUPER_PREFIX}, diff --git a/git-submodule.sh b/git-submodule.sh index 29fd69250d..aa9c898e1c 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -373,8 +373,6 @@ cmd_update() do die_if_unmatched "$quickabort" "$sha1" - git submodule--helper ensure-core-worktree "$sm_path" || exit 1 - displaypath=$(git submodule--helper relative-path "$prefix$sm_path" "$wt_prefix") if test $just_cloned -eq 0 From patchwork Thu Feb 10 09:28:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12741610 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65D23C433FE for ; Thu, 10 Feb 2022 09:29:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238725AbiBJJ3g (ORCPT ); Thu, 10 Feb 2022 04:29:36 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238563AbiBJJ3S (ORCPT ); Thu, 10 Feb 2022 04:29:18 -0500 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1CE81131 for ; Thu, 10 Feb 2022 01:29:18 -0800 (PST) Received: by mail-pl1-x64a.google.com with SMTP id y3-20020a1709029b8300b0014c8bcb70a1so1174433plp.3 for ; Thu, 10 Feb 2022 01:29:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=eDE9N2lSSvdsSpnLVK+ske7kG+FpFoWcwLzUChjaM1g=; b=SoWpyRGSv8RVXU1gr0LZrom3F0GAGkVXpCOeCPPA/RCBeWimUPIPJOon3/Y5Ftc6OB 0dM9oROZWjKDTo45F5Kbz84tx16CNdPVATxYNprAH09gwBHRSqFUFCLTvTX588ghqNma RaLMhtxeMHNT14QMQ+VtszsI5BxLRBL1Owq4/BHKspzrRX0JMqijWZzdVmabceJZePFz j2HmCRkKpKIEujD82QoDYgK7NeTSXLWFwEcUJ3GPAhQ3+0zD/krMKMwkeSZOGwbVS+dI QAEIJYMucpbVNKQqbOjSoKmmfd+XdeljY5SbGGhJOi2j8byOl7b9SGMDf6d+CbQ97+Ka /ZsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=eDE9N2lSSvdsSpnLVK+ske7kG+FpFoWcwLzUChjaM1g=; b=MamgMofI5/X2gpjMQXQvvY4IqvWl4UdFU4aMt7PPmLyyMZ3nO4PcoedcPBTIpfO3qz 4UP/Xd0+zwroOc9Hm4T/tivMC7gKKvzTef3gPZ8HHL6bnP4ro9qWphWmI7brhvuoWpco R4+tvi/7S01JV3/hIufucn6zazNMbdQcBBzytzBXAu8GmIV4ksSrK/IKGsxq+PJEi3qw Pvfb6/G8jHJ589tIT8XkCZfc6sLml3j/wsPe01G3iZebphG0zOc2wjyLRvVqZaC0Sky4 UnC+bXHVKUOHUKQuDYJn/W9sBgzNDrkRA52jfSeyqVlFtwhZ4/943TZSuXv7lXYNwccN tlvw== X-Gm-Message-State: AOAM533RRxWoPuTvA5Cd1qTUDqSqEqPw7EfRz/Gd+/EFge1jW01WQVXC Nmqdz0XqXofkFAV0NGp4Vq8KkKcB9xtAX8LvKMYoW/Fdb8MrWDAHtZ2G93U0H3hRJ2bN6n9TIYH v/B+AtpxxxuX+IB3AISfSLJOktu58yQ9QfJYJfBQaybyq22ZuWfutNXUbySn4Da0= X-Google-Smtp-Source: ABdhPJxYD74gOcnvmuQJxMkIAt2wBzFxc8LMQNrriU5ooLNE69V7KA57IgoRrUtW7P28upfseUiF3/KN2vqP0A== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a17:90a:4291:: with SMTP id p17mr1813198pjg.126.1644485357980; Thu, 10 Feb 2022 01:29:17 -0800 (PST) Date: Thu, 10 Feb 2022 17:28:27 +0800 In-Reply-To: <20220210092833.55360-1-chooglen@google.com> Message-Id: <20220210092833.55360-15-chooglen@google.com> Mime-Version: 1.0 References: <20220208083952.35036-1-chooglen@google.com> <20220210092833.55360-1-chooglen@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH v7 14/20] submodule--helper update-clone: learn --init From: Glen Choo To: git@vger.kernel.org Cc: Glen Choo , Junio C Hamano , Atharva Raykar , Christian Couder , Emily Shaffer , Jonathan Nieder , Kaartic Sivaraam , pc44800@gmail.com, Shourya Shukla , " =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= " Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Teach "git submodule--helper update-clone" the --init flag and remove the corresponding shell code. When the `--init` flag is passed to the subcommand, we do not spawn a new subprocess and call `submodule--helper init` on the submodule paths, because the Git machinery is not able to pick up the configuration changes introduced by that init call. So we instead run the `init_submodule_cb()` callback over each submodule in the same process. [1] https://lore.kernel.org/git/CAP8UFD0NCQ5w_3GtT_xHr35i7h8BuLX4UcHNY6VHPGREmDVObA@mail.gmail.com/ Signed-off-by: Glen Choo --- builtin/submodule--helper.c | 26 ++++++++++++++++++++++++++ git-submodule.sh | 9 +++------ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index a05aea5cd6..5635f0c48b 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1989,6 +1989,7 @@ struct submodule_update_clone { int failed_clones_nr, failed_clones_alloc; int max_jobs; + unsigned int init; }; #define SUBMODULE_UPDATE_CLONE_INIT { \ .list = MODULE_LIST_INIT, \ @@ -2483,6 +2484,8 @@ static int update_clone(int argc, const char **argv, const char *prefix) struct submodule_update_clone opt = SUBMODULE_UPDATE_CLONE_INIT; struct option module_update_clone_options[] = { + OPT_BOOL(0, "init", &opt.init, + N_("initialize uninitialized submodules before update")), OPT_STRING(0, "prefix", &prefix, N_("path"), N_("path into the working tree")), @@ -2536,6 +2539,29 @@ static int update_clone(int argc, const char **argv, const char *prefix) if (pathspec.nr) opt.warn_if_uninitialized = 1; + if (opt.init) { + struct module_list list = MODULE_LIST_INIT; + struct init_cb info = INIT_CB_INIT; + + if (module_list_compute(argc, argv, opt.prefix, + &pathspec, &list) < 0) + return 1; + + /* + * If there are no path args and submodule.active is set then, + * by default, only initialize 'active' modules. + */ + if (!argc && git_config_get_value_multi("submodule.active")) + module_list_active(&list); + + info.prefix = opt.prefix; + info.superprefix = opt.recursive_prefix; + if (opt.quiet) + info.flags |= OPT_QUIET; + + for_each_listed_submodule(&list, init_submodule_cb, &info); + } + return update_submodules(&opt); } diff --git a/git-submodule.sh b/git-submodule.sh index aa9c898e1c..3ccf2388bf 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -347,14 +347,11 @@ cmd_update() shift done - if test -n "$init" - then - cmd_init "--" "$@" || return - fi - { - git submodule--helper update-clone ${GIT_QUIET:+--quiet} \ + git ${wt_prefix:+-C "$wt_prefix"} submodule--helper update-clone \ + ${GIT_QUIET:+--quiet} \ ${progress:+"--progress"} \ + ${init:+--init} \ ${wt_prefix:+--prefix "$wt_prefix"} \ ${prefix:+--recursive-prefix "$prefix"} \ ${update:+--update "$update"} \ From patchwork Thu Feb 10 09:28:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12741611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0049C433F5 for ; Thu, 10 Feb 2022 09:29:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238614AbiBJJ3r (ORCPT ); Thu, 10 Feb 2022 04:29:47 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238671AbiBJJ3U (ORCPT ); Thu, 10 Feb 2022 04:29:20 -0500 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F3B0D98 for ; Thu, 10 Feb 2022 01:29:21 -0800 (PST) Received: by mail-pj1-x1049.google.com with SMTP id z12-20020a17090a1fcc00b001b63e477f9fso3562704pjz.3 for ; Thu, 10 Feb 2022 01:29:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=r/KojfLz2J5XeB+gTn2pB7l9rfA/WZU4hc79VKle4yc=; b=kSE3SxoKqByXjnjA254Pd+/t/7STxwfhK6R1VeEd3FpuycaBzQiPu9PGW0vOEcuFy4 zhksIXdVaQv+If/0jPPJW/nIK/eAg+BTByBQrn8VeKp7HSaKpa1krqjmDmUoXQXIVmV8 iY/nIgI3T8hIr0Uv7cuB/5wFxnQrLpQ9OTkeK1x5AucAE4wCUKmwH88k/hQpiEghNBEe PhiNIL0+fH7xZtG5SXCpYCmX8+SK4pHcYUq1bxHb0XO7AuzmS0JJpdnSvXkzF73BvSNy POC4DVrRCHqI/p4MMIMRPlowPEdifSeEpZBMR0fSR1a5mvi8yMSuG2s42EllfqqSQs7w qocg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=r/KojfLz2J5XeB+gTn2pB7l9rfA/WZU4hc79VKle4yc=; b=YGzaNxRMyuTNrNdyWEZcln/IqskSIDVY0iGCf3vT0jy2VZWJRrBfyCY6q0mZTt4eoh WODXm/JXQ77wLcFI7P3k+vYjB8C1eAeU+MqBC3aO65OMXyKEGuTMM3Bjtvdjt2vMUFbf TsdSkVXMq17GZobj929gXpGhohO+HIHWZBUhysdqvEHsOcMYtU14xHTqEH8WKLBjcPPQ oSDp7cya176RI3aB/iK6/WdZga5G7vX2meq5oMlT04v+1L3aXAZKDDllG76hSoPFpTKq LwojpXdpZtIPK+Zjo8Km7yn5ihMOWZ9yFVXmGc07a7SznYW5jIuUWFdP7j6xRc8LlY8W YDqA== X-Gm-Message-State: AOAM532wkPsfVifqGDMn8aJJYDm3VjbLnMw3tOgCPCqxD5vbFMZpoo6k CRNkB2CuqFmx8mVvuMYPUHf+M9Fu97OC80wQaLn4CYbjMR0CsxQUp9W53Pv14kugnJFEE+UrpeW ftM1BkFEkOMpDyQOAq8G51o7uMGWuRkM3FEp79ilZvqnJr6y3N1lC2uisk2P5Zqc= X-Google-Smtp-Source: ABdhPJwvpd5sDsbkDi1sHkVEqmohuvbinJgbwtaCV26mtp/1c3wI8So3BVYf8d+hL+Me1+3HnrqVW5gLCjmMNg== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a17:90a:e40f:: with SMTP id hv15mr318874pjb.1.1644485360183; Thu, 10 Feb 2022 01:29:20 -0800 (PST) Date: Thu, 10 Feb 2022 17:28:28 +0800 In-Reply-To: <20220210092833.55360-1-chooglen@google.com> Message-Id: <20220210092833.55360-16-chooglen@google.com> Mime-Version: 1.0 References: <20220208083952.35036-1-chooglen@google.com> <20220210092833.55360-1-chooglen@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH v7 15/20] submodule--helper: move functions around From: Glen Choo To: git@vger.kernel.org Cc: Glen Choo , Junio C Hamano , Atharva Raykar , Christian Couder , Emily Shaffer , Jonathan Nieder , Kaartic Sivaraam , pc44800@gmail.com, Shourya Shukla , " =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= " Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org A subsequent commit will change the internals of several functions and arrange them in a more logical manner. Move these functions to their final positions so that the diff is smaller. Signed-off-by: Glen Choo --- builtin/submodule--helper.c | 228 ++++++++++++++++++------------------ 1 file changed, 114 insertions(+), 114 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 5635f0c48b..0ab8f9d49f 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2451,120 +2451,6 @@ static void update_submodule(struct update_clone_data *ucd) ucd->sub->path); } -static int update_submodules(struct submodule_update_clone *suc) -{ - int i; - - run_processes_parallel_tr2(suc->max_jobs, update_clone_get_next_task, - update_clone_start_failure, - update_clone_task_finished, suc, "submodule", - "parallel/update"); - - /* - * We saved the output and put it out all at once now. - * That means: - * - the listener does not have to interleave their (checkout) - * work with our fetching. The writes involved in a - * checkout involve more straightforward sequential I/O. - * - the listener can avoid doing any work if fetching failed. - */ - if (suc->quickstop) - return 1; - - for (i = 0; i < suc->update_clone_nr; i++) - update_submodule(&suc->update_clone[i]); - - return 0; -} - -static int update_clone(int argc, const char **argv, const char *prefix) -{ - const char *update = NULL; - struct pathspec pathspec; - struct submodule_update_clone opt = SUBMODULE_UPDATE_CLONE_INIT; - - struct option module_update_clone_options[] = { - OPT_BOOL(0, "init", &opt.init, - N_("initialize uninitialized submodules before update")), - OPT_STRING(0, "prefix", &prefix, - N_("path"), - N_("path into the working tree")), - OPT_STRING(0, "recursive-prefix", &opt.recursive_prefix, - N_("path"), - N_("path into the working tree, across nested " - "submodule boundaries")), - OPT_STRING(0, "update", &update, - N_("string"), - N_("rebase, merge, checkout or none")), - OPT_STRING_LIST(0, "reference", &opt.references, N_("repo"), - N_("reference repository")), - OPT_BOOL(0, "dissociate", &opt.dissociate, - N_("use --reference only while cloning")), - OPT_STRING(0, "depth", &opt.depth, "", - N_("create a shallow clone truncated to the " - "specified number of revisions")), - OPT_INTEGER('j', "jobs", &opt.max_jobs, - N_("parallel jobs")), - OPT_BOOL(0, "recommend-shallow", &opt.recommend_shallow, - N_("whether the initial clone should follow the shallow recommendation")), - OPT__QUIET(&opt.quiet, N_("don't print cloning progress")), - OPT_BOOL(0, "progress", &opt.progress, - N_("force cloning progress")), - OPT_BOOL(0, "require-init", &opt.require_init, - N_("disallow cloning into non-empty directory")), - OPT_BOOL(0, "single-branch", &opt.single_branch, - N_("clone only one branch, HEAD or --branch")), - OPT_END() - }; - - const char *const git_submodule_helper_usage[] = { - N_("git submodule--helper update-clone [--prefix=] [...]"), - NULL - }; - opt.prefix = prefix; - - update_clone_config_from_gitmodules(&opt.max_jobs); - git_config(git_update_clone_config, &opt.max_jobs); - - argc = parse_options(argc, argv, prefix, module_update_clone_options, - git_submodule_helper_usage, 0); - - if (update) - if (parse_submodule_update_strategy(update, &opt.update) < 0) - die(_("bad value for update parameter")); - - if (module_list_compute(argc, argv, prefix, &pathspec, &opt.list) < 0) - return 1; - - if (pathspec.nr) - opt.warn_if_uninitialized = 1; - - if (opt.init) { - struct module_list list = MODULE_LIST_INIT; - struct init_cb info = INIT_CB_INIT; - - if (module_list_compute(argc, argv, opt.prefix, - &pathspec, &list) < 0) - return 1; - - /* - * If there are no path args and submodule.active is set then, - * by default, only initialize 'active' modules. - */ - if (!argc && git_config_get_value_multi("submodule.active")) - module_list_active(&list); - - info.prefix = opt.prefix; - info.superprefix = opt.recursive_prefix; - if (opt.quiet) - info.flags |= OPT_QUIET; - - for_each_listed_submodule(&list, init_submodule_cb, &info); - } - - return update_submodules(&opt); -} - /* * NEEDSWORK: Use a forward declaration to avoid moving * run_update_procedure() (which will be removed soon). @@ -3021,6 +2907,120 @@ static int update_submodule2(struct update_data *update_data) return 3; } +static int update_submodules(struct submodule_update_clone *suc) +{ + int i; + + run_processes_parallel_tr2(suc->max_jobs, update_clone_get_next_task, + update_clone_start_failure, + update_clone_task_finished, suc, "submodule", + "parallel/update"); + + /* + * We saved the output and put it out all at once now. + * That means: + * - the listener does not have to interleave their (checkout) + * work with our fetching. The writes involved in a + * checkout involve more straightforward sequential I/O. + * - the listener can avoid doing any work if fetching failed. + */ + if (suc->quickstop) + return 1; + + for (i = 0; i < suc->update_clone_nr; i++) + update_submodule(&suc->update_clone[i]); + + return 0; +} + +static int update_clone(int argc, const char **argv, const char *prefix) +{ + const char *update = NULL; + struct pathspec pathspec; + struct submodule_update_clone opt = SUBMODULE_UPDATE_CLONE_INIT; + + struct option module_update_clone_options[] = { + OPT_BOOL(0, "init", &opt.init, + N_("initialize uninitialized submodules before update")), + OPT_STRING(0, "prefix", &prefix, + N_("path"), + N_("path into the working tree")), + OPT_STRING(0, "recursive-prefix", &opt.recursive_prefix, + N_("path"), + N_("path into the working tree, across nested " + "submodule boundaries")), + OPT_STRING(0, "update", &update, + N_("string"), + N_("rebase, merge, checkout or none")), + OPT_STRING_LIST(0, "reference", &opt.references, N_("repo"), + N_("reference repository")), + OPT_BOOL(0, "dissociate", &opt.dissociate, + N_("use --reference only while cloning")), + OPT_STRING(0, "depth", &opt.depth, "", + N_("create a shallow clone truncated to the " + "specified number of revisions")), + OPT_INTEGER('j', "jobs", &opt.max_jobs, + N_("parallel jobs")), + OPT_BOOL(0, "recommend-shallow", &opt.recommend_shallow, + N_("whether the initial clone should follow the shallow recommendation")), + OPT__QUIET(&opt.quiet, N_("don't print cloning progress")), + OPT_BOOL(0, "progress", &opt.progress, + N_("force cloning progress")), + OPT_BOOL(0, "require-init", &opt.require_init, + N_("disallow cloning into non-empty directory")), + OPT_BOOL(0, "single-branch", &opt.single_branch, + N_("clone only one branch, HEAD or --branch")), + OPT_END() + }; + + const char *const git_submodule_helper_usage[] = { + N_("git submodule--helper update-clone [--prefix=] [...]"), + NULL + }; + opt.prefix = prefix; + + update_clone_config_from_gitmodules(&opt.max_jobs); + git_config(git_update_clone_config, &opt.max_jobs); + + argc = parse_options(argc, argv, prefix, module_update_clone_options, + git_submodule_helper_usage, 0); + + if (update) + if (parse_submodule_update_strategy(update, &opt.update) < 0) + die(_("bad value for update parameter")); + + if (module_list_compute(argc, argv, prefix, &pathspec, &opt.list) < 0) + return 1; + + if (pathspec.nr) + opt.warn_if_uninitialized = 1; + + if (opt.init) { + struct module_list list = MODULE_LIST_INIT; + struct init_cb info = INIT_CB_INIT; + + if (module_list_compute(argc, argv, opt.prefix, + &pathspec, &list) < 0) + return 1; + + /* + * If there are no path args and submodule.active is set then, + * by default, only initialize 'active' modules. + */ + if (!argc && git_config_get_value_multi("submodule.active")) + module_list_active(&list); + + info.prefix = opt.prefix; + info.superprefix = opt.recursive_prefix; + if (opt.quiet) + info.flags |= OPT_QUIET; + + for_each_listed_submodule(&list, init_submodule_cb, &info); + } + + return update_submodules(&opt); +} + struct add_data { const char *prefix; const char *branch; From patchwork Thu Feb 10 09:28:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12741612 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CC79C433EF for ; Thu, 10 Feb 2022 09:29:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238588AbiBJJ3s (ORCPT ); Thu, 10 Feb 2022 04:29:48 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238507AbiBJJ3W (ORCPT ); Thu, 10 Feb 2022 04:29:22 -0500 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EAE510B9 for ; Thu, 10 Feb 2022 01:29:23 -0800 (PST) Received: by mail-pf1-x44a.google.com with SMTP id m6-20020a056a00080600b004e06140d481so2336914pfk.9 for ; Thu, 10 Feb 2022 01:29:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=LTQppUaG6czFzYFgMJ1+lhXCVOnbg0TheoPSy/3IWaQ=; b=XWjc4zqa/FQqNnXMUp+8YsLymIe0liaDINK+41mPYzb+Rddot17NL4PWdpsXx5h97O SurqzQnvYFlQXts15T5QTqaV/wCL5eKCb/Rrapw70y3OYP5cJyN2P2q4s4IQqO0BV5Pt ji25iVRBm8e2emQNni8ke1u9A8Io5BPHp/aB5Yx0MBjDCJjXKDzJLPNNDq4urLH29ky3 PMcfdVu3EYRvCBK9qTxBJQLjKl0YVUHflqJIE3ORuJaW0EJ/9MFm57hPyUlyYjcG3TEU 2zbKKpsQUm3F5dIgpamwDz74zEZHvOFJAofMT73AvcT2rUhEjTfUUlGFR4XpDf09f1cz Igfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=LTQppUaG6czFzYFgMJ1+lhXCVOnbg0TheoPSy/3IWaQ=; b=RElf1HV6W9nfXugruJf5yapSEzP5L7zUzfz1slAja9hAk/1QyJ7boozPdKfbEUEt7+ SHv/6kakKJth+JyIXUDyBFIrEBvTb0Zq6AoHgPOHzq8wZxVWafpnEVTyoAaaThCJ3Cxm qQeVYVUDabdOiZgjGNaNYfu8/Bp5/BEWbuAdk7sZO6bZPotfHzZW5s8+O8pgZu2buJRp BN4OqieKSYQQHZ9wvulAB9cR9kzV9WLDiB0A9ppV0fCouwj9rL25Q3TirC7b6H1DJUQJ 1YSUbkbY2xPfnqWARX7R3uDHhZngc3EWLqAW779jaPU6NlP/uTD1/3Oxq7mrs8rt8KYT G2rw== X-Gm-Message-State: AOAM5309jJ/+3Tv+uAejO4FLLgDzj6piXcRjGmvWx7hX7sKj065Nvg3b D9n4G9cHwQHYCw7x3hEIQuv5435lkIWF4uEcCH1TU8tbm6FBcUm2bKNMWcBo7voCSbiu5/IeyKa tcHPAFlKgivDojmsN0sjqYWvbw+X89sIso+rwSrv9cYR2chxhKI2b8zlUwOMFM4U= X-Google-Smtp-Source: ABdhPJyQ4G73qX5c6LHvvHAiHYR1tRTId4QKDSbHFWx0Zf+rm2bOvcknBIn6DISkwrdaMDV5glVoFyK3RUXLQA== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a17:902:d2ca:: with SMTP id n10mr6681474plc.28.1644485362662; Thu, 10 Feb 2022 01:29:22 -0800 (PST) Date: Thu, 10 Feb 2022 17:28:29 +0800 In-Reply-To: <20220210092833.55360-1-chooglen@google.com> Message-Id: <20220210092833.55360-17-chooglen@google.com> Mime-Version: 1.0 References: <20220208083952.35036-1-chooglen@google.com> <20220210092833.55360-1-chooglen@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH v7 16/20] submodule--helper: reduce logic in run_update_procedure() From: Glen Choo To: git@vger.kernel.org Cc: Glen Choo , Junio C Hamano , Atharva Raykar , Christian Couder , Emily Shaffer , Jonathan Nieder , Kaartic Sivaraam , pc44800@gmail.com, Shourya Shukla , " =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= " Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org A later commit will combine the "update-clone" and "run-update-procedure" commands, so run_update_procedure() will be removed. Prepare for this by moving as much logic as possible out of run_update_procedure() and into update_submodule2(). Signed-off-by: Glen Choo --- builtin/submodule--helper.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 0ab8f9d49f..ff7ee73e1a 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2001,9 +2001,11 @@ struct submodule_update_clone { } struct update_data { + const char *prefix; const char *recursive_prefix; const char *sm_path; const char *displaypath; + const char *update_default; struct object_id oid; struct object_id suboid; struct submodule_update_strategy update_strategy; @@ -2458,7 +2460,6 @@ static void update_submodule(struct update_clone_data *ucd) static int update_submodule2(struct update_data *update_data); static int run_update_procedure(int argc, const char **argv, const char *prefix) { - char *prefixed_path, *update = NULL; struct update_data opt = UPDATE_DATA_INIT; struct option options[] = { @@ -2471,10 +2472,10 @@ static int run_update_procedure(int argc, const char **argv, const char *prefix) OPT_BOOL(0, "just-cloned", &opt.just_cloned, N_("overrides update mode in case the repository is a fresh clone")), OPT_INTEGER(0, "depth", &opt.depth, N_("depth for shallow fetch")), - OPT_STRING(0, "prefix", &prefix, + OPT_STRING(0, "prefix", &opt.prefix, N_("path"), N_("path into the working tree")), - OPT_STRING(0, "update", &update, + OPT_STRING(0, "update", &opt.update_default, N_("string"), N_("rebase, merge, checkout or none")), OPT_STRING(0, "recursive-prefix", &opt.recursive_prefix, N_("path"), @@ -2500,18 +2501,6 @@ static int run_update_procedure(int argc, const char **argv, const char *prefix) opt.sm_path = argv[0]; - if (opt.recursive_prefix) - prefixed_path = xstrfmt("%s%s", opt.recursive_prefix, opt.sm_path); - else - prefixed_path = xstrdup(opt.sm_path); - - opt.displaypath = get_submodule_displaypath(prefixed_path, prefix); - - determine_submodule_update_strategy(the_repository, opt.just_cloned, - opt.sm_path, update, - &opt.update_strategy); - - free(prefixed_path); return update_submodule2(&opt); } @@ -2871,8 +2860,24 @@ static int module_set_branch(int argc, const char **argv, const char *prefix) /* NEEDSWORK: this is a temporary name until we delete update_submodule() */ static int update_submodule2(struct update_data *update_data) { + char *prefixed_path; + ensure_core_worktree(update_data->sm_path); + if (update_data->recursive_prefix) + prefixed_path = xstrfmt("%s%s", update_data->recursive_prefix, + update_data->sm_path); + else + prefixed_path = xstrdup(update_data->sm_path); + + update_data->displaypath = get_submodule_displaypath(prefixed_path, + update_data->prefix); + free(prefixed_path); + + determine_submodule_update_strategy(the_repository, update_data->just_cloned, + update_data->sm_path, update_data->update_default, + &update_data->update_strategy); + /* NEEDSWORK: fix the style issues e.g. braces */ if (update_data->just_cloned) { oidcpy(&update_data->suboid, null_oid()); From patchwork Thu Feb 10 09:28:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12741613 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DB1EC433EF for ; Thu, 10 Feb 2022 09:29:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238675AbiBJJ3u (ORCPT ); Thu, 10 Feb 2022 04:29:50 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238577AbiBJJ30 (ORCPT ); Thu, 10 Feb 2022 04:29:26 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B003E10D8 for ; Thu, 10 Feb 2022 01:29:25 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id t8-20020a259ac8000000b00619a3b5977fso10924691ybo.5 for ; Thu, 10 Feb 2022 01:29:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc:content-transfer-encoding; bh=GYZji1wInO0NZO6UezqSy7QAaxGLjwdHNA4vsYNZUnw=; b=d9Ym2pe3az71obFe/NHTqNckv0bXeqJLVjeKJHJPu7aQ3dJIDeLKQkoQnPgQGbMbr5 avMKF6uWFx/RGoempaJj7oQsIkdvbHdimiqmYnhQH/iNrKWzKECE2TXQiHfCGkaXvzNS AgjD4Du+6qnyV4dWw3FGRme0dMxHRApmZGD2fRJ7BUsYcq/GxfHCGULfQyPWe58mH0AL hoBNeem/PWRj61LZyhdvSzXHR9CG9edsyuEpcy3K9jY/keaX4jVZRvz7KZKEMswm0sgl YvXdaXZYe4lInNIWUcdJne+V6K0/aih/iwycP5jsHYL91NAEK58rdZqsoYKZtS+yGIXR FxQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=GYZji1wInO0NZO6UezqSy7QAaxGLjwdHNA4vsYNZUnw=; b=yoU0Zr/N1ANLVYPHXroR0XCEsslFElu9RuBXK6mYLitxLD3flOsCwm61dffJHN7EK2 pDygXCZbrkXYcZU10piwOUcXJQw5gf9HOtP9xpcZHczD6o+6UKYCknZ4vgh4K8uFJlsk rcB9wCSfg0ZKiwaUum6FqVorRKmosvzjfQuTMfL0ovVDBbItuv2zfcXqb/SNg3Ajkdho 4oS9PnZtR8srxHEbB54NLboC7wA83vwfkmLTvcfO6enKGTiAP7oDg9PP98eTPsfhh7gn M/2V+IOVR0wI2XlY3zodT+RW/foWi5yIvn7d178Xdsfi1SzRkmLohBLASkl+kHn4dEGd a2WQ== X-Gm-Message-State: AOAM532O+7ryPmn5vgCm5vlS+Had7wJpIo/q9BZ3y2rf94fdYZJdgm4F 0vMguJ8VczxNYZTGyCwIPNLofumNlADcUNqMLCMh85zV6aCl7gNIoYzR+YnQJ12yXFo+5B5Qfxq D5mkxg8mjsqHHMMsXVlBOgSMsaSxAfJqx+ql/HPGbaWzwC/RZzGP3wyI62xPWNiw= X-Google-Smtp-Source: ABdhPJzgb0o/zgAwmSp5wWxjvcc25vyDFKhEdRJDwgARxOUOuWmXr8zw67apTKL6CRJZ0czoHxM5igyZWDatrw== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a81:a888:: with SMTP id f130mr6385732ywh.46.1644485364877; Thu, 10 Feb 2022 01:29:24 -0800 (PST) Date: Thu, 10 Feb 2022 17:28:30 +0800 In-Reply-To: <20220210092833.55360-1-chooglen@google.com> Message-Id: <20220210092833.55360-18-chooglen@google.com> Mime-Version: 1.0 References: <20220208083952.35036-1-chooglen@google.com> <20220210092833.55360-1-chooglen@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH v7 17/20] submodule: move core cmd_update() logic to C From: Glen Choo To: git@vger.kernel.org Cc: Glen Choo , Junio C Hamano , Atharva Raykar , Christian Couder , Emily Shaffer , Jonathan Nieder , Kaartic Sivaraam , pc44800@gmail.com, Shourya Shukla , " =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= " Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Atharva Raykar This patch completes the conversion past the flag parsing of `submodule update` by introducing a helper subcommand called `submodule--helper update`. The behaviour of `submodule update` should remain the same after this patch. We add more fields to the `struct update_data` that are required by `struct submodule_update_clone` to be able to perform a clone, when that is needed to be done. Recursing on a submodule is done by calling a subprocess that launches `submodule--helper update`, with a modified `--recursive-prefix` and `--prefix` parameter. Mentored-by: Christian Couder Mentored-by: Shourya Shukla Signed-off-by: Atharva Raykar Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano Signed-off-by: Glen Choo --- builtin/submodule--helper.c | 312 ++++++++++++++++++++++-------------- git-submodule.sh | 105 ++---------- 2 files changed, 201 insertions(+), 216 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index ff7ee73e1a..b895e88a64 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1977,7 +1977,6 @@ struct submodule_update_clone { const char *prefix; int single_branch; - /* to be consumed by git-submodule.sh */ struct update_clone_data *update_clone; int update_clone_nr; int update_clone_alloc; @@ -1989,7 +1988,6 @@ struct submodule_update_clone { int failed_clones_nr, failed_clones_alloc; int max_jobs; - unsigned int init; }; #define SUBMODULE_UPDATE_CLONE_INIT { \ .list = MODULE_LIST_INIT, \ @@ -2010,14 +2008,54 @@ struct update_data { struct object_id suboid; struct submodule_update_strategy update_strategy; int depth; + int recommend_shallow; + int single_branch; + int max_jobs; + unsigned int init; unsigned int force; unsigned int quiet; unsigned int nofetch; unsigned int just_cloned; unsigned int remote; + unsigned int recursive; + unsigned int progress; + unsigned int dissociate; + unsigned int require_init; + unsigned warn_if_uninitialized ; + struct string_list references; + struct module_list list; }; #define UPDATE_DATA_INIT { \ + .list = MODULE_LIST_INIT, \ .update_strategy = SUBMODULE_UPDATE_STRATEGY_INIT, \ + .recommend_shallow = -1, \ + .references = STRING_LIST_INIT_DUP, \ + .single_branch = -1, \ + .max_jobs = 1, \ +} + +static void update_clone_from_update_data(struct submodule_update_clone *suc, + struct update_data *update_data) +{ + suc->prefix = update_data->prefix; + suc->recursive_prefix = update_data->recursive_prefix; + suc->max_jobs = update_data->max_jobs; + suc->progress = update_data->progress; + suc->quiet = update_data->quiet; + suc->dissociate = update_data->dissociate; + suc->require_init = update_data->require_init; + suc->single_branch = update_data->single_branch; + suc->warn_if_uninitialized = update_data->warn_if_uninitialized; + suc->list = update_data->list; + suc->update = update_data->update_strategy; + suc->recommend_shallow = update_data->recommend_shallow; + if (update_data->depth) + suc->depth = xstrfmt("--depth=%d", update_data->depth); + if (update_data->references.nr) { + struct string_list_item *item; + for_each_string_list_item(item, &update_data->references) + string_list_append(&suc->references, item->string); + } } static void next_submodule_warn_missing(struct submodule_update_clone *suc, @@ -2356,40 +2394,35 @@ static int run_update_command(struct update_data *ud, int subforce) if (run_command(&cp)) { switch (ud->update_strategy.type) { case SM_UPDATE_CHECKOUT: - printf(_("Unable to checkout '%s' in submodule path '%s'"), - oid, ud->displaypath); + die_message(_("Unable to checkout '%s' in submodule path '%s'"), + oid, ud->displaypath); break; case SM_UPDATE_REBASE: - printf(_("Unable to rebase '%s' in submodule path '%s'"), - oid, ud->displaypath); + die_message(_("Unable to rebase '%s' in submodule path '%s'"), + oid, ud->displaypath); break; case SM_UPDATE_MERGE: - printf(_("Unable to merge '%s' in submodule path '%s'"), - oid, ud->displaypath); + die_message(_("Unable to merge '%s' in submodule path '%s'"), + oid, ud->displaypath); break; case SM_UPDATE_COMMAND: - printf(_("Execution of '%s %s' failed in submodule path '%s'"), - ud->update_strategy.command, oid, ud->displaypath); + die_message(_("Execution of '%s %s' failed in submodule path '%s'"), + ud->update_strategy.command, oid, ud->displaypath); break; default: BUG("unexpected update strategy type: %s", submodule_strategy_to_string(&ud->update_strategy)); } - /* - * NEEDSWORK: We are currently printing to stdout with error - * return so that the shell caller handles the error output - * properly. Once we start handling the error messages within - * C, we should use die() instead. - */ if (must_die_on_failure) - return 2; - /* - * This signifies to the caller in shell that the command - * failed without dying - */ + exit(128); + + /* the command failed, but update must continue */ return 1; } + if (ud->quiet) + return 0; + switch (ud->update_strategy.type) { case SM_UPDATE_CHECKOUT: printf(_("Submodule path '%s': checked out '%s'\n"), @@ -2415,7 +2448,7 @@ static int run_update_command(struct update_data *ud, int subforce) return 0; } -static int do_run_update_procedure(struct update_data *ud) +static int run_update_procedure(struct update_data *ud) { int subforce = is_null_oid(&ud->suboid) || ud->force; @@ -2445,76 +2478,6 @@ static int do_run_update_procedure(struct update_data *ud) return run_update_command(ud, subforce); } -static void update_submodule(struct update_clone_data *ucd) -{ - fprintf(stdout, "dummy %s %d\t%s\n", - oid_to_hex(&ucd->oid), - ucd->just_cloned, - ucd->sub->path); -} - -/* - * NEEDSWORK: Use a forward declaration to avoid moving - * run_update_procedure() (which will be removed soon). - */ -static int update_submodule2(struct update_data *update_data); -static int run_update_procedure(int argc, const char **argv, const char *prefix) -{ - struct update_data opt = UPDATE_DATA_INIT; - - struct option options[] = { - OPT__QUIET(&opt.quiet, - N_("suppress output for update by rebase or merge")), - OPT__FORCE(&opt.force, N_("force checkout updates"), - 0), - OPT_BOOL('N', "no-fetch", &opt.nofetch, - N_("don't fetch new objects from the remote site")), - OPT_BOOL(0, "just-cloned", &opt.just_cloned, - N_("overrides update mode in case the repository is a fresh clone")), - OPT_INTEGER(0, "depth", &opt.depth, N_("depth for shallow fetch")), - OPT_STRING(0, "prefix", &opt.prefix, - N_("path"), - N_("path into the working tree")), - OPT_STRING(0, "update", &opt.update_default, - N_("string"), - N_("rebase, merge, checkout or none")), - OPT_STRING(0, "recursive-prefix", &opt.recursive_prefix, N_("path"), - N_("path into the working tree, across nested " - "submodule boundaries")), - OPT_CALLBACK_F(0, "oid", &opt.oid, N_("sha1"), - N_("SHA1 expected by superproject"), PARSE_OPT_NONEG, - parse_opt_object_id), - OPT_BOOL(0, "remote", &opt.remote, - N_("use SHA-1 of submodule's remote tracking branch")), - OPT_END() - }; - - const char *const usage[] = { - N_("git submodule--helper run-update-procedure [] "), - NULL - }; - - argc = parse_options(argc, argv, prefix, options, usage, 0); - - if (argc != 1) - usage_with_options(usage, options); - - opt.sm_path = argv[0]; - - return update_submodule2(&opt); -} - -static int resolve_relative_path(int argc, const char **argv, const char *prefix) -{ - struct strbuf sb = STRBUF_INIT; - if (argc != 3) - die("submodule--helper relative-path takes exactly 2 arguments, got %d", argc); - - printf("%s", relative_path(argv[1], argv[2], &sb)); - strbuf_release(&sb); - return 0; -} - static const char *remote_submodule_branch(const char *path) { const struct submodule *sub; @@ -2857,8 +2820,53 @@ static int module_set_branch(int argc, const char **argv, const char *prefix) return !!ret; } -/* NEEDSWORK: this is a temporary name until we delete update_submodule() */ -static int update_submodule2(struct update_data *update_data) +static void update_data_to_args(struct update_data *update_data, struct strvec *args) +{ + strvec_pushl(args, "submodule--helper", "update", "--recursive", NULL); + strvec_pushf(args, "--jobs=%d", update_data->max_jobs); + /* + * NEEDSWORK: the equivalent code in git-submodule.sh does not + * pass --prefix, so this shouldn't either + */ + if (update_data->prefix) + strvec_pushl(args, "--prefix", update_data->prefix, NULL); + if (update_data->recursive_prefix) + strvec_pushl(args, "--recursive-prefix", + update_data->recursive_prefix, NULL); + if (update_data->quiet) + strvec_push(args, "--quiet"); + if (update_data->force) + strvec_push(args, "--force"); + if (update_data->init) + strvec_push(args, "--init"); + if (update_data->remote) + strvec_push(args, "--remote"); + if (update_data->nofetch) + strvec_push(args, "--no-fetch"); + if (update_data->dissociate) + strvec_push(args, "--dissociate"); + if (update_data->progress) + strvec_push(args, "--progress"); + if (update_data->require_init) + strvec_push(args, "--require-init"); + if (update_data->depth) + strvec_pushf(args, "--depth=%d", update_data->depth); + if (update_data->update_default) + strvec_pushl(args, "--update", update_data->update_default, NULL); + if (update_data->references.nr) { + struct string_list_item *item; + for_each_string_list_item(item, &update_data->references) + strvec_pushl(args, "--reference", item->string, NULL); + } + if (update_data->recommend_shallow == 0) + strvec_push(args, "--no-recommend-shallow"); + else if (update_data->recommend_shallow == 1) + strvec_push(args, "--recommend-shallow"); + if (update_data->single_branch >= 0) + strvec_push(args, "--single-branch"); +} + +static int update_submodule(struct update_data *update_data) { char *prefixed_path; @@ -2907,18 +2915,55 @@ static int update_submodule2(struct update_data *update_data) } if (!oideq(&update_data->oid, &update_data->suboid) || update_data->force) - return do_run_update_procedure(update_data); + if (run_update_procedure(update_data)) + return 1; + + if (update_data->recursive) { + struct child_process cp = CHILD_PROCESS_INIT; + struct update_data next = *update_data; + int res; + + if (update_data->recursive_prefix) + prefixed_path = xstrfmt("%s%s/", update_data->recursive_prefix, + update_data->sm_path); + else + prefixed_path = xstrfmt("%s/", update_data->sm_path); + + next.recursive_prefix = get_submodule_displaypath(prefixed_path, + update_data->prefix); + next.prefix = NULL; + oidcpy(&next.oid, null_oid()); + oidcpy(&next.suboid, null_oid()); + + cp.dir = update_data->sm_path; + cp.git_cmd = 1; + prepare_submodule_repo_env(&cp.env_array); + update_data_to_args(&next, &cp.args); - return 3; + /* die() if child process die()'d */ + res = run_command(&cp); + if (!res) + return 0; + die_message(_("Failed to recurse into submodule path '%s'"), + update_data->displaypath); + if (res == 128) + exit(res); + else if (res) + return 1; + } + + return 0; } -static int update_submodules(struct submodule_update_clone *suc) +static int update_submodules(struct update_data *update_data) { - int i; + int i, res = 0; + struct submodule_update_clone suc = SUBMODULE_UPDATE_CLONE_INIT; - run_processes_parallel_tr2(suc->max_jobs, update_clone_get_next_task, + update_clone_from_update_data(&suc, update_data); + run_processes_parallel_tr2(suc.max_jobs, update_clone_get_next_task, update_clone_start_failure, - update_clone_task_finished, suc, "submodule", + update_clone_task_finished, &suc, "submodule", "parallel/update"); /* @@ -2929,50 +2974,69 @@ static int update_submodules(struct submodule_update_clone *suc) * checkout involve more straightforward sequential I/O. * - the listener can avoid doing any work if fetching failed. */ - if (suc->quickstop) - return 1; + if (suc.quickstop) { + res = 1; + goto cleanup; + } - for (i = 0; i < suc->update_clone_nr; i++) - update_submodule(&suc->update_clone[i]); + for (i = 0; i < suc.update_clone_nr; i++) { + struct update_clone_data ucd = suc.update_clone[i]; - return 0; + oidcpy(&update_data->oid, &ucd.oid); + update_data->just_cloned = ucd.just_cloned; + update_data->sm_path = ucd.sub->path; + + if (update_submodule(update_data)) + res = 1; + } + +cleanup: + string_list_clear(&update_data->references, 0); + return res; } -static int update_clone(int argc, const char **argv, const char *prefix) +static int module_update(int argc, const char **argv, const char *prefix) { - const char *update = NULL; struct pathspec pathspec; - struct submodule_update_clone opt = SUBMODULE_UPDATE_CLONE_INIT; + struct update_data opt = UPDATE_DATA_INIT; + /* NEEDSWORK: update names and strings */ struct option module_update_clone_options[] = { + OPT__FORCE(&opt.force, N_("force checkout updates"), 0), OPT_BOOL(0, "init", &opt.init, N_("initialize uninitialized submodules before update")), - OPT_STRING(0, "prefix", &prefix, + OPT_BOOL(0, "remote", &opt.remote, + N_("use SHA-1 of submodule's remote tracking branch")), + OPT_BOOL(0, "recursive", &opt.recursive, + N_("traverse submodules recursively")), + OPT_BOOL('N', "no-fetch", &opt.nofetch, + N_("don't fetch new objects from the remote site")), + OPT_STRING(0, "prefix", &opt.prefix, N_("path"), N_("path into the working tree")), OPT_STRING(0, "recursive-prefix", &opt.recursive_prefix, N_("path"), N_("path into the working tree, across nested " "submodule boundaries")), - OPT_STRING(0, "update", &update, + OPT_STRING(0, "update", &opt.update_default, N_("string"), N_("rebase, merge, checkout or none")), OPT_STRING_LIST(0, "reference", &opt.references, N_("repo"), - N_("reference repository")), + N_("reference repository")), OPT_BOOL(0, "dissociate", &opt.dissociate, - N_("use --reference only while cloning")), - OPT_STRING(0, "depth", &opt.depth, "", - N_("create a shallow clone truncated to the " - "specified number of revisions")), + N_("use --reference only while cloning")), + OPT_INTEGER(0, "depth", &opt.depth, + N_("create a shallow clone truncated to the " + "specified number of revisions")), OPT_INTEGER('j', "jobs", &opt.max_jobs, N_("parallel jobs")), OPT_BOOL(0, "recommend-shallow", &opt.recommend_shallow, - N_("whether the initial clone should follow the shallow recommendation")), + N_("whether the initial clone should follow the shallow recommendation")), OPT__QUIET(&opt.quiet, N_("don't print cloning progress")), OPT_BOOL(0, "progress", &opt.progress, - N_("force cloning progress")), + N_("force cloning progress")), OPT_BOOL(0, "require-init", &opt.require_init, - N_("disallow cloning into non-empty directory")), + N_("disallow cloning into non-empty directory")), OPT_BOOL(0, "single-branch", &opt.single_branch, N_("clone only one branch, HEAD or --branch")), OPT_END() @@ -2982,16 +3046,18 @@ static int update_clone(int argc, const char **argv, const char *prefix) N_("git submodule--helper update-clone [--prefix=] [...]"), NULL }; - opt.prefix = prefix; update_clone_config_from_gitmodules(&opt.max_jobs); git_config(git_update_clone_config, &opt.max_jobs); argc = parse_options(argc, argv, prefix, module_update_clone_options, git_submodule_helper_usage, 0); + oidcpy(&opt.oid, null_oid()); + oidcpy(&opt.suboid, null_oid()); - if (update) - if (parse_submodule_update_strategy(update, &opt.update) < 0) + if (opt.update_default) + if (parse_submodule_update_strategy(opt.update_default, + &opt.update_strategy) < 0) die(_("bad value for update parameter")); if (module_list_compute(argc, argv, prefix, &pathspec, &opt.list) < 0) @@ -3413,9 +3479,7 @@ static struct cmd_struct commands[] = { {"name", module_name, 0}, {"clone", module_clone, 0}, {"add", module_add, SUPPORT_SUPER_PREFIX}, - {"update-clone", update_clone, 0}, - {"run-update-procedure", run_update_procedure, 0}, - {"relative-path", resolve_relative_path, 0}, + {"update", module_update, 0}, {"resolve-relative-url-test", resolve_relative_url_test, 0}, {"foreach", module_foreach, SUPPORT_SUPER_PREFIX}, {"init", module_init, SUPPORT_SUPER_PREFIX}, diff --git a/git-submodule.sh b/git-submodule.sh index 3ccf2388bf..d176469fb1 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -50,6 +50,7 @@ single_branch= jobs= recommend_shallow= +# NEEDSWORK this is now unused die_if_unmatched () { if test "$1" = "#unmatched" @@ -347,108 +348,28 @@ cmd_update() shift done - { - git ${wt_prefix:+-C "$wt_prefix"} submodule--helper update-clone \ + # NEEDSWORK --super-prefix isn't actually supported by this + # command - we just pass the $prefix to --recursive-prefix. + git ${wt_prefix:+-C "$wt_prefix"} ${prefix:+--super-prefix "$prefix"} submodule--helper update \ ${GIT_QUIET:+--quiet} \ - ${progress:+"--progress"} \ + ${force:+--force} \ + ${progress:+--progress} \ + ${dissociate:+--dissociate} \ + ${remote:+--remote} \ + ${recursive:+--recursive} \ ${init:+--init} \ + ${require_init:+--require-init} \ + ${nofetch:+--no-fetch} \ ${wt_prefix:+--prefix "$wt_prefix"} \ ${prefix:+--recursive-prefix "$prefix"} \ ${update:+--update "$update"} \ ${reference:+"$reference"} \ - ${dissociate:+"--dissociate"} \ - ${depth:+--depth "$depth"} \ - ${require_init:+--require-init} \ + ${depth:+"$depth"} \ $single_branch \ $recommend_shallow \ $jobs \ -- \ - "$@" || echo "#unmatched" $? - } | { - err= - while read -r quickabort sha1 just_cloned sm_path - do - die_if_unmatched "$quickabort" "$sha1" - - displaypath=$(git submodule--helper relative-path "$prefix$sm_path" "$wt_prefix") - - if test $just_cloned -eq 0 - then - just_cloned= - fi - - out=$(git submodule--helper run-update-procedure \ - ${wt_prefix:+--prefix "$wt_prefix"} \ - ${GIT_QUIET:+--quiet} \ - ${force:+--force} \ - ${just_cloned:+--just-cloned} \ - ${nofetch:+--no-fetch} \ - ${depth:+"$depth"} \ - ${update:+--update "$update"} \ - ${prefix:+--recursive-prefix "$prefix"} \ - ${sha1:+--oid "$sha1"} \ - ${remote:+--remote} \ - "--" \ - "$sm_path") - - # exit codes for run-update-procedure: - # 0: update was successful, say command output - # 1: update procedure failed, but should not die - # 2 or 128: subcommand died during execution - # 3: no update procedure was run - res="$?" - case $res in - 0) - say "$out" - ;; - 1) - err="${err};fatal: $out" - continue - ;; - 2|128) - die_with_status $res "fatal: $out" - ;; - esac - - if test -n "$recursive" - then - ( - prefix=$(git submodule--helper relative-path "$prefix$sm_path/" "$wt_prefix") - wt_prefix= - sanitize_submodule_env - cd "$sm_path" && - eval cmd_update - ) - res=$? - if test $res -gt 0 - then - die_msg="fatal: $(eval_gettext "Failed to recurse into submodule path '\$displaypath'")" - if test $res -ne 2 - then - err="${err};$die_msg" - continue - else - die_with_status $res "$die_msg" - fi - fi - fi - done - - if test -n "$err" - then - OIFS=$IFS - IFS=';' - for e in $err - do - if test -n "$e" - then - echo >&2 "$e" - fi - done - IFS=$OIFS - exit 1 - fi - } + "$@" } # From patchwork Thu Feb 10 09:28:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12741614 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03F08C433F5 for ; Thu, 10 Feb 2022 09:29:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238682AbiBJJ3x (ORCPT ); Thu, 10 Feb 2022 04:29:53 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238620AbiBJJ3b (ORCPT ); Thu, 10 Feb 2022 04:29:31 -0500 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 495CB10F2 for ; Thu, 10 Feb 2022 01:29:27 -0800 (PST) Received: by mail-pj1-x1049.google.com with SMTP id gj12-20020a17090b108c00b001b89b5f3dd4so5798508pjb.6 for ; Thu, 10 Feb 2022 01:29:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=6ns3Xfnn3SvI0lg4fojBZdtCWkLa/bIJPZdKcTfMtvI=; b=TgH8hfz+C500f4J6xfoAfFmdG8xqYj4EQdoGYoV6WuKnG01z31GPbGUL0hEayC/mc3 0TSzRCE/8s+NU5rTXaQeQYrfkkhdDLnUS8ElUGplfdaL1A3btoMk8ddfDRJvirTp0PBL RjamwVsIsL9X9Eva47JAkNMxb9K1Uz6z5aVxoqY1UTQKinnTUXYXUwNztsbyOSz9pETY +Ki7HN6Zf7qReEPispgjdungZS/GCL0CZ1es5XTgw6V1oU/+umhUdg3Cz1ySON9LMHqe o7qIcuPx/BkjCIgJDUMCeG1As2hfiJy41biNwkfulMQXdPGbBkejaZRz8NtUtyvV8d8N ZQ1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=6ns3Xfnn3SvI0lg4fojBZdtCWkLa/bIJPZdKcTfMtvI=; b=OowALhtgTofa8vbNZU0BN+BBM/IOSiF//ql3hZV6bLJX/pxF3+Vac7eB+1E0PVqW5B UiXQts+gEPBkVCiL5fwiy8oReWXMETUKZba1x/Qg3PTOIHp48sQxMw8ml4fiLGPmQoA3 oGTL4zT1CgzJJuTnKBsF82e3VSDuKwqPtN86VKHWouh6Rvgnw32VXjw5uiW1wZa+jqDR 61MOn0mijnik7hDRaFjYoZ10RzRmtEzK+8hstIcSoQCbBkZ5//s98yRvSRd5w/PiQCF1 k+0Ypihpkzf1u3POc6dbMzmcRujU8TXurC39vLMBZSgbBdl5Di3+asH3oyjbkOSa/t1p tbbw== X-Gm-Message-State: AOAM530VKnMNM4X8N+dkjDBuO2pM7BHiZUV+LCH4uWmTmT6zcmuVQBdt QY7CltY3FyFngcDdEs0eoP00jzXc6G7gPPDn3c6UXmOADt5nV9dVoBL1Q0A3WQYdtnIkLiE/sAX 8WyuF1DoxRNDuELMehyhiNjy8k/bABWi0+yRsgHG8nok8wl7X/m9aaIx93/q+eMc= X-Google-Smtp-Source: ABdhPJz7WVeQwtP1xTloHCCztmxPdcKLB2pwzGhZDBJdUUDxsKpi21war7iTgQjFWJXfXAbodGcGH/zl11ZoJQ== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a05:6a00:1785:: with SMTP id s5mr6564098pfg.72.1644485366688; Thu, 10 Feb 2022 01:29:26 -0800 (PST) Date: Thu, 10 Feb 2022 17:28:31 +0800 In-Reply-To: <20220210092833.55360-1-chooglen@google.com> Message-Id: <20220210092833.55360-19-chooglen@google.com> Mime-Version: 1.0 References: <20220208083952.35036-1-chooglen@google.com> <20220210092833.55360-1-chooglen@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH v7 18/20] fixup! submodule--helper run-update-procedure: remove --suboid From: Glen Choo To: git@vger.kernel.org Cc: Glen Choo , Junio C Hamano , Atharva Raykar , Christian Couder , Emily Shaffer , Jonathan Nieder , Kaartic Sivaraam , pc44800@gmail.com, Shourya Shukla , " =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= " Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Glen Choo --- builtin/submodule--helper.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index b895e88a64..98d8910930 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2886,14 +2886,11 @@ static int update_submodule(struct update_data *update_data) update_data->sm_path, update_data->update_default, &update_data->update_strategy); - /* NEEDSWORK: fix the style issues e.g. braces */ - if (update_data->just_cloned) { + if (update_data->just_cloned) oidcpy(&update_data->suboid, null_oid()); - } else { - if (resolve_gitlink_ref(update_data->sm_path, "HEAD", &update_data->suboid)) - die(_("Unable to find current revision in submodule path '%s'"), - update_data->displaypath); - } + else if (resolve_gitlink_ref(update_data->sm_path, "HEAD", &update_data->suboid)) + die(_("Unable to find current revision in submodule path '%s'"), + update_data->displaypath); if (update_data->remote) { char *remote_name = get_default_remote_submodule(update_data->sm_path); From patchwork Thu Feb 10 09:28:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12741615 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7757FC433F5 for ; Thu, 10 Feb 2022 09:30:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238690AbiBJJaD (ORCPT ); Thu, 10 Feb 2022 04:30:03 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238688AbiBJJ3b (ORCPT ); Thu, 10 Feb 2022 04:29:31 -0500 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AB6310FD for ; Thu, 10 Feb 2022 01:29:29 -0800 (PST) Received: by mail-pf1-x449.google.com with SMTP id w12-20020aa7858c000000b004e02ef665e7so3968986pfn.15 for ; Thu, 10 Feb 2022 01:29:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=PimCtu4h/hGqS09q6THQe+qzeegstCZeV0OHpeR3Y1Q=; b=FRGb+ZPWbwPXKwmj3K6Z10/VkQIQmVvn6/4YCoX9HfVPJQBHMNN+R/h4K9z7x8JKdv pOBkc3OPVz1f4ROem88BE6h8AEm8rLCwCyTozYw2Wh6jQm08k+yCkjGjblJ9hWlGDG8O HM/jB65o2ngzvLBHZ/D6t1NtmbiJKS57anEiYv9/YGLLAUYHeaPJ2TbhAiTP87iQ6s+a 3WJjQZFIuVoeVwKlFmna6SLy2jtuwKVcZFWPXEQz7KdtuWBSfnCR/cfnhLzo3jHVmokA K9wCJK4LU8bAM/bE4tkRVv1frrB+xUb4UNLc5b+R042jCuXsVDg086S/m98k1FOn4QhN KOug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=PimCtu4h/hGqS09q6THQe+qzeegstCZeV0OHpeR3Y1Q=; b=JajDq0bCJKP1PRm6GCDcVR4CGShK9YT+0Ht5j37NMOddAFN4o5r+CTCrOLy/5eEgUP a+K+U4dSUg1otk36pEETEbkVUXDrXcD+4/6PdhQ0fNUSoYlbX7XXcNpK4I6qXRyoulMH Pt+sVpYko5mhYAXM0yKdr6izsG7ixrrPfibPdxbuf3ULJNkvcYCTI9nigpa+tZ4jn7QC jrEDyREssucocjG/meVAtVjM4Cm/3yhy/LJ3kZACtMglW0EicXQh/RAeIFFS3uHwA/iu TITGnZp/7RpsxBUi5YMErXLnVfi4S9vMjgy3yvINQNI+PeLOidU84z1IrZwjAjh3ZwrN L5TA== X-Gm-Message-State: AOAM533KvfAHZGqPq49NdkgrMKEbd/omk/0f0S3L8YR7+trOba9pvGBR JKMbtrb/qsmAjlAwNNFMB68uLo6WkBovP6YcXIz11pnbU2J8ZKtr9HoCh82KDwxqWbRr4I4BpP+ mlY39A9FMzm0ysENzJamk5LuvYeyBbgZi4vxjtruqqAO/ft11nWhPMbdnFapezDM= X-Google-Smtp-Source: ABdhPJzokLNBne3NGRIXcZtfiatvOiX7EgRw5+e4VKjihssUmWyaTKOnsiNEiZkV4vB67i7ydhTLvGAbi7Qj8A== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a62:7e06:: with SMTP id z6mr6603743pfc.60.1644485368912; Thu, 10 Feb 2022 01:29:28 -0800 (PST) Date: Thu, 10 Feb 2022 17:28:32 +0800 In-Reply-To: <20220210092833.55360-1-chooglen@google.com> Message-Id: <20220210092833.55360-20-chooglen@google.com> Mime-Version: 1.0 References: <20220208083952.35036-1-chooglen@google.com> <20220210092833.55360-1-chooglen@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH v7 19/20] fixup! submodule--helper run-update-procedure: learn --remote From: Glen Choo To: git@vger.kernel.org Cc: Glen Choo , Junio C Hamano , Atharva Raykar , Christian Couder , Emily Shaffer , Jonathan Nieder , Kaartic Sivaraam , pc44800@gmail.com, Shourya Shukla , " =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= " Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Glen Choo --- builtin/submodule--helper.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 98d8910930..5d5302b50b 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2516,23 +2516,6 @@ static const char *remote_submodule_branch(const char *path) return branch; } -static int resolve_remote_submodule_branch(int argc, const char **argv, - const char *prefix) -{ - const char *ret; - struct strbuf sb = STRBUF_INIT; - if (argc != 2) - die("submodule--helper remote-branch takes exactly one arguments, got %d", argc); - - ret = remote_submodule_branch(argv[1]); - if (!ret) - die("submodule %s doesn't exist", argv[1]); - - printf("%s", ret); - strbuf_release(&sb); - return 0; -} - static int push_check(int argc, const char **argv, const char *prefix) { struct remote *remote; @@ -3484,8 +3467,6 @@ static struct cmd_struct commands[] = { {"sync", module_sync, SUPPORT_SUPER_PREFIX}, {"deinit", module_deinit, 0}, {"summary", module_summary, SUPPORT_SUPER_PREFIX}, - /* NEEDSWORK: remote-branch is also obsolete */ - {"remote-branch", resolve_remote_submodule_branch, 0}, {"push-check", push_check, 0}, {"absorb-git-dirs", absorb_git_dirs, SUPPORT_SUPER_PREFIX}, {"is-active", is_active, 0}, From patchwork Thu Feb 10 09:28:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12741616 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D528C433EF for ; Thu, 10 Feb 2022 09:30:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238633AbiBJJaF (ORCPT ); Thu, 10 Feb 2022 04:30:05 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238552AbiBJJ3c (ORCPT ); Thu, 10 Feb 2022 04:29:32 -0500 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F313E1145 for ; Thu, 10 Feb 2022 01:29:31 -0800 (PST) Received: by mail-pf1-x449.google.com with SMTP id s207-20020a6277d8000000b004e0300e14f7so3933016pfc.23 for ; Thu, 10 Feb 2022 01:29:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=lNK+oYAT8iCrh3nj/FdHLjMJncmuBYs5ti04rusFEQU=; b=I29doCT12nyHufckfJQR0QKYVDsmBa7Msp74xknm1FBYPMwEGZzB8KuK76VW6yaT9B G3DMXyqejsw1yyBMzrZwbwSaXln2NI9wwS1TfCHEuNQdisSRs38bHFWCu3dKgl7ZWZWS myi2jXLMxZn1tHN6t0bptqCmjSj/1LZMige9+0xvzcSP6qRVhonx3Miv+MPsFRcidIjN h5sM8kO0Z45x18ihRKxtY1tBmDEKX4q1zmKYjC7q3KA7UVbe1GmE07dWUmEH5MvxyzSo WBKRTpma6HlV4GFXzqhQKmzhEGRTNa6aaP2jq9dXZ8MkaC0nulMOvj2XaHLbzJ4jl/qs /1XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=lNK+oYAT8iCrh3nj/FdHLjMJncmuBYs5ti04rusFEQU=; b=bTZCbS3BYfHCaoh8OUbLAxe+lO+QVc5/BRTxCDmbCqqdtcKRqV7Vi1T+fE0zMC+jdN AJ7vlr8Tqax/MECV4HtfeiDC4WPkGN69oItW0C7jeVSXtNtHkfh6ChuXen61//5yekrl BgBJnZOJZ9q6Ae3v8VsKg6IS+PS+F8hlXlvam/QBzSu6y8UbM81wrIuB871sdt7m8eWi XFlCoH3K8phTHNnUtpRVmtbu/zhceBn5NugX7hMQieGETQML12kvLKKnmeTUm9WYoqqw O2MPm0NLJ/hh21GL6YUOdTbuE7G7TYOpEsM4+RsEJ1ajPEraCID5avAJalSyTSJp2Pw+ MSGg== X-Gm-Message-State: AOAM532ITJit6gTupcGMt72a11909pNS9llob5rzNp1JDXOTxf+28FIR pW4VppaEWMDRl5YGfxYCGC8VgP5U6u9xD1977wiau5sdqisrVAUwH9uhTw0SgxqqZCdTgJX38ZU VGVRYcRpuUtFnfc26n/9pNs8GGk3BgeALCB4XZcM4xBdLulgWBpzFPPL+p60vaok= X-Google-Smtp-Source: ABdhPJzIf6xi0LuUPdJkkLfD5nhyUdeOZukP7yvWn2M8jp8cESD/UfWIgw4HNqjg7yNCNjxznOSgKhlNYqXNLA== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a17:902:ab53:: with SMTP id ij19mr6690409plb.45.1644485371336; Thu, 10 Feb 2022 01:29:31 -0800 (PST) Date: Thu, 10 Feb 2022 17:28:33 +0800 In-Reply-To: <20220210092833.55360-1-chooglen@google.com> Message-Id: <20220210092833.55360-21-chooglen@google.com> Mime-Version: 1.0 References: <20220208083952.35036-1-chooglen@google.com> <20220210092833.55360-1-chooglen@google.com> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog Subject: [PATCH v7 20/20] fixup! submodule: move core cmd_update() logic to C From: Glen Choo To: git@vger.kernel.org Cc: Glen Choo , Junio C Hamano , Atharva Raykar , Christian Couder , Emily Shaffer , Jonathan Nieder , Kaartic Sivaraam , pc44800@gmail.com, Shourya Shukla , " =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= " Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Glen Choo --- builtin/submodule--helper.c | 13 +++---------- git-submodule.sh | 13 +------------ 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 5d5302b50b..3367997973 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2807,12 +2807,6 @@ static void update_data_to_args(struct update_data *update_data, struct strvec * { strvec_pushl(args, "submodule--helper", "update", "--recursive", NULL); strvec_pushf(args, "--jobs=%d", update_data->max_jobs); - /* - * NEEDSWORK: the equivalent code in git-submodule.sh does not - * pass --prefix, so this shouldn't either - */ - if (update_data->prefix) - strvec_pushl(args, "--prefix", update_data->prefix, NULL); if (update_data->recursive_prefix) strvec_pushl(args, "--recursive-prefix", update_data->recursive_prefix, NULL); @@ -2980,8 +2974,7 @@ static int module_update(int argc, const char **argv, const char *prefix) struct pathspec pathspec; struct update_data opt = UPDATE_DATA_INIT; - /* NEEDSWORK: update names and strings */ - struct option module_update_clone_options[] = { + struct option module_update_options[] = { OPT__FORCE(&opt.force, N_("force checkout updates"), 0), OPT_BOOL(0, "init", &opt.init, N_("initialize uninitialized submodules before update")), @@ -3023,14 +3016,14 @@ static int module_update(int argc, const char **argv, const char *prefix) }; const char *const git_submodule_helper_usage[] = { - N_("git submodule--helper update-clone [--prefix=] [...]"), + N_("git submodule--helper update [--prefix=] [...]"), NULL }; update_clone_config_from_gitmodules(&opt.max_jobs); git_config(git_update_clone_config, &opt.max_jobs); - argc = parse_options(argc, argv, prefix, module_update_clone_options, + argc = parse_options(argc, argv, prefix, module_update_options, git_submodule_helper_usage, 0); oidcpy(&opt.oid, null_oid()); oidcpy(&opt.suboid, null_oid()); diff --git a/git-submodule.sh b/git-submodule.sh index d176469fb1..89f5cf393e 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -50,15 +50,6 @@ single_branch= jobs= recommend_shallow= -# NEEDSWORK this is now unused -die_if_unmatched () -{ - if test "$1" = "#unmatched" - then - exit ${2:-1} - fi -} - isnumber() { n=$(($1 + 0)) 2>/dev/null && test "$n" = "$1" @@ -348,9 +339,7 @@ cmd_update() shift done - # NEEDSWORK --super-prefix isn't actually supported by this - # command - we just pass the $prefix to --recursive-prefix. - git ${wt_prefix:+-C "$wt_prefix"} ${prefix:+--super-prefix "$prefix"} submodule--helper update \ + git ${wt_prefix:+-C "$wt_prefix"} submodule--helper update \ ${GIT_QUIET:+--quiet} \ ${force:+--force} \ ${progress:+--progress} \