From patchwork Thu Sep 16 10:32:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atharva Raykar X-Patchwork-Id: 12498599 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADB05C433EF for ; Thu, 16 Sep 2021 10:33:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 95E6360238 for ; Thu, 16 Sep 2021 10:33:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236581AbhIPKe3 (ORCPT ); Thu, 16 Sep 2021 06:34:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233913AbhIPKe0 (ORCPT ); Thu, 16 Sep 2021 06:34:26 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A1B7C061574 for ; Thu, 16 Sep 2021 03:33:06 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id j16so5515540pfc.2 for ; Thu, 16 Sep 2021 03:33:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6++1T30h1iGYOlKKfZKE16nCjyjI8IJhhiJmo/sUrrI=; b=ECweIR2QqvC8YpnhgQxeOjbbIlCV7MGbK2uucpr723IXaahXS+4r4EWa0gpqU68op7 Z7qL/uXlsC7z3KaScHWmrL+8seT1eLiJ/ZWz3YxxjRjrnUUWgfzNaMyOHn5QXEsAiOZH pN1zsqyaeHFRUtCcO8ujZCGbegWdzlLs0jo0f8beBM9bTSjlkoz4EzdbtvPC+15tPGV9 9cj8QDx8/t4GWwq2vAonMV4qxGNLRmbD4YyCgGrg/QGH9ie/6TDptA3qNlLFSFVux0Lh TUTu5qakierw45Q1IjkLcNyqvDoVp4MOn2UMpXqzWvUPXzM8WkHgSLACAEfwIrjJWMpD 60Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6++1T30h1iGYOlKKfZKE16nCjyjI8IJhhiJmo/sUrrI=; b=RuTmdqc7xudr0Zl7n4hziE4Ip5wCWYWY2jcRtDsq3AO+vUHayL+45G5/y6j8AvPWWP 8ns3BV0x+zWMImBfZ4evbYsO2c0/hKisgVnsHdGR5yHlI/+EAl2825FEU+xyE5gz2yMD KBcBAiH4xsPPGp2Hofnm+C91baN2aHI6N3VSOOCd8NB+Vvpia8KSktKIfxzXiiKPHVva ltzEVvslfPsaYzBeAccoiDKpX0uCRz5FdFRbcppEWpOrgHzJugOT99xein9eMw5cmicx BSrzqy2W52ChimPWqLJAQccfLkdFsXNLtV6SrNnMy4EHPIHVfB2hUMsvyiIf+vyc2+K1 vkuQ== X-Gm-Message-State: AOAM533mqyJUyOJxV9mALsnwnpk5O2W+LO1ua/ka7DhF98J2w7vt7UV8 jpTRHaB0VYNa3yBgKxp/KMM= X-Google-Smtp-Source: ABdhPJz3CGFlVh/VMkPyX+g5RCaym8ybdsFylUX26Yro0AEyKGdYZj/ihw9izup+S5HlLfJAqy1o6w== X-Received: by 2002:a62:7e55:0:b0:441:c7a6:fcd2 with SMTP id z82-20020a627e55000000b00441c7a6fcd2mr2111938pfc.6.1631788385729; Thu, 16 Sep 2021 03:33:05 -0700 (PDT) Received: from atharva-on-air.Dlink ([119.82.121.182]) by smtp.gmail.com with ESMTPSA id c199sm2642605pfb.152.2021.09.16.03.33.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Sep 2021 03:33:05 -0700 (PDT) From: Atharva Raykar To: raykar.ath@gmail.com Cc: avarab@gmail.com, christian.couder@gmail.com, emilyshaffer@google.com, git@vger.kernel.org, gitster@pobox.com, jrnieder@gmail.com, kaartic.sivaraam@gmail.com, pc44800@gmail.com, periperidip@gmail.com Subject: [PATCH v2 1/8] submodule--helper: split up ensure_core_worktree() Date: Thu, 16 Sep 2021 16:02:34 +0530 Message-Id: <20210916103241.62376-2-raykar.ath@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210916103241.62376-1-raykar.ath@gmail.com> References: <20210907115932.36068-1-raykar.ath@gmail.com> <20210916103241.62376-1-raykar.ath@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Let's split up `ensure_core_worktree()` so that we can call it from C code without needing to deal with command line arguments. Mentored-by: Christian Couder Mentored-by: Shourya Shukla Signed-off-by: Atharva Raykar --- builtin/submodule--helper.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 80619361fc..97512ccf0b 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2794,18 +2794,12 @@ 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 do_ensure_core_worktree(const char *path) { const struct submodule *sub; - const char *path; const char *cw; struct repository subrepo; - if (argc != 2) - BUG("submodule--helper ensure-core-worktree "); - - path = argv[1]; - sub = submodule_from_path(the_repository, null_oid(), path); if (!sub) BUG("We could get the submodule handle before?"); @@ -2829,6 +2823,17 @@ static int ensure_core_worktree(int argc, const char **argv, const char *prefix) free(abs_path); strbuf_release(&sb); } +} + +static int ensure_core_worktree(int argc, const char **argv, const char *prefix) +{ + const char *path; + + if (argc != 2) + BUG("submodule--helper ensure-core-worktree "); + + path = argv[1]; + do_ensure_core_worktree(path); return 0; } From patchwork Thu Sep 16 10:32:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atharva Raykar X-Patchwork-Id: 12498601 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24C88C433F5 for ; Thu, 16 Sep 2021 10:33:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0D5BF61108 for ; Thu, 16 Sep 2021 10:33:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236608AbhIPKeb (ORCPT ); Thu, 16 Sep 2021 06:34:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233913AbhIPKea (ORCPT ); Thu, 16 Sep 2021 06:34:30 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 047D5C061574 for ; Thu, 16 Sep 2021 03:33:10 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id c4so3530758pls.6 for ; Thu, 16 Sep 2021 03:33:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HP8XnJZ9umqYMyOZqaS4wWyOIaomOst6k3OEPStAMl8=; b=gY6MXAmnEdEUDb7YHq7rMP8WFT4RGkffMtiT/41LlBnFZ4ZD27I3p3XXbLchjScD71 GiNP6XnPILHrBFSNP/zkDs24WX6Xohfmfi0bQjTPk7Q1EY8/DofMN7TJevl0qsRUezbG qexn/ugHp+tboidq8NmvdPu1hEdd0GZNOsOUFf/ngRe67j58mryZ6qvmar3yiYQKDZfX pNGZcueJnnMK9/Is2CvjnUPtvi/DQbd0vhmFy9m/dkHIIan+yzQCc0HlRDdYwONmBZcI U3jQL/GSCaRQqoAn3fdhfZD4+Uvq/Gv8xUDnNbpc/ikGZe+J4Dsnzjw/D60u+EZGiK8M WydA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HP8XnJZ9umqYMyOZqaS4wWyOIaomOst6k3OEPStAMl8=; b=wmINke4O8Rb0rtwkzqTxxIilZoiaGffRvmlC/jE/3SmBy5x7mX0z06bvXFCeq4Fiv+ IRYkZzqlXOc8rQj/509Ea765qW3E+jCm6PGBCz4afY8tpwzIzl9xTU0NRT1mcINuMBM6 qyB+ozxfGh/vRZO57jFL1qFicsg/VSLp1VRUaZP7PRhP6vN17jQn3LobIFd799WAHGjT iSDSXwCPNFlXGjx9HEyPzM8P9PiDnAYjNwrrSTwBKlszFVvfVhSc4D+O0FZUp44NThCA qrepat4O1fMtbfw3DLxWrzKiwin6Z4tSkB1Mu7xmYkioSA5YIfCGLYLZz5rgcvo4le6x leqA== X-Gm-Message-State: AOAM532j8ih/VJ/zoohdeDnVakU9z++NwiOKVRmOzQ50vU3ylssg2RmL LnQlAiNkghZ3LgxTimUSjHM= X-Google-Smtp-Source: ABdhPJwzlKwsDOaWqaT9yYuOTsHNyn3w9xjQmZXHGouH0u1XhE+VZv3TEYog3+Sbny3IPn8Upp8CYw== X-Received: by 2002:a17:902:a407:b0:138:849b:56f6 with SMTP id p7-20020a170902a40700b00138849b56f6mr4127536plq.0.1631788389594; Thu, 16 Sep 2021 03:33:09 -0700 (PDT) Received: from atharva-on-air.Dlink ([119.82.121.182]) by smtp.gmail.com with ESMTPSA id c199sm2642605pfb.152.2021.09.16.03.33.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Sep 2021 03:33:09 -0700 (PDT) From: Atharva Raykar To: raykar.ath@gmail.com Cc: avarab@gmail.com, christian.couder@gmail.com, emilyshaffer@google.com, git@vger.kernel.org, gitster@pobox.com, jrnieder@gmail.com, kaartic.sivaraam@gmail.com, pc44800@gmail.com, periperidip@gmail.com Subject: [PATCH v2 2/8] submodule--helper: get remote names from any repository Date: Thu, 16 Sep 2021 16:02:35 +0530 Message-Id: <20210916103241.62376-3-raykar.ath@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210916103241.62376-1-raykar.ath@gmail.com> References: <20210907115932.36068-1-raykar.ath@gmail.com> <20210916103241.62376-1-raykar.ath@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org `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 Signed-off-by: Atharva Raykar --- builtin/submodule--helper.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 97512ccf0b..f6c4fc349b 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -29,11 +29,10 @@ 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, const char *refname) { char *dest = NULL, *ret; struct strbuf sb = STRBUF_INIT; - const char *refname = resolve_ref_unsafe("HEAD", 0, NULL, NULL); if (!refname) die(_("No such ref: %s"), "HEAD"); @@ -46,7 +45,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 +54,25 @@ static char *get_default_remote(void) return ret; } +static char *get_default_remote_submodule(const char *module_path) +{ + const char *refname; + const struct submodule *sub; + struct repository subrepo; + + refname = refs_resolve_ref_unsafe(get_submodule_ref_store(module_path), + "HEAD", 0, NULL, NULL); + sub = submodule_from_path(the_repository, null_oid(), module_path); + repo_submodule_init(&subrepo, the_repository, sub); + return repo_get_default_remote(&subrepo, refname); +} + +static char *get_default_remote(void) +{ + const char *refname = resolve_ref_unsafe("HEAD", 0, NULL, NULL); + return repo_get_default_remote(the_repository, refname); +} + static int print_default_remote(int argc, const char **argv, const char *prefix) { char *remote; @@ -1369,7 +1387,6 @@ static void sync_submodule(const char *path, const char *prefix, char *remote_key = NULL; char *sub_origin_url, *super_config_url, *displaypath; struct strbuf sb = STRBUF_INIT; - struct child_process cp = CHILD_PROCESS_INIT; char *sub_config_path = NULL; if (!is_submodule_active(the_repository, path)) @@ -1418,14 +1435,9 @@ 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)) + strbuf_addstr(&sb, get_default_remote_submodule(path)); + if (!sb.buf) die(_("failed to get the default remote for submodule '%s'"), path); From patchwork Thu Sep 16 10:32:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atharva Raykar X-Patchwork-Id: 12498603 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6DDDC433EF for ; Thu, 16 Sep 2021 10:33:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CEF1A6120E for ; Thu, 16 Sep 2021 10:33:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236631AbhIPKef (ORCPT ); Thu, 16 Sep 2021 06:34:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236567AbhIPKed (ORCPT ); Thu, 16 Sep 2021 06:34:33 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA068C061574 for ; Thu, 16 Sep 2021 03:33:13 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id j1so4217856pjv.3 for ; Thu, 16 Sep 2021 03:33:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dm16lt3N3la3Rsj8BnLp3eWLyTCyeeHI76VyVOgUN78=; b=OAP1eZbKvLKujTVg+NJtGS5u4iopfwqfngQTQkt3g85TI+LXdjmGokDOj2Ovr6RcUC bzmxRO4GKlYLOiDPhg4c4DVMl1jDWmcBz8eC3J7ap/qo/IM961JzsMTzJggOn9SghbBy 0cLCFauX84on9HfBzO7FXdrWNH0DWHCyZGUK5hewAp+Zz2bHCbNsLORs8Sdn0iGwaEJi E9DNquFMRBt0O3XQrM3dTFfYBslSR9whafp3yA61dt+Cn9jXtwntukMJIDLDkurt64wz 4CAHCBxjNkb9KdPg0wNkE1Fa6jtAu+9Xd9AK4BtI/nEInIOgg2ICsb/HA5d4PJUcKZB5 emSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dm16lt3N3la3Rsj8BnLp3eWLyTCyeeHI76VyVOgUN78=; b=DvSf+5ww1rpeqAaGNbw50LWEMO5MnAZhx1TlEi0u5v7X048RfwMVRITePlSbh+3JPn fMXWRrxlbwQSr65eFtrOue08+7t/g9FQPW3Hm6HNNJ8xfM1uZwrvos1uaoSt0YPLb58/ r5IWU30bxRIaH8HoxXjaQkSJdANbuG6dQw9Idu7N5uFtGNd2bo+ggDpWLZ7UfdCJC3/7 ePeiN9wleRq6CSGM8EivEG/hYTcWOkVSgNmDMAktKeQ/Xyd/zFb+UVFC74WcnZUV5tro Yb+b/qqyzbiRW/KatO0kvx213FpJuQF5Li9KIUtofVPJCr5QKvXe/IDtqicQ7iHciSJi HuEA== X-Gm-Message-State: AOAM533Tw1f0rvbUB/aAmAVCycWgJZmj8AMjJJcbLD1bO00VI95YIHy1 gU7j4tRIXsgddTe3vFCaU7M= X-Google-Smtp-Source: ABdhPJxxXE7zlCi2YaKys/j36xYKg+uXLKXxi11mYi43s+zvnSY5R82rv6BH05XCIRqlx+i59Jw7ng== X-Received: by 2002:a17:902:6ac4:b0:13c:856f:9511 with SMTP id i4-20020a1709026ac400b0013c856f9511mr4240182plt.23.1631788393406; Thu, 16 Sep 2021 03:33:13 -0700 (PDT) Received: from atharva-on-air.Dlink ([119.82.121.182]) by smtp.gmail.com with ESMTPSA id c199sm2642605pfb.152.2021.09.16.03.33.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Sep 2021 03:33:13 -0700 (PDT) From: Atharva Raykar To: raykar.ath@gmail.com Cc: avarab@gmail.com, christian.couder@gmail.com, emilyshaffer@google.com, git@vger.kernel.org, gitster@pobox.com, jrnieder@gmail.com, kaartic.sivaraam@gmail.com, pc44800@gmail.com, periperidip@gmail.com Subject: [PATCH v2 3/8] submodule--helper: rename helpers for update-clone Date: Thu, 16 Sep 2021 16:02:36 +0530 Message-Id: <20210916103241.62376-4-raykar.ath@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210916103241.62376-1-raykar.ath@gmail.com> References: <20210907115932.36068-1-raykar.ath@gmail.com> <20210916103241.62376-1-raykar.ath@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The `update-clone` subcommand helpers that perform the parallel clone and printing to stdout for shell script consumption, are renamed. This lets us use the names `update_submodules()` and `update_submodule()` for the helpers in the next patch, when we create an `update` subcommand that does a full conversion. We will get rid of these helpers in a cleanup patch at the end of this series, when the `update-clone` command is no longer useful to us. Mentored-by: Christian Couder Mentored-by: Shourya Shukla Signed-off-by: Atharva Raykar --- builtin/submodule--helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index f6c4fc349b..b0336b0377 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2499,7 +2499,7 @@ 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) +static void update_clone_submodule(struct update_clone_data *ucd) { fprintf(stdout, "dummy %s %d\t%s\n", oid_to_hex(&ucd->oid), @@ -2507,7 +2507,7 @@ static void update_submodule(struct update_clone_data *ucd) ucd->sub->path); } -static int update_submodules(struct submodule_update_clone *suc) +static int update_clone_submodules(struct submodule_update_clone *suc) { int i; @@ -2528,7 +2528,7 @@ static int update_submodules(struct submodule_update_clone *suc) return 1; for (i = 0; i < suc->update_clone_nr; i++) - update_submodule(&suc->update_clone[i]); + update_clone_submodule(&suc->update_clone[i]); return 0; } @@ -2593,7 +2593,7 @@ static int update_clone(int argc, const char **argv, const char *prefix) if (pathspec.nr) suc.warn_if_uninitialized = 1; - return update_submodules(&suc); + return update_clone_submodules(&suc); } static int run_update_procedure(int argc, const char **argv, const char *prefix) From patchwork Thu Sep 16 10:32:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atharva Raykar X-Patchwork-Id: 12498605 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 408C0C433FE for ; Thu, 16 Sep 2021 10:33:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2215D61108 for ; Thu, 16 Sep 2021 10:33:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236679AbhIPKej (ORCPT ); Thu, 16 Sep 2021 06:34:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236647AbhIPKeh (ORCPT ); Thu, 16 Sep 2021 06:34:37 -0400 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1736C061574 for ; Thu, 16 Sep 2021 03:33:17 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id u18so5794855pgf.0 for ; Thu, 16 Sep 2021 03:33:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jnkkddKqtqWYsXo+82ptvtqq+qtAQ70WTJ2ehwv2NG8=; b=dO6SdbbV78UNMNnWnGT7f1eIxm3kG2t5I65HGSmt0yDBk27MdoNmMAqE1DNns3hHUx k4DNmyKpanFRKYYdRzQSZNhSlodyNDdXrbPggLSB6phHRp/pWjrH3R6sPzGkL8ajoaJQ 2lrOrvOZgawv6BfKuamGbOBRa0iKxIW1tAo5xL5Na7LD2A4A2RItJCQXMwutOs5udpBy tYvaOfqvQbTSejFYC12dxNA1IUj449qS5tU/Cj2O9UtQa6P9ShtJT2j/de6ed3l5OzQh YlRb5rEOMkIKEIiuachKqXyrUHPJNEHi3iA98kSeXhQ5UI7dN0E+aKd0QgLek2iNNbS+ QyFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jnkkddKqtqWYsXo+82ptvtqq+qtAQ70WTJ2ehwv2NG8=; b=zmuwQEvGmmhr4P9SE6aP4v45XEqmlFnFWMApJxEpEztYCfuL1fLBTWH+AqqIn5RUm5 kvLEDxi091iwUwYCYUo+CGU9wlCO2g6UOqnrqfWuVbpBKNnbtmwvaS81PMui2FCqz0tY drCXHpANN1GbC/eRYmCYrQfHriwIzWAl1SfYmBotkKHyrxeaIozv9j49DraZuCUAZDjX UIHBBpzRflgBU7KjBeKGfzHI1yOnYR1ATj6ussTeeUWz97J7Nt/JNDzKaqHz1UUMfyQw 7OmK9PfDbQv/jGQOouDGlJGU3JglFeo1A+WegN8QEKDzrvBghjqIQ8vVr1nk5mXp6qFe Ex3g== X-Gm-Message-State: AOAM530O0QbkQJ7A6LBl6l00k+g7FB5FGZojaIxy6qoZwz5FV8HdWhKB 7YjpslbLRqX+4GIqgkPhthy1OBIsKhA= X-Google-Smtp-Source: ABdhPJw7iIV2C3Qgue52FQSWnhi+hJr7G7LeZDnlmA8PIVxWJSE7fGocgYVS8bvHHcAeFd48FJu95w== X-Received: by 2002:aa7:8893:0:b0:416:4ed7:e4c4 with SMTP id z19-20020aa78893000000b004164ed7e4c4mr4452001pfe.83.1631788397274; Thu, 16 Sep 2021 03:33:17 -0700 (PDT) Received: from atharva-on-air.Dlink ([119.82.121.182]) by smtp.gmail.com with ESMTPSA id c199sm2642605pfb.152.2021.09.16.03.33.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Sep 2021 03:33:17 -0700 (PDT) From: Atharva Raykar To: raykar.ath@gmail.com Cc: avarab@gmail.com, christian.couder@gmail.com, emilyshaffer@google.com, git@vger.kernel.org, gitster@pobox.com, jrnieder@gmail.com, kaartic.sivaraam@gmail.com, pc44800@gmail.com, periperidip@gmail.com Subject: [PATCH v2 4/8] submodule--helper: refactor get_submodule_displaypath() Date: Thu, 16 Sep 2021 16:02:37 +0530 Message-Id: <20210916103241.62376-5-raykar.ath@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210916103241.62376-1-raykar.ath@gmail.com> References: <20210907115932.36068-1-raykar.ath@gmail.com> <20210916103241.62376-1-raykar.ath@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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 --- 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 b0336b0377..10de01a1f7 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -269,11 +269,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); @@ -289,6 +286,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 Sep 16 10:32:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atharva Raykar X-Patchwork-Id: 12498607 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E3CBC433EF for ; Thu, 16 Sep 2021 10:33:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E1CCC61108 for ; Thu, 16 Sep 2021 10:33:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236617AbhIPKep (ORCPT ); Thu, 16 Sep 2021 06:34:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236417AbhIPKem (ORCPT ); Thu, 16 Sep 2021 06:34:42 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15001C061574 for ; Thu, 16 Sep 2021 03:33:22 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id mv7-20020a17090b198700b0019c843e7233so679694pjb.4 for ; Thu, 16 Sep 2021 03:33:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jyJRk25V1xD/bDKjcHw3Oz1rresiepiqo0Y3rP3RvFo=; b=mW2jzL59JtKi2+kVmWc6J/HhiUXIPr40Rknwm+bkBT2mQ73ijvPAHv+vrHUPiF+dtI NZ2apLq7lUo74Jq8Offy37vOlBPHUX5QiEWhrIfh0akm5lNSSWXyB6qM86zJFlPjhr0Y URUHEvz/5f/BhvYftQ4WCzvBIlOB/5RpAiVqBZtkn+B7KO5vQbGXEhQXdwsKKuenXl/n bYZvFYMsdQhrpgGeWoVStLA4qrlFQ0bmhXyDQkylM3ghuEqFCu38PK7PhgN5OwZDgd/L BytxCPCrRmxrwvqGAGQletTSRFY2p40NIdhY4GxHcpGmMIug4CakF/+arxpQUC2oquCq 7Alg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jyJRk25V1xD/bDKjcHw3Oz1rresiepiqo0Y3rP3RvFo=; b=fN3kGGnHKSujrS45QEDZEJLWe/vK0YF3iT/y+KL2+QaAyLEFihInDd9uHZYqlkEWSe B1rnP0xDi01xovWJ5IrMFrsQV6iNh+KkxiPUxGunrrPSr+RXibRmaqlT8lLyzS3QT23l WPyNdxMEWJx/R96zdxOnBTt1smgzYE3Ak0mPmA/wLwk+frOx7Ng1gd3ieCHmWFE7muOg Zc3THSRqsQefCYCB4dlxJEZEhA/pWQQL9AYae1bxhCqjZ8y2n6npd4CXWk3t/4MmwH/x vjtmjFrsCK7sQHWQGgPgeTgew9NvwIkBYdHuFKA/jpd4vNM7bQO43koFCk/84fOCe66P EZ/g== X-Gm-Message-State: AOAM530K5rojU0Ssr/xzDtZ+fq2np2Z9CjNFD9hrPk3Su9gZHlipbstH cQ3mnn84fWgWG/kimrquyp0= X-Google-Smtp-Source: ABdhPJxogTe7Y2nuAEcEcuF2+2HP6+W80lmLu3tTKghYGEUVgier8cjowMKuhCo3wigsezrzfyyN/A== X-Received: by 2002:a17:903:120e:b0:138:d732:3b01 with SMTP id l14-20020a170903120e00b00138d7323b01mr4158794plh.21.1631788401452; Thu, 16 Sep 2021 03:33:21 -0700 (PDT) Received: from atharva-on-air.Dlink ([119.82.121.182]) by smtp.gmail.com with ESMTPSA id c199sm2642605pfb.152.2021.09.16.03.33.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Sep 2021 03:33:21 -0700 (PDT) From: Atharva Raykar To: raykar.ath@gmail.com Cc: avarab@gmail.com, christian.couder@gmail.com, emilyshaffer@google.com, git@vger.kernel.org, gitster@pobox.com, jrnieder@gmail.com, kaartic.sivaraam@gmail.com, pc44800@gmail.com, periperidip@gmail.com Subject: [PATCH v2 5/8] submodule: move core cmd_update() logic to C Date: Thu, 16 Sep 2021 16:02:38 +0530 Message-Id: <20210916103241.62376-6-raykar.ath@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210916103241.62376-1-raykar.ath@gmail.com> References: <20210907115932.36068-1-raykar.ath@gmail.com> <20210916103241.62376-1-raykar.ath@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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. We also introduce `update_submodules()` and `update_submodule()` which are quite similar to `update_clone_submodules()` and `update_clone_submodule()`, and will supersede them. 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[1]. So we instead run the `init_submodule_cb()` callback over each submodule directly. This introduces another problem, because there is no mechanism to pass the superproject path prefix (ie, `--super-prefix`) without starting a new git process. This field is required for obtaining the display path for that is used by the command's output messages. So let's add a field into the `init_cb` struct that lets us pass this information to `init_submodule()`, which will now also take an explicit 'superprefix' argument. While we are at it, we also remove the fetch_in_submodule() shell function since it is no longer used anywhere. [1] https://lore.kernel.org/git/CAP8UFD0NCQ5w_3GtT_xHr35i7h8BuLX4UcHNY6VHPGREmDVObA@mail.gmail.com/ Mentored-by: Christian Couder Mentored-by: Shourya Shukla Signed-off-by: Atharva Raykar --- builtin/submodule--helper.c | 505 ++++++++++++++++++++++++++++++------ git-submodule.sh | 145 +---------- 2 files changed, 433 insertions(+), 217 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 10de01a1f7..1eea626864 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -634,18 +634,22 @@ static char *compute_submodule_clone_url(const char *rel_url) struct init_cb { const char *prefix; + const char *superprefix; unsigned int flags; }; -#define INIT_CB_INIT { NULL, 0 } +#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); @@ -719,7 +723,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) @@ -2039,7 +2043,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; @@ -2062,19 +2065,63 @@ struct submodule_update_clone { } struct update_data { + const char *prefix; const char *recursive_prefix; const char *sm_path; const char *displaypath; struct object_id oid; struct object_id suboid; - struct submodule_update_strategy update_strategy; + int max_jobs; int depth; + int recommend_shallow; + int single_branch; + unsigned int init: 1; unsigned int force: 1; unsigned int quiet: 1; unsigned int nofetch: 1; - unsigned int just_cloned: 1; + unsigned int remote: 1; + unsigned int recursive: 1; + unsigned int progress: 1; + unsigned int dissociate: 1; + unsigned int require_init: 1; + unsigned warn_if_uninitialized : 1; + unsigned int just_cloned : 1; + struct submodule_update_strategy update_strategy; + struct string_list references; + struct module_list list; }; -#define UPDATE_DATA_INIT { .update_strategy = SUBMODULE_UPDATE_STRATEGY_INIT } +#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, struct strbuf *out, const char *displaypath) @@ -2369,111 +2416,113 @@ static int fetch_in_submodule(const char *module_path, int depth, int quiet, str return run_command(&cp); } -static int run_update_command(struct update_data *ud, int subforce) +static int run_update_command(struct update_data *ud, int subforce, struct string_list *err) { - 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); + struct strbuf out = STRBUF_INIT; int must_die_on_failure = 0; - int git_cmd; + struct submodule_update_strategy strategy = SUBMODULE_UPDATE_STRATEGY_INIT; - switch (ud->update_strategy.type) { + if (ud->update_strategy.type == SM_UPDATE_UNSPECIFIED || ud->just_cloned) + determine_submodule_update_strategy(the_repository, ud->just_cloned, + ud->sm_path, NULL, &strategy); + else + strategy = ud->update_strategy; + + cp.dir = xstrdup(ud->sm_path); + switch (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.git_cmd = 0; + cp.use_shell = 1; + strvec_push(&cp.args, strategy.command); must_die_on_failure = 1; break; default: BUG("unexpected update strategy type: %s", - submodule_strategy_to_string(&ud->update_strategy)); + submodule_strategy_to_string(&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)) { - switch (ud->update_strategy.type) { - case SM_UPDATE_CHECKOUT: - printf(_("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); - break; - case SM_UPDATE_MERGE: - printf(_("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); - break; - default: - BUG("unexpected update strategy type: %s", - submodule_strategy_to_string(&ud->update_strategy)); + prepare_submodule_repo_env(&cp.env_array); + if (capture_command(&cp, &out, 0)) { + if (must_die_on_failure) { + switch (strategy.type) { + case SM_UPDATE_CHECKOUT: + die(_("Unable to checkout '%s' in submodule path '%s'"), + oid, ud->displaypath); + break; + case SM_UPDATE_REBASE: + die(_("Unable to rebase '%s' in submodule path '%s'"), + oid, ud->displaypath); + break; + case SM_UPDATE_MERGE: + die(_("Unable to merge '%s' in submodule path '%s'"), + oid, ud->displaypath); + break; + case SM_UPDATE_COMMAND: + die(_("Execution of '%s %s' failed in submodule path '%s'"), + strategy.command, oid, ud->displaypath); + break; + default: + BUG("unexpected update strategy type: %s", + submodule_strategy_to_string(&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 - */ + + /* the command failed, but update must continue */ + string_list_append(err, out.buf); return 1; } - switch (ud->update_strategy.type) { - case SM_UPDATE_CHECKOUT: - printf(_("Submodule path '%s': checked out '%s'\n"), - ud->displaypath, oid); - break; - case SM_UPDATE_REBASE: - printf(_("Submodule path '%s': rebased into '%s'\n"), - ud->displaypath, oid); - break; - case SM_UPDATE_MERGE: - printf(_("Submodule path '%s': merged in '%s'\n"), - ud->displaypath, oid); - break; - case SM_UPDATE_COMMAND: - printf(_("Submodule path '%s': '%s %s'\n"), - ud->displaypath, ud->update_strategy.command, oid); - break; - default: - BUG("unexpected update strategy type: %s", - submodule_strategy_to_string(&ud->update_strategy)); + if (!ud->quiet) { + switch (strategy.type) { + case SM_UPDATE_CHECKOUT: + printf(_("Submodule path '%s': checked out '%s'\n"), + ud->displaypath, oid); + break; + case SM_UPDATE_REBASE: + printf(_("Submodule path '%s': rebased into '%s'\n"), + ud->displaypath, oid); + break; + case SM_UPDATE_MERGE: + printf(_("Submodule path '%s': merged in '%s'\n"), + ud->displaypath, oid); + break; + case SM_UPDATE_COMMAND: + printf(_("Submodule path '%s': '%s %s'\n"), + ud->displaypath, strategy.command, oid); + break; + default: + BUG("unexpected update strategy type: %s", + submodule_strategy_to_string(&strategy)); + } } return 0; } -static int do_run_update_procedure(struct update_data *ud) +static int do_run_update_procedure(struct update_data *ud, struct string_list *err) { int subforce = is_null_oid(&ud->suboid) || ud->force; @@ -2500,7 +2549,7 @@ static int do_run_update_procedure(struct update_data *ud) ud->displaypath, oid_to_hex(&ud->oid)); } - return run_update_command(ud, subforce); + return run_update_command(ud, subforce, err); } static void update_clone_submodule(struct update_clone_data *ucd) @@ -2605,6 +2654,7 @@ 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 string_list err = STRING_LIST_INIT_DUP; struct option options[] = { OPT__QUIET(&quiet, N_("suppress output for update by rebase or merge")), @@ -2662,7 +2712,7 @@ static int run_update_procedure(int argc, const char **argv, const char *prefix) free(prefixed_path); if (!oideq(&update_data.oid, &update_data.suboid) || update_data.force) - return do_run_update_procedure(&update_data); + return do_run_update_procedure(&update_data, &err); return 3; } @@ -3038,6 +3088,291 @@ static int module_set_branch(int argc, const char **argv, const char *prefix) return !!ret; } +static void update_data_to_args(struct update_data *update_data, struct strvec *args) +{ + const char *update = submodule_strategy_to_string(&update_data->update_strategy); + + strvec_pushl(args, "submodule--helper", "update", "--recursive", NULL); + strvec_pushf(args, "--jobs=%d", update_data->max_jobs); + 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) + strvec_pushl(args, "--update", update, 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; + struct string_list err = STRING_LIST_INIT_DUP; + + do_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); + + 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 (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) + if (do_run_update_procedure(update_data, &err)) + return 1; + + if (update_data->recursive) { + int res; + struct child_process cp = CHILD_PROCESS_INIT; + struct update_data next = *update_data; + char *die_msg = xstrfmt(_("Failed to recurse into submodule path '%s'"), + update_data->displaypath); + + 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); + + /* die() if child process die()'d */ + if ((res = run_command(&cp)) == 128) + die("%s", die_msg); + if (res) + string_list_append(&err, die_msg); + + free(die_msg); + } + + if (err.nr) { + struct string_list_item *item; + for_each_string_list_item(item, &err) + fputs(item->string, stderr); + return 1; + } + + return 0; +} + +static int update_submodules(struct update_data *update_data) +{ + int i, res = 0; + struct submodule_update_clone suc = SUBMODULE_UPDATE_CLONE_INIT; + + 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", + "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) { + string_list_clear(&update_data->references, 0); + return 1; + } + + for (i = 0; i < suc.update_clone_nr; i++) { + struct update_clone_data ucd = suc.update_clone[i]; + + 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; + } + + string_list_clear(&update_data->references, 0); + return res; +} + +static int module_update(int argc, const char **argv, const char *prefix) +{ + int init = 0, force = 0, quiet = 0, nofetch = 0; + int remote = 0, recursive = 0, dissociate = 0; + int progress = 0, require_init = 0; + const char *update = NULL; + struct pathspec pathspec; + struct update_data update_data = UPDATE_DATA_INIT; + + struct option module_update_clone_options[] = { + OPT__FORCE(&force, N_("force checkout updates"), 0), + OPT_BOOL(0, "init", &init, + N_("initialize uninitialized submodules before update")), + OPT_BOOL(0, "remote", &remote, + N_("use SHA-1 of submodule's remote tracking branch")), + OPT_BOOL(0, "recursive", &recursive, + N_("traverse submodules recursively")), + OPT_BOOL('N', "no-fetch", &nofetch, + N_("don't fetch new objects from the remote site")), + OPT_STRING(0, "prefix", &prefix, + N_("path"), + N_("path into the working tree")), + OPT_STRING(0, "recursive-prefix", &update_data.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", &update_data.references, N_("repo"), + N_("reference repository")), + OPT_BOOL(0, "dissociate", &dissociate, + N_("use --reference only while cloning")), + OPT_INTEGER(0, "depth", &update_data.depth, + N_("create a shallow clone truncated to the " + "specified number of revisions")), + OPT_INTEGER('j', "jobs", &update_data.max_jobs, + N_("parallel jobs")), + OPT_BOOL(0, "recommend-shallow", &update_data.recommend_shallow, + N_("whether the initial clone should follow the shallow recommendation")), + OPT__QUIET(&quiet, N_("don't print cloning progress")), + OPT_BOOL(0, "progress", &progress, + N_("force cloning progress")), + OPT_BOOL(0, "require-init", &require_init, + N_("disallow cloning into non-empty directory")), + OPT_BOOL(0, "single-branch", &update_data.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 + }; + + update_clone_config_from_gitmodules(&update_data.max_jobs); + git_config(git_update_clone_config, &update_data.max_jobs); + + argc = parse_options(argc, argv, prefix, module_update_clone_options, + git_submodule_helper_usage, 0); + update_data.prefix = prefix; + + update_data.force = !!force; + update_data.quiet = !!quiet; + update_data.nofetch = !!nofetch; + update_data.init = !!init; + update_data.require_init = !!require_init; + update_data.remote = !!remote; + update_data.recursive = !!recursive; + update_data.progress = !!progress; + update_data.dissociate = !!dissociate; + oidcpy(&update_data.oid, null_oid()); + oidcpy(&update_data.suboid, null_oid()); + + if (update) + if (parse_submodule_update_strategy(update, + &update_data.update_strategy) < 0) + die(_("bad value for update parameter")); + + if (module_list_compute(argc, argv, prefix, &pathspec, &update_data.list) < 0) + return 1; + + if (pathspec.nr) + update_data.warn_if_uninitialized = 1; + + if (update_data.init) { + struct module_list list = MODULE_LIST_INIT; + struct init_cb info = INIT_CB_INIT; + + if (module_list_compute(argc, argv, update_data.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 = update_data.prefix; + info.superprefix = update_data.recursive_prefix; + if (update_data.quiet) + info.flags |= OPT_QUIET; + + for_each_listed_submodule(&list, init_submodule_cb, &info); + } + + return update_submodules(&update_data); +} + struct add_data { const char *prefix; const char *branch; @@ -3213,6 +3548,7 @@ static int add_clone(int argc, const char **argv, const char *prefix) return 0; } + #define SUPPORT_SUPER_PREFIX (1<<0) struct cmd_struct { @@ -3226,6 +3562,7 @@ static struct cmd_struct commands[] = { {"name", module_name, 0}, {"clone", module_clone, 0}, {"add-clone", add_clone, 0}, + {"update", module_update, 0}, {"update-module-mode", module_update_module_mode, 0}, {"update-clone", update_clone, 0}, {"run-update-procedure", run_update_procedure, 0}, diff --git a/git-submodule.sh b/git-submodule.sh index f703cddce8..5197de4551 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -369,20 +369,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 # @@ -484,133 +470,26 @@ cmd_update() shift done - if test -n "$init" - then - cmd_init "--" "$@" || return - fi - - { - git submodule--helper update-clone ${GIT_QUIET:+--quiet} \ - ${progress:+"--progress"} \ + git ${wt_prefix:+-C "$wt_prefix"} ${prefix:+--super-prefix "$prefix"} submodule--helper update \ + ${GIT_QUIET:+--quiet} \ + ${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" - - 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 1 - 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" - 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} \ - ${force:+--force} \ - ${just_cloned:+--just-cloned} \ - ${nofetch:+--no-fetch} \ - ${depth:+"$depth"} \ - ${update:+--update "$update"} \ - ${prefix:+--recursive-prefix "$prefix"} \ - ${sha1:+--oid "$sha1"} \ - ${subsha1:+--suboid "$subsha1"} \ - "--" \ - "$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 Sep 16 10:32:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atharva Raykar X-Patchwork-Id: 12498609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 842FCC433F5 for ; Thu, 16 Sep 2021 10:33:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6DC1561108 for ; Thu, 16 Sep 2021 10:33:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236718AbhIPKer (ORCPT ); Thu, 16 Sep 2021 06:34:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236417AbhIPKep (ORCPT ); Thu, 16 Sep 2021 06:34:45 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 887D7C061574 for ; Thu, 16 Sep 2021 03:33:25 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id c1so2558972pfp.10 for ; Thu, 16 Sep 2021 03:33:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/TaZPwx/RaQvt27yfvLBvnREbW9wPfsE3i+D5HXIMws=; b=kWPMaYUhdDd4j45tJWET6Taz5vQyhaYUlZudrOVYSkxvf9D1tFdIqL5l9XXhE3X8hG 1e5B34aR6OaVK7i3avHi5Efv11K+NyFFCsLxL4iFkHYJVPM4vW2u+kknIeVpVhAE51ml 38+1MqPAMwYLd/e23vvFpZ19clYLy9+YLQV/uRj/X/ouZTobnJrqq3d9Hdjb9SH5ZMvR 57H2WE/KWzgGDFCzuIuoW1MNKnf69hCyhE6+YY2CfL5W74mTQk534QzOuZYjNua7YA7k qxU5CRY31mL6fbbljQSHm8gRU/3HTEuG8qju1H+M849oMb7x8ud8rkkR7GkWnkp7f0v5 jZ6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/TaZPwx/RaQvt27yfvLBvnREbW9wPfsE3i+D5HXIMws=; b=Ln3giFUO2flRUiqIueQ/siTrMoSKhiaOvh0sxeW/4jROzxxGdEhuOUu2YMW8ieMggM XWgJugnhGDmr4GQvaV2ivHoWtjXusU1Ozg/C3zikCRjnT2q12JI44M9uxCbpmeee9KuB fj6687ZfXNT9HFBhYTrZGOwx9snk6T7nRekeBRqGOS1SLLDEARdMi0w+waL0mOK3wav2 uGWwDp+lsoE/JTXb7QxDeeB3vXJ2e0jo9zXUgP8YEdH66rkHdS6TlyofE7H4EDmXybAh 1WjWOy3efWdac/mUGdJZH6Dbay938/nmt6Qi+bXYtUjxdY3gJWlpmhpP2Pv1WcPczknH iTWA== X-Gm-Message-State: AOAM531HqQ4hgqBTbVA3DDWn3Z8FhCB/j9x3oKEfrYcOltC378VS+5R/ G4bc0a6HeamxTw44TcGkv2g= X-Google-Smtp-Source: ABdhPJzdWiT67bsow75ah2oPHS2VFOeaOLLTrLiBoaxhVIeXbLjSrSdSvXFsAjjARfBSiMS3JrUBOQ== X-Received: by 2002:a65:400c:: with SMTP id f12mr4346454pgp.296.1631788405007; Thu, 16 Sep 2021 03:33:25 -0700 (PDT) Received: from atharva-on-air.Dlink ([119.82.121.182]) by smtp.gmail.com with ESMTPSA id c199sm2642605pfb.152.2021.09.16.03.33.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Sep 2021 03:33:24 -0700 (PDT) From: Atharva Raykar To: raykar.ath@gmail.com Cc: avarab@gmail.com, christian.couder@gmail.com, emilyshaffer@google.com, git@vger.kernel.org, gitster@pobox.com, jrnieder@gmail.com, kaartic.sivaraam@gmail.com, pc44800@gmail.com, periperidip@gmail.com Subject: [PATCH v2 6/8] submodule--helper: remove update-clone subcommand Date: Thu, 16 Sep 2021 16:02:39 +0530 Message-Id: <20210916103241.62376-7-raykar.ath@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210916103241.62376-1-raykar.ath@gmail.com> References: <20210907115932.36068-1-raykar.ath@gmail.com> <20210916103241.62376-1-raykar.ath@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We no longer need this subcommand as the shell version calls the 'update' subcommand instead, which does all the cloning within C itself. We also no longer need the 'update_clone_submodules()' and 'update_clone_submodule()' functions, so we remove those as well. Mentored-by: Christian Couder Mentored-by: Shourya Shukla Signed-off-by: Atharva Raykar --- builtin/submodule--helper.c | 98 ------------------------------------- 1 file changed, 98 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 1eea626864..c1ce3981ad 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2552,103 +2552,6 @@ static int do_run_update_procedure(struct update_data *ud, struct string_list *e return run_update_command(ud, subforce, err); } -static void update_clone_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); -} - -static int update_clone_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_clone_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 suc = 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, - 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"), - N_("reference repository")), - OPT_BOOL(0, "dissociate", &suc.dissociate, - N_("use --reference only while cloning")), - OPT_STRING(0, "depth", &suc.depth, "", - N_("create a shallow clone truncated to the " - "specified number of revisions")), - OPT_INTEGER('j', "jobs", &suc.max_jobs, - N_("parallel jobs")), - OPT_BOOL(0, "recommend-shallow", &suc.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, - N_("force cloning progress")), - OPT_BOOL(0, "require-init", &suc.require_init, - N_("disallow cloning into non-empty directory")), - OPT_BOOL(0, "single-branch", &suc.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 - }; - suc.prefix = prefix; - - update_clone_config_from_gitmodules(&suc.max_jobs); - git_config(git_update_clone_config, &suc.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) - die(_("bad value for update parameter")); - - if (module_list_compute(argc, argv, prefix, &pathspec, &suc.list) < 0) - return 1; - - if (pathspec.nr) - suc.warn_if_uninitialized = 1; - - return update_clone_submodules(&suc); -} - static int run_update_procedure(int argc, const char **argv, const char *prefix) { int force = 0, quiet = 0, nofetch = 0, just_cloned = 0; @@ -3564,7 +3467,6 @@ static struct cmd_struct commands[] = { {"add-clone", add_clone, 0}, {"update", module_update, 0}, {"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}, {"relative-path", resolve_relative_path, 0}, From patchwork Thu Sep 16 10:32:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atharva Raykar X-Patchwork-Id: 12498611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96AC4C433F5 for ; Thu, 16 Sep 2021 10:33:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7AFB560238 for ; Thu, 16 Sep 2021 10:33:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236736AbhIPKex (ORCPT ); Thu, 16 Sep 2021 06:34:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236755AbhIPKet (ORCPT ); Thu, 16 Sep 2021 06:34:49 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F219EC0613CF for ; Thu, 16 Sep 2021 03:33:28 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id t20so4213156pju.5 for ; Thu, 16 Sep 2021 03:33:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IYquWGyZRPHSafHkbR6FxYdBZ/uFzYBJOR7cohIQe+Q=; b=Bcu60z44UEOiNMMKsScBjUSQtyoJK8jBccTUaIvQ3PSHabvlfkJa56Fh3bdSdSOsbo ZWPv4ShFNWu8fmnkU1uDGWyB37iCMzU6I9CDm+A7txs/wXQjqaOS7HCc2s/FVFGU0dDR IBR6mF2cZt9I3qPufuNSK082wtrexrPnpfCoOZtxsTlB38IvMZy+Qn0RIDt9eWZpYtfP axYi4gVIpP1MGRJoR4eMHy4BCKnUG+tLOgKH+sUT0anUwCPJIXUQSwzhfVaCnenk2GKW F9MeJv5a8Qi+Zt5x3f6lK9AynKNfUFwNIf+5s3fQ8rjeUTpeV2uxgxgqUdAwsUfvgfCA 9bAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IYquWGyZRPHSafHkbR6FxYdBZ/uFzYBJOR7cohIQe+Q=; b=C5+AM3vBjH2YhEq6E7hHB41IMgAWKbqj6n1ZpYOOKR2V3ijxDvvEz6ZrXnkwkQKaiT BKEwb2GKtVlRPV/YlTlnQPZysj16LkOD5QZ6sqeWPDv3JI4AHS4MzeMMPfu7PlJAihCx GHnHODLXcsgoeEdXYO3ivbyqEJo2Lv/AQokN0u2z6SKhKAOiZLmk06e2Cl5x14Bn8JB9 G7P6O+Jc7aOlATC81b0sFjYwYEvFoDdt8BkyK91uzsrD218r648yDFeZIPJjXoNGTovh gzuQaKfE9Z4w087IJ9TdfD2gLneZxwoSzXHyTOjxmLo6RIfC1LddAzSq7z0lVidWNHio K/gg== X-Gm-Message-State: AOAM531fnqsSMeCySNu+J0ekTmqYBItbQiD3H9uOM8leiwzfmA/um1QF 63pYgdyfYkc4DkAJbOx+d90= X-Google-Smtp-Source: ABdhPJwkaL5TnHOn+uOwGLlwyKcUsOUR6nlLo1ANYx5ZrgmyzNvmSSFR+54nrl04No0bE7mRQr6ttg== X-Received: by 2002:a17:90b:314c:: with SMTP id ip12mr14300473pjb.32.1631788408559; Thu, 16 Sep 2021 03:33:28 -0700 (PDT) Received: from atharva-on-air.Dlink ([119.82.121.182]) by smtp.gmail.com with ESMTPSA id c199sm2642605pfb.152.2021.09.16.03.33.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Sep 2021 03:33:28 -0700 (PDT) From: Atharva Raykar To: raykar.ath@gmail.com Cc: avarab@gmail.com, christian.couder@gmail.com, emilyshaffer@google.com, git@vger.kernel.org, gitster@pobox.com, jrnieder@gmail.com, kaartic.sivaraam@gmail.com, pc44800@gmail.com, periperidip@gmail.com Subject: [PATCH v2 7/8] submodule--helper: remove unused helpers Date: Thu, 16 Sep 2021 16:02:40 +0530 Message-Id: <20210916103241.62376-8-raykar.ath@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210916103241.62376-1-raykar.ath@gmail.com> References: <20210907115932.36068-1-raykar.ath@gmail.com> <20210916103241.62376-1-raykar.ath@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org These helpers were useful back when 'submodule update' had most of its logic in shell. Now that they will never be invoked, let us remove them. Mentored-by: Christian Couder Mentored-by: Shourya Shukla Signed-off-by: Atharva Raykar --- builtin/submodule--helper.c | 135 ------------------------------------ 1 file changed, 135 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index c1ce3981ad..0910af9c71 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -73,21 +73,6 @@ static char *get_default_remote(void) return repo_get_default_remote(the_repository, refname); } -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]); @@ -1993,29 +1978,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; @@ -2552,85 +2514,6 @@ static int do_run_update_procedure(struct update_data *ud, struct string_list *e return run_update_command(ud, subforce, err); } -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 string_list err = STRING_LIST_INIT_DUP; - - 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, - 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_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"), - N_("path into the working tree, across nested " - "submodule boundaries")), - OPT_CALLBACK_F(0, "oid", &update_data.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"), - N_("SHA1 of submodule's HEAD"), PARSE_OPT_NONEG, - parse_opt_object_id), - 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); - - update_data.force = !!force; - update_data.quiet = !!quiet; - update_data.nofetch = !!nofetch; - update_data.just_cloned = !!just_cloned; - update_data.sm_path = argv[0]; - - 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, prefix); - - determine_submodule_update_strategy(the_repository, update_data.just_cloned, - update_data.sm_path, update, - &update_data.update_strategy); - - free(prefixed_path); - - if (!oideq(&update_data.oid, &update_data.suboid) || update_data.force) - return do_run_update_procedure(&update_data, &err); - - return 3; -} - -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; @@ -2794,19 +2677,6 @@ static void do_ensure_core_worktree(const char *path) } } -static int ensure_core_worktree(int argc, const char **argv, const char *prefix) -{ - const char *path; - - if (argc != 2) - BUG("submodule--helper ensure-core-worktree "); - - path = argv[1]; - do_ensure_core_worktree(path); - - return 0; -} - static int absorb_git_dirs(int argc, const char **argv, const char *prefix) { int i; @@ -3466,16 +3336,11 @@ static struct cmd_struct commands[] = { {"clone", module_clone, 0}, {"add-clone", add_clone, 0}, {"update", module_update, 0}, - {"update-module-mode", module_update_module_mode, 0}, - {"run-update-procedure", run_update_procedure, 0}, - {"ensure-core-worktree", ensure_core_worktree, 0}, - {"relative-path", resolve_relative_path, 0}, {"resolve-relative-url", resolve_relative_url, 0}, {"resolve-relative-url-test", resolve_relative_url_test, 0}, {"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}, From patchwork Thu Sep 16 10:32:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atharva Raykar X-Patchwork-Id: 12498613 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90160C433EF for ; Thu, 16 Sep 2021 10:33:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 79C6861108 for ; Thu, 16 Sep 2021 10:33:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236651AbhIPKex (ORCPT ); Thu, 16 Sep 2021 06:34:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236689AbhIPKex (ORCPT ); Thu, 16 Sep 2021 06:34:53 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D62E4C061574 for ; Thu, 16 Sep 2021 03:33:32 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id n18so5695041pgm.12 for ; Thu, 16 Sep 2021 03:33:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5ZsYKhVnL+IuBodtegGy0VCqxe39ceufVO7HEtxfens=; b=RpUniyBgdHVj30RsFte+j/zHy1Anw/a9q1qcx6QN0GdC9kt56FntwpzbXj9yb2riKi VkxiIZf+LiMrg5o12d6JepwAtRTpYhqx/r0aRgZtb025A9bpB6l3A9TxMe0h09+QUkHG CLpMn17ij5oSUdhlHwO3z/994Zf0RcLMF98we4iKtewT1Nyxhu963TIqLw0cCMWJ/hDJ 8UzU/VMj5W2QqJtZDIhWCvKqSdbjxYJXfo4VTdO/YS6H1i8xTq0H9IqrpzhHvvacu/5k 4YObOgKxQGswsUBMuJzwodH8gCd4r29zV4Nj7gDy6CyiLgudMg/Ki28xYGBSF1fm4aYc yVEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5ZsYKhVnL+IuBodtegGy0VCqxe39ceufVO7HEtxfens=; b=32r0obBISFzLQb4nkTGoqq//jmXJikolO9aH2SA5WBOWVw/cLMXcERSNuSEDhNT8KL 10NdAdXN6dL4TXKmHng46vEu/h2EqbFaYDKCSxdbqa/Ya+oJW/cS6yNcqq+qAJT7k2MC CP/hBKfIwUpO2twceGozXpt9vtEEfqThqddSIQ0XIf+VosQcOV3tBpkMwl4cLA4z43os dSF6aDCyLNQmTYYQY4G84HHGmi0a0HWHBmZMUeczVlXyjLht+4DZwb8+sQUSzY8oJJjD nk0DuXEtv+jZla7gVim/pVqUdSpLeNDzOUb8WYb3cD18nfrX1kQg/nC7IVQRuAbQd/C2 e6NA== X-Gm-Message-State: AOAM530nWbXeD1mX19q/1kZUMI93EA8eY5z5KxWi6/8QVI5QJXIM//4T DMICXY81MfMoFIGqBg8ENU0= X-Google-Smtp-Source: ABdhPJwPGr0hWReye3Brf1//QRNay1NaQeyutd0I0tpjzsHPubQCnIPB4DKLsOpm4wFsEnMGrjs8Dw== X-Received: by 2002:a63:4cd:: with SMTP id 196mr4359882pge.239.1631788412463; Thu, 16 Sep 2021 03:33:32 -0700 (PDT) Received: from atharva-on-air.Dlink ([119.82.121.182]) by smtp.gmail.com with ESMTPSA id c199sm2642605pfb.152.2021.09.16.03.33.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Sep 2021 03:33:32 -0700 (PDT) From: Atharva Raykar To: raykar.ath@gmail.com Cc: avarab@gmail.com, christian.couder@gmail.com, emilyshaffer@google.com, git@vger.kernel.org, gitster@pobox.com, jrnieder@gmail.com, kaartic.sivaraam@gmail.com, pc44800@gmail.com, periperidip@gmail.com Subject: [PATCH v2 8/8] submodule--helper: rename helper functions Date: Thu, 16 Sep 2021 16:02:41 +0530 Message-Id: <20210916103241.62376-9-raykar.ath@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210916103241.62376-1-raykar.ath@gmail.com> References: <20210907115932.36068-1-raykar.ath@gmail.com> <20210916103241.62376-1-raykar.ath@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org These two functions were prefixed with 'do' before the shell-to-C conversion because they were utility functions meant to be called by their non-prefixed counterpart. Since those callers don't exist anymore, and these functions can now be used directly, let's rename them to signal this fact. Mentored-by: Christian Couder Mentored-by: Shourya Shukla Signed-off-by: Atharva Raykar --- builtin/submodule--helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 0910af9c71..e5e33be6ea 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2484,7 +2484,7 @@ static int run_update_command(struct update_data *ud, int subforce, struct strin return 0; } -static int do_run_update_procedure(struct update_data *ud, struct string_list *err) +static int run_update_procedure(struct update_data *ud, struct string_list *err) { int subforce = is_null_oid(&ud->suboid) || ud->force; @@ -2646,7 +2646,7 @@ static int push_check(int argc, const char **argv, const char *prefix) return 0; } -static void do_ensure_core_worktree(const char *path) +static void ensure_core_worktree(const char *path) { const struct submodule *sub; const char *cw; @@ -2910,7 +2910,7 @@ static int update_submodule(struct update_data *update_data) char *prefixed_path; struct string_list err = STRING_LIST_INIT_DUP; - do_ensure_core_worktree(update_data->sm_path); + ensure_core_worktree(update_data->sm_path); if (update_data->recursive_prefix) prefixed_path = xstrfmt("%s%s", update_data->recursive_prefix, @@ -2950,7 +2950,7 @@ static int update_submodule(struct update_data *update_data) } if (!oideq(&update_data->oid, &update_data->suboid) || update_data->force) - if (do_run_update_procedure(update_data, &err)) + if (run_update_procedure(update_data, &err)) return 1; if (update_data->recursive) {