From patchwork Wed Oct 13 05:17:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atharva Raykar X-Patchwork-Id: 12554521 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69994C433FE for ; Wed, 13 Oct 2021 05:18:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 50AEF60E8B for ; Wed, 13 Oct 2021 05:18:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237593AbhJMFUj (ORCPT ); Wed, 13 Oct 2021 01:20:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237569AbhJMFUi (ORCPT ); Wed, 13 Oct 2021 01:20:38 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F264CC061570 for ; Tue, 12 Oct 2021 22:18:35 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id t15so1384629pfl.13 for ; Tue, 12 Oct 2021 22:18:35 -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=qfSym00iVBaM1DxV96eOqz2gjEPxdle5KZHz9EqKflw=; b=Ii2768tPiCyfCRE9i/jnzDxP2RVDo3dAR/OKAGJNlQwuyUtdyGkMTx/75+2hTkYmY2 1J0gwA3dSdtJHm+n1WWyMaHkAjdhM+TQuDmRR64I3yV5LhB89y7juhNGos7vRU7epXwI +3toCKkwZzS9uaQ4W3cgqc8BLaECGnq4iOp3gpScZhCKKdnSmBQvBZkzkRwN8Jxy35yv B0f6dAc/eYNnFgZ80CG8LEekpRRHH8xVa42Do54/O15dYqv2d882iVTSS4PMS6SvjhsM o9u5Rwp10bkRm/RPtMrmY0OXiq9XSgCRSRTdB+Kssg/QPyTdbWKTNgi4StNv3N+wTYTr DIKQ== 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=qfSym00iVBaM1DxV96eOqz2gjEPxdle5KZHz9EqKflw=; b=rFTjFcej4OQAauNBXAEBV7AaRQLkbJBvhacR3KRg9/shFRvVGTFzGtsIT8aI0+iSbw OeCj0eIweFNBtgau9SmDrF/JDlYWlITA7APnqxmWBGrkHb3h23w/12XCBzvmkFoO6/ia R8H2XYhrYAVMoTwo1MYd/YUR6/8vHElfS7rEWsKhqn7aLGndA8U3xdQ6ic8RXqjDvBMM 640rlnyDsyS+KKwopqfNr3XT0zaEzrTeE7ScLQhmPwfckqqcyiHJ6QlcpCKWcI/Da31G 1b0ubnttF0IDToj1U3/00PKXdIivySepEv+ff1qKnIgSSl0rwBIsw2xsz+qaj/FDAFEb 6PPg== X-Gm-Message-State: AOAM533spwRFH9iuugLZVj+WmtjfGfQHzyI86i+duZ4Ta2JxRa/T7V51 S/HTax4JfZG/BxmZX7IZsHg= X-Google-Smtp-Source: ABdhPJw6CCzkRcEM3/Xy+bkxH290p/8VBBkf/mWc+yz4EbyHEB8Dszepo43sznfp+gp8owllmDS4Cg== X-Received: by 2002:a63:7010:: with SMTP id l16mr26016614pgc.32.1634102315570; Tue, 12 Oct 2021 22:18:35 -0700 (PDT) Received: from atharva-on-air.Dlink ([119.82.121.111]) by smtp.gmail.com with ESMTPSA id 12sm12481197pfz.133.2021.10.12.22.18.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Oct 2021 22:18:35 -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 v3 1/9] submodule--helper: split up ensure_core_worktree() Date: Wed, 13 Oct 2021 10:47:57 +0530 Message-Id: <20211013051805.45662-2-raykar.ath@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211013051805.45662-1-raykar.ath@gmail.com> References: <20210916103241.62376-1-raykar.ath@gmail.com> <20211013051805.45662-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 88ce6be69c..764fcb7dba 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2764,17 +2764,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 do_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); @@ -2794,6 +2788,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 Wed Oct 13 05:17:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atharva Raykar X-Patchwork-Id: 12554523 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7866CC433EF for ; Wed, 13 Oct 2021 05:18:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5233B60E8B for ; Wed, 13 Oct 2021 05:18:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237598AbhJMFUq (ORCPT ); Wed, 13 Oct 2021 01:20:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237633AbhJMFUm (ORCPT ); Wed, 13 Oct 2021 01:20:42 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F7B7C06174E for ; Tue, 12 Oct 2021 22:18:39 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id oa12-20020a17090b1bcc00b0019f715462a8so1326416pjb.3 for ; Tue, 12 Oct 2021 22:18:39 -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=Vucoq0/0s1EnRlZ3RZDRggQ9MYfsk7ZPh5/u+9Ud8Dc=; b=Do9eYQqq/HQSczPGQhR3tFtEUQAgJteOcvYajnlAmKz5FsPXvW30HkGbsGvLu0Ppfv P2EmNlNIyhhKpunQEjq6Ayl02aZY+0EZXIXdsKpC+hizuK8ddzB5mNsFB3Rghpk8rwkw Ma1dIR+tO0oUsE1cdySyiw65PvAwKn/+KkuVKH6Sm9wg3kzZULWhUX9WuE8hijFmO5CM 6+wir+cCldImYTBSuwSCSFhluG2gRQ7XKETDSj60k/thVTUEIGM92/Z9AIQMGj8OPoWc OcgnPvj9ax6464xNlp5O+SBf7tgrLt08n46mpwHRWKf2C2gp9W/i+znGzWJGZKdcHkCJ Cb5g== 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=Vucoq0/0s1EnRlZ3RZDRggQ9MYfsk7ZPh5/u+9Ud8Dc=; b=L378cPBubn23GmbwsEF18HQNMsWXVoICQ/TggViXnXaNIJLwFaMh/hxpQTMRcoE5ik TFGbGhP/WrnD4gmTSxICwW9SmDWQ8wm1tE8qFfdyO6TcIX5WVsXr2qDLvui4SapcluEw pcyzpWQWn0jxPcwuXnKBS9Hf7VFUayTysKWL4Koipnu44Cdi7o0AMw8lClypu4azx/Df w/GWlIryD/2z77BTUGG80fqXMz+tiOwXLepZXwgE1kfRknPLJkbNcSrZamSSdF3J3x3T 0gJWQDgXK8bLhmGXtVchEj6MSn3qlpA8MqY28rTOhpJFX6BwiFCnmFizlzSxHt38bQSy cFJw== X-Gm-Message-State: AOAM53129T1KShjYgz65wTBlL7e3hc8opV11xwqiMLrVNZbqRfDIGx2k 33mz5eXyZN47JmyazeT7pVI= X-Google-Smtp-Source: ABdhPJxaQSa4dBMxaW07VVZjlv60CugxukjzAt8F2CDL9Rjre7YK6I/R2ys0DENtnvivuq+0Kf+zUA== X-Received: by 2002:a17:90a:4306:: with SMTP id q6mr11160411pjg.17.1634102319051; Tue, 12 Oct 2021 22:18:39 -0700 (PDT) Received: from atharva-on-air.Dlink ([119.82.121.111]) by smtp.gmail.com with ESMTPSA id 12sm12481197pfz.133.2021.10.12.22.18.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Oct 2021 22:18:38 -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 v3 2/9] submodule--helper: get remote names from any repository Date: Wed, 13 Oct 2021 10:47:58 +0530 Message-Id: <20211013051805.45662-3-raykar.ath@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211013051805.45662-1-raykar.ath@gmail.com> References: <20210916103241.62376-1-raykar.ath@gmail.com> <20211013051805.45662-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 | 39 +++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 764fcb7dba..bbab43230b 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,23 @@ static char *get_default_remote(void) return ret; } +static char *get_default_remote_submodule(const char *module_path) +{ + const char *refname; + struct repository subrepo; + + refname = refs_resolve_ref_unsafe(get_submodule_ref_store(module_path), + "HEAD", 0, NULL, NULL); + repo_submodule_init(&subrepo, the_repository, module_path, null_oid()); + 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; @@ -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 Wed Oct 13 05:17:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atharva Raykar X-Patchwork-Id: 12554525 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32D7FC433FE for ; Wed, 13 Oct 2021 05:18:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C0EB60231 for ; Wed, 13 Oct 2021 05:18:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237624AbhJMFUq (ORCPT ); Wed, 13 Oct 2021 01:20:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237643AbhJMFUp (ORCPT ); Wed, 13 Oct 2021 01:20:45 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BB8BC061714 for ; Tue, 12 Oct 2021 22:18:43 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id f189so340587pfg.12 for ; Tue, 12 Oct 2021 22:18:43 -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=4GWq8VVA/w+P/FFbZu43+9fAT4rqkr1/83y09oKmzEk=; b=NyrfhTcOju5XG+VrP9LYIBkMWJBwDHdW1AzPObAVJ9e3DWWIRG4Kf5E7FRHfvNHD93 PNxja3gpvYg8rXZpEopmZKAJVO+VpEnMCa7QSfO94gm2ewxua0u6B7BEBsUBy0clKdui CUeqKX0IFh6c0yD66vmtnvPXrQt1IdFu4Ertu2qfIrjCeVu6wDCIYgUdfdC6/SSzQvrP tWC263+PuRQ6Cl5u3s5ZCaKYANbn5Am9DB7CUVC6rdxd3UWqHRx9G5Ocj+AGzXtm7238 QrzbaoK/pmWqv7pEqu/Cp7upsyx8YMpfvzVVXVfx6iB1CNlN5+8bBt14Izv4XHwAUQkm Z3/g== 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=4GWq8VVA/w+P/FFbZu43+9fAT4rqkr1/83y09oKmzEk=; b=bejkALv1lvw32hXueKHMpsD6bQbRuSvROAF++zZ+1DLo02TE3XVEHoKTmeYOPIg1w8 dTVb5ezrDDvPpI/Xc6hMX7lgjcZt9kk9+5UuL16v8eL0au6XKiQDiqWGOcslRK/44IGI 1xrTwYWgJ27V2vPHqs/itoGy9uDdo4x6w0D16ImMRB8PaYGxCiomEec7wGAVp9r/7tLe bdAH2os/i3mtyuHOo3FZUDbgy8Afyx4USid86yMUMsD/9V7IsLczAMZdyboLh8dfI7Vn cDfGNNgxBNpzeTo/ehug9deIvBf5RkaIsTjU0DkliiF4IFtrvodaiSiET7OMBNfwiHcs wp8Q== X-Gm-Message-State: AOAM533BULfH9q0bQqUzAQGCgAca7fua0RiQ+hyHjizntd8NERAH7ogi menEYJdguMpfVTF3jRFK6txwzohTQIo= X-Google-Smtp-Source: ABdhPJwLhmf07U+bfE812d4y+fkpjGvs+9e0CyDIebjd/p+wFcVfB0Uyz/gDfy3hMyAJ5rs0RLLNUQ== X-Received: by 2002:a63:454e:: with SMTP id u14mr25905865pgk.314.1634102322660; Tue, 12 Oct 2021 22:18:42 -0700 (PDT) Received: from atharva-on-air.Dlink ([119.82.121.111]) by smtp.gmail.com with ESMTPSA id 12sm12481197pfz.133.2021.10.12.22.18.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Oct 2021 22:18:42 -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 v3 3/9] submodule--helper: rename helpers for update-clone Date: Wed, 13 Oct 2021 10:47:59 +0530 Message-Id: <20211013051805.45662-4-raykar.ath@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211013051805.45662-1-raykar.ath@gmail.com> References: <20210916103241.62376-1-raykar.ath@gmail.com> <20211013051805.45662-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 bbab43230b..f60db966ea 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2466,7 +2466,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), @@ -2474,7 +2474,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; @@ -2495,7 +2495,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; } @@ -2560,7 +2560,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 Wed Oct 13 05:18:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atharva Raykar X-Patchwork-Id: 12554527 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8636DC433F5 for ; Wed, 13 Oct 2021 05:19:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 69D7D60EE9 for ; Wed, 13 Oct 2021 05:19:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237629AbhJMFVD (ORCPT ); Wed, 13 Oct 2021 01:21:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237681AbhJMFUv (ORCPT ); Wed, 13 Oct 2021 01:20:51 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D671C061753 for ; Tue, 12 Oct 2021 22:18:46 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id e7so1202045pgk.2 for ; Tue, 12 Oct 2021 22:18:46 -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=xZOdQLpEk2PWV9JQZWLLZ8CfzQ7SFN1Htnxm6qlEU7w=; b=GCHygXMdH7/CDXCHxFq6vSBpKksb97j8/Mx/vfy8QMbCf+aJvsu1zeaQoXCishp2o7 AxVoqKliWNOe+ekIvE8sdz+vK2cvjT47ohet9nf7dxaaORGs8rm0EmkGlo5f9GTktaE8 hMxqp9ulqXa+mBdFcRYSuk5uBDHGDB6GANJLaAZl0MzCejFvURLwLdICFy4XSPLz5CYV KwyOGsk/dbgnEhyjQywlrGvoGjgy6SWgVyF6YHbLAhnVOwp5yzbnXy9s+wP+kLgP7zom PnGbftS+bfZBYgjasl8KtuX1Ko+b6IgHWxZKz+YAKgiqzam9IJ1vz5+FRJ8/7muaNg0/ 9rUA== 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=xZOdQLpEk2PWV9JQZWLLZ8CfzQ7SFN1Htnxm6qlEU7w=; b=eaWONkDNa0PSUhiF5z8dR8Hl8/QerwZb9HjQMaeO9KehtKBE2d5z9wKkoP1hs+ANAA +eeDlNU2HCKZWFaFPvsN/pIkPSO5qzBCzXsELB2+X/LtusPKtiMJKYfOoHJYuWwODQLp RkIVrqQuF1uTykphbk/8vvqLWGnL+/GSjYIWmYfrsrxdQxrCxIKU4Rg7H7m0yhEFjfzl DsSWvBxSxcKjE4RUmaC40Hx/ons7zWeQhK0SBZ6eb0yc0NkCKnYnOHpMa+qSFRJTiWoS 2bKrt+24RLG/zISEzP0Lw2QwzjrNjSUaa+Z8iSe5cvuGpy6xC19a9U8/EQl5ZIHI3/ay 97Gg== X-Gm-Message-State: AOAM532lmgxcr/WOed2VBf7zKM/Yuwl+tuBn4k4AuW79M6vYwAKXTjYS ck1L8MebCEv/Lcn/XVwbuy4= X-Google-Smtp-Source: ABdhPJzyRadvtN1cSJDmcqR+RfE1b2ZDXitFGuVoam8zapP01R66LcabR/Jb8I8wGEZVFimA+yhBag== X-Received: by 2002:a63:3389:: with SMTP id z131mr12507614pgz.469.1634102326083; Tue, 12 Oct 2021 22:18:46 -0700 (PDT) Received: from atharva-on-air.Dlink ([119.82.121.111]) by smtp.gmail.com with ESMTPSA id 12sm12481197pfz.133.2021.10.12.22.18.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Oct 2021 22:18:45 -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 v3 4/9] submodule--helper: refactor get_submodule_displaypath() Date: Wed, 13 Oct 2021 10:48:00 +0530 Message-Id: <20211013051805.45662-5-raykar.ath@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211013051805.45662-1-raykar.ath@gmail.com> References: <20210916103241.62376-1-raykar.ath@gmail.com> <20211013051805.45662-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 f60db966ea..5b4f1dbcbd 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 Wed Oct 13 05:18:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atharva Raykar X-Patchwork-Id: 12554533 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6111FC433F5 for ; Wed, 13 Oct 2021 05:19:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4AE1060E8B for ; Wed, 13 Oct 2021 05:19:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237683AbhJMFVS (ORCPT ); Wed, 13 Oct 2021 01:21:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237633AbhJMFUx (ORCPT ); Wed, 13 Oct 2021 01:20:53 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ECBBC061714 for ; Tue, 12 Oct 2021 22:18:50 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id k23so1331363pji.0 for ; Tue, 12 Oct 2021 22:18:50 -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=3CB00U6KchGlEdE4K8+5i37LJ+Qu7UdCj3Ax3kaK1RQ=; b=GnhtWQ/xQkjgwMkussjVUJXTWv3kNrIWmIBATQnq/x6wwEL0azM1bQYJZw/l52mTER MgNvTFsrl2LAudmI+r2PtnfVbAA+USZhDbctQamJlAtZ4SdqE5AyLFSc25mA/dp63E/H il9Al/mqFOXBLcK8Q1WkOGKnoWgguuYSesK93gVTBwWo6mzfojXto6SLAr2KBJAb3eUT Oo6vDjSVtviSifMumbDqAWgb+Bpwg8RCsXbxZKPwYmUhlLZhA4ij9IiUuhDO0/tuY3dU JeCjNF0a48dS6/CuiUbqq+5ql6VTWayghvzwhVjHMiiPOHT/op7krMyvCsMDJHgIXwGm eF3Q== 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=3CB00U6KchGlEdE4K8+5i37LJ+Qu7UdCj3Ax3kaK1RQ=; b=KFiEnm+frYCbrxpGME/wkEqsi3EBKdV2fTt76HJfloUTnbcJZHgNp5W8NfzreC++si WzLTWcMaD2IKoW4cNwelsZje4I4iVFZzhJRG9Q2/HVEe0sqXf6Pve1XLdD3TSsjTQodS wShAkwZkxNGZCKs+CNM0HmdbWOg1B7asm7Zc5XU5//sMz6G9YB3gZSH+JOl6CbHaXYlz jHtbLYKbZ03hZvrb9cTfBKffJ06kz8HTeU0NNp66re0K0SsLVz1AF7/mWPjNS03RO4eX 4l80jRFgdzPszUPonEgPDSgmJmQpq6L4SXTU33jtqS7argJhdWwzjIdMm5XOaH393zlk Sh6A== X-Gm-Message-State: AOAM532ZxiixOeW228SlxlNnhBOZ08d5DXiQeaDfq1Q5B8fJTeyD6B9L 65SYjEp28VJ8kyDbxpQ0Q5k= X-Google-Smtp-Source: ABdhPJyPGyCaxSbnNuxuqoaP1xG1Djay1e36Rs75BiVtSukYmByo26839ulrJuHOy2Is4TfAw6tnVg== X-Received: by 2002:a17:90b:2349:: with SMTP id ms9mr11167852pjb.45.1634102329760; Tue, 12 Oct 2021 22:18:49 -0700 (PDT) Received: from atharva-on-air.Dlink ([119.82.121.111]) by smtp.gmail.com with ESMTPSA id 12sm12481197pfz.133.2021.10.12.22.18.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Oct 2021 22:18:49 -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 v3 5/9] submodule--helper: allow setting superprefix for init_submodule() Date: Wed, 13 Oct 2021 10:48:01 +0530 Message-Id: <20211013051805.45662-6-raykar.ath@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211013051805.45662-1-raykar.ath@gmail.com> References: <20210916103241.62376-1-raykar.ath@gmail.com> <20211013051805.45662-1-raykar.ath@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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 --- 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 5b4f1dbcbd..74f084a9c9 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 { 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); @@ -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 Wed Oct 13 05:18:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atharva Raykar X-Patchwork-Id: 12554531 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B252C433F5 for ; Wed, 13 Oct 2021 05:19:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 53D8360E8B for ; Wed, 13 Oct 2021 05:19:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237631AbhJMFVM (ORCPT ); Wed, 13 Oct 2021 01:21:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237699AbhJMFVD (ORCPT ); Wed, 13 Oct 2021 01:21:03 -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 B578AC061762 for ; Tue, 12 Oct 2021 22:18:53 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id 75so1201265pga.3 for ; Tue, 12 Oct 2021 22:18:53 -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=2Qh1a/wdPmwsVWdqNOWX0JbkE/w6lpaxZJwFH6/+zLs=; b=eboL/BusfPa3vuHrf17fTuASLrsAu32ZGu9tG2IdOvIW3n6drVbV62+Dn+bU2VKfM6 SYCcoyovHMdRataZpqLA3Xn9uuOE5vKi6P1Kx9Kdfk3cc2Vjb0LnhR+e19YuQk3YNdW8 YSRKZPv4a9ofDmyr6I/v7n5BIYXVt+BBNNqvYSqa0WXAQiSvLae79ERiWkYWdzki2FSP d3C1rtyEd77aNb2WF54b8rvn12u2ouD23chmQK30TK2aW7B6Exrh4s+0zHTHxCmUjhEb ph17uHW+hpAKSMlWKprovdqA5wpxRhgWdaUXHVtfP113n9cr4ufRf4Cjt5D0VQXZEGNg PRAw== 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=2Qh1a/wdPmwsVWdqNOWX0JbkE/w6lpaxZJwFH6/+zLs=; b=RcFaD1I/V8QE102QaRpfMdkkOxzyER/f4DxTBwvGA1OFgc8ZMMdbjP95g8LAbtW9wS lWqNDW2fLTpqSFy5aNtUlGydxtNVTecQ9oVGu1/6rV1Vwzwh2hzgh2i25s9pLCa2WSFL Ia+lvIeDvlK7RdGPiJVePMMyVCwB6DSO/MtEKsmAIafi18qgye4FVGvoQVoRydTwOPyE BmH3uTj5Bat4mfXTF97P3lisKph0Vdmb979TOLVyXXo72AA90jijj6KbFg8aXABk5zgO 67CpWcRH2w8Wu1fwtpasT19TwYM40ihh1ZsJEy5zeOadAhPaB69T91IN5nvSkXhHTVLn RXXg== X-Gm-Message-State: AOAM531sZl8nj4GecaL06EL0fxTzKAzDfkbw0Ub4G4fg8hsibNp0ZS9l MYpOiN9Y8yRcKVplmckQCBg= X-Google-Smtp-Source: ABdhPJzV15R7jBswyk3Ke+hPognOCiVzt4NtCH2JnwW6OryQMPSCvtRoWrIrafxtTkFArs2q57EDzA== X-Received: by 2002:a62:ce01:0:b0:44c:569c:5c3e with SMTP id y1-20020a62ce01000000b0044c569c5c3emr35926358pfg.77.1634102333320; Tue, 12 Oct 2021 22:18:53 -0700 (PDT) Received: from atharva-on-air.Dlink ([119.82.121.111]) by smtp.gmail.com with ESMTPSA id 12sm12481197pfz.133.2021.10.12.22.18.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Oct 2021 22:18:53 -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 v3 6/9] submodule--helper: run update using child process struct Date: Wed, 13 Oct 2021 10:48:02 +0530 Message-Id: <20211013051805.45662-7-raykar.ath@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211013051805.45662-1-raykar.ath@gmail.com> References: <20210916103241.62376-1-raykar.ath@gmail.com> <20211013051805.45662-1-raykar.ath@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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 --- 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 74f084a9c9..640b3bd220 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2342,47 +2342,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 Wed Oct 13 05:18:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atharva Raykar X-Patchwork-Id: 12554535 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7ADA1C433EF for ; Wed, 13 Oct 2021 05:19:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6269860231 for ; Wed, 13 Oct 2021 05:19:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237682AbhJMFVR (ORCPT ); Wed, 13 Oct 2021 01:21:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237707AbhJMFVD (ORCPT ); Wed, 13 Oct 2021 01:21:03 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B0BDC061765 for ; Tue, 12 Oct 2021 22:18:57 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id 66so1175121pgc.9 for ; Tue, 12 Oct 2021 22:18:57 -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=p8UhSVTCIzhbZ80oRhq3vnqAUYKy+YMgYiF3HNWQEHE=; b=B/ea+O+S01rW24GE9X8C1JYPqNWXnJCaMAiljb0i4Gw6wJa4OPlFJu8rBhH81krulg O8boUz1IG8YO+PP4JXcJ6yBgYWZICpU0lwtCI2GcAsCl0EKZIeTF/BnL8MRSw8z7sSC0 8qzlN/u3xUru8B4GO8t17R+3btAjj9cHgvk48qqrCscJ0LZYrV3kD7Nw3S7vZdpuI9Bh e6bg/bULpKuFVjnhbqjeC9A+uj8Mjmxcu12LsIZYOZCrMn+n8jKHY7AXMiqVXD/hGenA W97mquJ132BxbMbB3h5QzpbwwIqK2wh4/SpnxhbUD0RQRFpIJ+H2MA2zeEX3Fd5unqH9 yaEg== 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=p8UhSVTCIzhbZ80oRhq3vnqAUYKy+YMgYiF3HNWQEHE=; b=pgPPAQ2Ogdxi0TT4YsUe1+K0jaMehRNytCe5mJwXS4lVX83PO8goqJKB8V3NCpdRC2 jrIQfCzTW3MeHGv/kwS6mzu31zdmGr27w1ptBVuxTnXJH9UQ7CaychI95TtSjKjOADLF fcMQVkpqDO3d7p5z7t2g8u1/nmDCqMPbNHFiR1BtRYhoyEm+YBQarMdAtl/H625b/zUQ 7GJiIdXa9MEfw4yNQbfWoTi0glIzUOeSt/5rn+eBDz3XFBptrnEGsr2C0val0CRK/ylP XYy03mXir7SOv/p1dAD4rlyjJQ1Ij0Y4JoBx0Y+wa8mU1Si7oTns9uidVgxd+9s0JUph z9Tg== X-Gm-Message-State: AOAM532Y0bc+YzjJSfrDj6D0L1lr7EcJlCD50oXLx+K2cd/8zb+LUSSZ 23MNLlsroGDWHPEX5hexlvU= X-Google-Smtp-Source: ABdhPJxfYIGKD9y0+nK5pUmb5t1/BbEh3FwGXIyaYFcWBfjORIGkmN6AtptWDaWz1YCiFh641Eohbw== X-Received: by 2002:a05:6a00:1634:b0:44b:7184:5ec4 with SMTP id e20-20020a056a00163400b0044b71845ec4mr35561331pfc.40.1634102336998; Tue, 12 Oct 2021 22:18:56 -0700 (PDT) Received: from atharva-on-air.Dlink ([119.82.121.111]) by smtp.gmail.com with ESMTPSA id 12sm12481197pfz.133.2021.10.12.22.18.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Oct 2021 22:18:56 -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 v3 7/9] submodule: move core cmd_update() logic to C Date: Wed, 13 Oct 2021 10:48:03 +0530 Message-Id: <20211013051805.45662-8-raykar.ath@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211013051805.45662-1-raykar.ath@gmail.com> References: <20210916103241.62376-1-raykar.ath@gmail.com> <20211013051805.45662-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 in the same process. 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 | 462 +++++++++++++++++++++++++++++++----- git-submodule.sh | 145 +---------- 2 files changed, 410 insertions(+), 197 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 640b3bd220..3049628f88 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2010,7 +2010,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; @@ -2033,19 +2032,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) @@ -2340,13 +2383,21 @@ 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 child_process cp = CHILD_PROCESS_INIT; char *oid = oid_to_hex(&ud->oid); + struct strbuf out = STRBUF_INIT; int must_die_on_failure = 0; + 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; + + switch (strategy.type) { case SM_UPDATE_CHECKOUT: cp.git_cmd = 1; strvec_pushl(&cp.args, "checkout", "-q", NULL); @@ -2369,80 +2420,75 @@ static int run_update_command(struct update_data *ud, int subforce) break; case SM_UPDATE_COMMAND: cp.use_shell = 1; - strvec_push(&cp.args, ud->update_strategy.command); + 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(&cp.args, oid); 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'"), - 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)); + 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; @@ -2469,7 +2515,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) @@ -2574,6 +2620,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")), @@ -2631,7 +2678,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; } @@ -3002,6 +3049,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; @@ -3360,6 +3692,7 @@ static int module_add(int argc, const char **argv, const char *prefix) return 0; } + #define SUPPORT_SUPER_PREFIX (1<<0) struct cmd_struct { @@ -3373,6 +3706,7 @@ static struct cmd_struct commands[] = { {"name", module_name, 0}, {"clone", module_clone, 0}, {"add", module_add, SUPPORT_SUPER_PREFIX}, + {"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 652861aa66..bcd8b92aab 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 # @@ -361,133 +347,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 Wed Oct 13 05:18:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atharva Raykar X-Patchwork-Id: 12554529 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7721CC433EF for ; Wed, 13 Oct 2021 05:19:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E98260EE9 for ; Wed, 13 Oct 2021 05:19:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237605AbhJMFVL (ORCPT ); Wed, 13 Oct 2021 01:21:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237530AbhJMFVD (ORCPT ); Wed, 13 Oct 2021 01:21:03 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2CDFC061570 for ; Tue, 12 Oct 2021 22:19:00 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id n11so1009590plf.4 for ; Tue, 12 Oct 2021 22:19:00 -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=/06YRsnW/qTZbhYX7jaSYL7zc6WH4rpY1sjrubjcBMA=; b=mtHcM/dNEnWeXXOKKr36/kCB5gVCbbAQV0IFf4v746Gpg9b641Rlfd/+WYm12rjqT2 4Z1DdczFtAD8aSAqWVrak7vEfKyfqRn0I78tzZTJt1GGby49xctQitxLnzvbNEkvydIQ yHR7/TyY1hsCpk1W7blzUhllNddEAKma6ZlIH7n9Ym0RMo1wzzQPQafWobsFL4m3CPt/ 5Uu3KiejdejFj4tes5ejRPsYMUqUiNGMqxd7r6oyiuV5ijuXvuKc2Fmg6q+qStfLDx+p N7cNJAJJiTseC0gAb37o2evGv00I5bsNFhnx44W5PegKEQUvzqpDpmhBZwbk9rhOJ6xu gWOQ== 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=/06YRsnW/qTZbhYX7jaSYL7zc6WH4rpY1sjrubjcBMA=; b=K4pzQIKtbX5GNij8IF3nsgOj1f4J/YbA+dW4oKWasncXP+8MheSrQnyb0MBn4lTOTc LL9ZaAz1adTI/b+3xMqs9nIEOM/h0B+jj27RtmjBG0bD4LaTGr6NyLrPR0Jeouw2rHDU 2QZTlYqPajW82OiGg7k6IOY5E9my6KscdWw5SeDsP+9DY/dDT7uxvBBmzzyIkqCLdDYC xnwugGrovslynaLU34epf1eP2n/n6xWNFym22CbzyYN1FucuTQgLMlrQtpz9GPVpH+rb 75CDaNHM2wOBkpFwRWU9cX8VSH60iwzv/VqLUbjddWKC63s8eWgjwsIB5cL4tyhe7uSu Z1Dg== X-Gm-Message-State: AOAM533spkvy2ItPF/6yQIwVaqv7g2L/3AHD5ouMxmaVzC6P21grEqMD HvhXcmleM84cPhq/VQvOAoE= X-Google-Smtp-Source: ABdhPJyHiIcTdo309yDqbyUkoouWHDcomfur0nv4SltZcmACC6xyiMhz2Cmwb+bWKro9nBjE4q3J8A== X-Received: by 2002:a17:90b:3b85:: with SMTP id pc5mr11138812pjb.74.1634102340457; Tue, 12 Oct 2021 22:19:00 -0700 (PDT) Received: from atharva-on-air.Dlink ([119.82.121.111]) by smtp.gmail.com with ESMTPSA id 12sm12481197pfz.133.2021.10.12.22.18.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Oct 2021 22:19:00 -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 v3 8/9] submodule--helper: remove unused helpers Date: Wed, 13 Oct 2021 10:48:04 +0530 Message-Id: <20211013051805.45662-9-raykar.ath@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211013051805.45662-1-raykar.ath@gmail.com> References: <20210916103241.62376-1-raykar.ath@gmail.com> <20211013051805.45662-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. 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 | 233 ------------------------------------ 1 file changed, 233 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 3049628f88..0d6e65bd6c 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, 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]); @@ -1960,29 +1945,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; @@ -2518,182 +2480,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; - 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; @@ -2852,19 +2638,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; @@ -3707,16 +3480,10 @@ static struct cmd_struct commands[] = { {"clone", module_clone, 0}, {"add", module_add, SUPPORT_SUPER_PREFIX}, {"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}, {"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 Wed Oct 13 05:18:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atharva Raykar X-Patchwork-Id: 12554537 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FCD0C433FE for ; Wed, 13 Oct 2021 05:19:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5173F60E8B for ; Wed, 13 Oct 2021 05:19:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237692AbhJMFVU (ORCPT ); Wed, 13 Oct 2021 01:21:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237650AbhJMFVJ (ORCPT ); Wed, 13 Oct 2021 01:21:09 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C48DC061714 for ; Tue, 12 Oct 2021 22:19:05 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id g184so1189475pgc.6 for ; Tue, 12 Oct 2021 22:19:05 -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=NzV8RB7URs90yC/jVzjYQqqva4SIwy/oMHW2og6DwE8=; b=a0NVFe3UlMDKVi7B4df8F1G1vfTnBXxpWyevPsACzHXyQ4gCjAKai2aQRL7vS0VAF1 cTOJb0oycuJ+7n4NG6JWVhFYiepmUCPbWBqkJu8apYBeRplOtp5M4tDauS9GEFrjHbb+ RiHc9nUlJILu5EwtOqVzrAfnfjQwOpk4RGeOk2gJj6S9J2A9A546znOYMlP87Q6Ta+pl xFouuwqnjXCURuFobaU8cmVf5fjdXXaKCE88vrDEhvyJQJegOKN70f6uvCO4Z3jRiOJg ZYYlI/wd7d1PAct3zWu7vbRn7zZGn8Sy2R1qR0BZj5/r51tj5TveTt8syJ5z0txgXl+E wNLQ== 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=NzV8RB7URs90yC/jVzjYQqqva4SIwy/oMHW2og6DwE8=; b=JgbhTDVr/9t/+F/TPm5KrxKlwvjoS1N75zx68SVxe+UYbqEo3T9AEQvRHw6kfpIwUL VPEmvyeERhXht+KCI9LmyMJ/YcDo1fgfYC/rofVD4SguKJDT0oo4TaZCngJH7Z4uYjTG b7yicc2HO8DhslTSzd8LVM9VNlnHI0Fdeh5N1UqnSD82NPomdOWm41H8LaIdKP+ePp3f 8HxJUeK1oh/bQ0Zhke8Ao+3LS71xcrUKsmJ0lMZQtkTu8vbFxsRMsBEJlkJQirl+VXjt LeEfaIApGUacsEyhNBwtAFSrKkQLQxQcyiWbwnCRrFpZ5zzmkO11Ylh+acqpeChfBqxz nB5A== X-Gm-Message-State: AOAM533+RY0nnNthegmUYBx4AKBo5bkeb/Dw8MWuE1TYc/m5EVjsQci3 sfCnrVKbPSIZiPzFjRad27w= X-Google-Smtp-Source: ABdhPJw6cEvJFgPhLY7ZVJbAHciuF1knp3KEz+3fMAdJQdnr6YbMfUCudkfXdvkmlvHW064XvDep0A== X-Received: by 2002:a05:6a00:16cb:b0:44b:bd38:e068 with SMTP id l11-20020a056a0016cb00b0044bbd38e068mr35817698pfc.34.1634102344925; Tue, 12 Oct 2021 22:19:04 -0700 (PDT) Received: from atharva-on-air.Dlink ([119.82.121.111]) by smtp.gmail.com with ESMTPSA id 12sm12481197pfz.133.2021.10.12.22.19.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Oct 2021 22:19:04 -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 v3 9/9] submodule--helper: rename helper functions Date: Wed, 13 Oct 2021 10:48:05 +0530 Message-Id: <20211013051805.45662-10-raykar.ath@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211013051805.45662-1-raykar.ath@gmail.com> References: <20210916103241.62376-1-raykar.ath@gmail.com> <20211013051805.45662-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 0d6e65bd6c..82d68650e8 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2450,7 +2450,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; @@ -2612,7 +2612,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 char *cw; struct repository subrepo; @@ -2871,7 +2871,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, @@ -2911,7 +2911,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) {