From: "Bruce Perry via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Stefan Beller <stefanbeller@gmail.com>,
Emily Shaffer <emilyshaffer@google.com>,
Bruce Perry <bruce.a.perry@gmail.com>,
Bruce Perry <bruce.perry@nrel.gov>
Subject: [PATCH 2/2] clone: no-shallow-submodules clone overrides option in gitmodules
Date: Tue, 02 Jul 2024 19:07:50 +0000 [thread overview]
Message-ID: <1679ab7b7a0db40733ad60ada8b226657782d33e.1719947271.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1740.git.git.1719947271.gitgitgadget@gmail.com>
From: Bruce Perry <bruce.perry@nrel.gov>
When the `--no-shallow-submodules` option is used for cloning, pass
the `--no-recommend-shallow` option to the internal submodule update
command, which will override an option for shallow in .gitmodules
if present. This allows the user to force a non-shallow clone of
the submodules if desired. It brings the behavior in line with
the present documentation, which states the option in gitmodules is
used unless explitcitly overridden by the user. Add a test to confirm
that the override is done when using the clone command (similar to
a current test that validates similar behavior for the submodule
update command).
Signed-off-by: Bruce Perry <bruce.perry@nrel.gov>
---
builtin/clone.c | 4 +++-
t/t5614-clone-submodules-shallow.sh | 16 ++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index 50ccce8902d..63cfb48484c 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -61,7 +61,7 @@ static int option_no_checkout, option_bare, option_mirror, option_single_branch
static int option_single_branch_submodules;
static int option_local = -1, option_no_hardlinks, option_shared;
static int option_no_tags;
-static int option_shallow_submodules;
+static int option_shallow_submodules = -1;
static int option_reject_shallow = -1; /* unspecified */
static int config_reject_shallow = -1; /* unspecified */
static int deepen;
@@ -798,6 +798,8 @@ static int checkout(int submodule_progress, int filter_submodules)
if (option_shallow_submodules == 1)
strvec_push(&cmd.args, "--depth=1");
+ else if (option_shallow_submodules == 0)
+ strvec_push(&cmd.args, "--no-recommend-shallow");
if (max_jobs != -1)
strvec_pushf(&cmd.args, "--jobs=%d", max_jobs);
diff --git a/t/t5614-clone-submodules-shallow.sh b/t/t5614-clone-submodules-shallow.sh
index b23c7d085aa..8e2965248a2 100755
--- a/t/t5614-clone-submodules-shallow.sh
+++ b/t/t5614-clone-submodules-shallow.sh
@@ -102,6 +102,22 @@ test_expect_success 'clone follows shallow recommendation' '
)
'
+test_expect_success 'no-shallow-submodules clone option overrides gitmodules' '
+ test_when_finished "rm -rf super_clone" &&
+ test_config_global protocol.file.allow always &&
+ git clone --recurse-submodules --no-shallow-submodules --no-local "file://$pwd/." super_clone &&
+ (
+ cd super_clone &&
+ git log --oneline >lines &&
+ test_line_count = 4 lines
+ ) &&
+ (
+ cd super_clone/sub &&
+ git log --oneline --all >lines &&
+ test_line_count = 5 lines
+ )
+'
+
test_expect_success 'get unshallow recommended shallow submodule' '
test_when_finished "rm -rf super_clone" &&
test_config_global protocol.file.allow always &&
--
gitgitgadget
next prev parent reply other threads:[~2024-07-02 19:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-02 19:07 [PATCH 0/2] clone: shallow-submodules should be single-branch by default Bruce Perry via GitGitGadget
2024-07-02 19:07 ` [PATCH 1/2] " Bruce Perry via GitGitGadget
2024-07-02 19:07 ` Bruce Perry via GitGitGadget [this message]
2024-07-02 19:12 ` [PATCH 0/2] " rsbecker
2024-07-03 5:00 ` Bruce Perry
2024-07-03 14:05 ` rsbecker
2024-07-25 17:10 ` Bruce Perry
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1679ab7b7a0db40733ad60ada8b226657782d33e.1719947271.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=bruce.a.perry@gmail.com \
--cc=bruce.perry@nrel.gov \
--cc=emilyshaffer@google.com \
--cc=git@vger.kernel.org \
--cc=stefanbeller@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).