{"thread":{"id":"61716","subject":"[PATCH 0/2] clone: shallow-submodules should be single-branch by default","startedAt":"2024-07-02T19:07:54Z","lastAt":"2024-07-25T17:10:32Z","messageCount":7,"participants":["Bruce Perry via GitGitGadget","rsbecker@nexbridge.com","Bruce Perry"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"497985","messageId":"pull.1740.git.git.1719947271.gitgitgadget@gmail.com","threadId":"61716","inReplyTo":null,"subject":"[PATCH 0/2] clone: shallow-submodules should be single-branch by default","fromName":"Bruce Perry via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2024-07-02T19:07:48Z","receivedAt":"2024-07-02T19:07:54Z","isPatch":true,"sender":{"key":"bruce.a.perry@gmail.com","avatar":null},"body":"I noticed a couple places where the behavior of recursive clones for shallow\nsubmodules does not match what is implied by the documentation. Shallow\nsubmodules should be, but aren't, single branch by default. It would also be\nuseful to allow users to override the shallow specification in gitmodules on\nthe command line for clones as they can for submodule update. The\nmodification here for the former is a bit ugly, but hopefully at least gets\nthe point across to start a discussion. First time submitting a patch here,\nhopefully I'm getting the process right.\n\nBruce Perry (2):\n  clone: shallow-submodules should be single-branch by default\n  clone: no-shallow-submodules clone overrides option in gitmodules\n\n Documentation/git-clone.txt         |  3 ++\n Documentation/gitmodules.txt        |  4 +--\n builtin/clone.c                     | 10 ++++--\n t/t5614-clone-submodules-shallow.sh | 52 +++++++++++++++++++++++------\n 4 files changed, 53 insertions(+), 16 deletions(-)\n\n\nbase-commit: daed0c68e94967bfbb3f87e15f7c9090dc1aa1e1\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1740%2Fbaperry2%2Fsubmods-clone-bug-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1740/baperry2/submods-clone-bug-v1\nPull-Request: https://github.com/git/git/pull/1740\n-- \ngitgitgadget\n"},{"id":"497986","messageId":"3e57c2eacfcd604510404481f366cf3755260c2c.1719947271.git.gitgitgadget@gmail.com","threadId":"61716","inReplyTo":"pull.1740.git.git.1719947271.gitgitgadget@gmail.com","subject":"[PATCH 1/2] clone: shallow-submodules should be single-branch by default","fromName":"Bruce Perry via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2024-07-02T19:07:49Z","receivedAt":"2024-07-02T19:07:55Z","isPatch":true,"sender":{"key":"bruce.a.perry@gmail.com","avatar":null},"body":"From: Bruce Perry <bruce.perry@nrel.gov>\n\nRecursive cloning with with the `--shallow-submodules` command\nline option (or the `shallow = true` option in .gitmodules) and\nno specification of `--[no-]single-branch` does result in a\nshallow submodule clone, but obtains all available branches.\nThis behavior is unexpected because in other circumstances\nshallow clones imply single-branch clones. It also violates the\ndocumented behavior: the documentation states that performing a\nclone with `--recurse-submodules` is equivalent to doing a\nnonrecursive clone then immediately running `git submodule\nupdate --init --recursive`. However, with the `shallow = true`\noption in .gitmodules, the former results in a shallow but not\nsingle-branch clone of the submodules, while the latter results\nsubmodules that are both shallow and single-branch.\n\nModify the logic for git clone with `--recurse-submodules` so\nthat if no option is specified for `--[no-]single-branch`, then\nno `--[no-]single-branch` option is passed to the internal call\nto `git submodule update --init --recursive`. As a result, the\ndefault will be used, which is to make shallow clones also\nsingle-branch and non-shallow clones multi-branch.\n\nModify the tests for shallow-submodules so that the submodule\nhas multiple branches and the expected behavior in terms of\nobtaining branches is validated: shallow submodules must also\nbe single-branch, while non-shallow submodules must obtain\nboth branches.\n\nMake a slight clarification to the documentation regarding\nthe above behavior, although primarily the effect is to bring\nthe behavior in line with the present documentation.\n\nSigned-off-by: Bruce Perry <bruce.perry@nrel.gov>\n---\n Documentation/git-clone.txt         |  3 +++\n Documentation/gitmodules.txt        |  4 ++--\n builtin/clone.c                     |  6 +++--\n t/t5614-clone-submodules-shallow.sh | 36 ++++++++++++++++++++---------\n 4 files changed, 34 insertions(+), 15 deletions(-)\n\ndiff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt\nindex 5de18de2ab8..69248421390 100644\n--- a/Documentation/git-clone.txt\n+++ b/Documentation/git-clone.txt\n@@ -297,6 +297,9 @@ or `--mirror` is given)\n \n `--`[`no-`]`shallow-submodules`::\n \tAll submodules which are cloned will be shallow with a depth of 1.\n+\tAlso implies `--single-branch` for the submodule clones\n+\tunless `--no-single-branch` is passed, in which case histories near\n+\tthe tips of all branches of the cloned submodules are fetched.\n \n `--`[`no-`]`remote-submodules`::\n \tAll submodules which are cloned will use the status of the submodule's\ndiff --git a/Documentation/gitmodules.txt b/Documentation/gitmodules.txt\nindex d9bec8b1875..c8160cd1df7 100644\n--- a/Documentation/gitmodules.txt\n+++ b/Documentation/gitmodules.txt\n@@ -95,8 +95,8 @@ affected by this setting.\n \n submodule.<name>.shallow::\n \tWhen set to true, a clone of this submodule will be performed as a\n-\tshallow clone (with a history depth of 1) unless the user explicitly\n-\tasks for a non-shallow clone.\n+\tshallow clone (single branch with a history depth of 1) unless the\n+\tuser explicitly asks for a non-shallow clone.\n \n NOTES\n -----\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex b28f88eb43d..50ccce8902d 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -58,6 +58,7 @@ static const char * const builtin_clone_usage[] = {\n };\n \n static int option_no_checkout, option_bare, option_mirror, option_single_branch = -1;\n+static int option_single_branch_submodules;\n static int option_local = -1, option_no_hardlinks, option_shared;\n static int option_no_tags;\n static int option_shallow_submodules;\n@@ -816,8 +817,8 @@ static int checkout(int submodule_progress, int filter_submodules)\n \t\t\tstrvec_pushf(&cmd.args, \"--filter=%s\",\n \t\t\t\t     expand_list_objects_filter_spec(&filter_options));\n \n-\t\tif (option_single_branch >= 0)\n-\t\t\tstrvec_push(&cmd.args, option_single_branch ?\n+\t\tif (option_single_branch_submodules >= 0)\n+\t\t\tstrvec_push(&cmd.args, option_single_branch_submodules ?\n \t\t\t\t\t       \"--single-branch\" :\n \t\t\t\t\t       \"--no-single-branch\");\n \n@@ -997,6 +998,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \n \tif (option_depth || option_since || option_not.nr)\n \t\tdeepen = 1;\n+\toption_single_branch_submodules = option_single_branch;\n \tif (option_single_branch == -1)\n \t\toption_single_branch = deepen ? 1 : 0;\n \ndiff --git a/t/t5614-clone-submodules-shallow.sh b/t/t5614-clone-submodules-shallow.sh\nindex c2a2bb453ee..b23c7d085aa 100755\n--- a/t/t5614-clone-submodules-shallow.sh\n+++ b/t/t5614-clone-submodules-shallow.sh\n@@ -14,10 +14,14 @@ test_expect_success 'setup' '\n \tmkdir sub &&\n \t(\n \t\tcd sub &&\n-\t\tgit init &&\n+\t\tgit init -b main &&\n \t\ttest_commit subcommit1 &&\n \t\ttest_commit subcommit2 &&\n-\t\ttest_commit subcommit3\n+\t\ttest_commit subcommit3 &&\n+\t\tgit checkout -b branch &&\n+\t\ttest_commit branchcommit1 &&\n+\t\ttest_commit branchcommit2 &&\n+\t\tgit checkout main\n \t) &&\n \tgit submodule add \"file://$pwd/sub\" sub &&\n \tgit commit -m \"add submodule\"\n@@ -30,16 +34,18 @@ test_expect_success 'nonshallow clone implies nonshallow submodule' '\n \tgit -C super_clone log --oneline >lines &&\n \ttest_line_count = 3 lines &&\n \tgit -C super_clone/sub log --oneline >lines &&\n-\ttest_line_count = 3 lines\n+\ttest_line_count = 3 lines &&\n+\tgit -C super_clone/sub log --oneline --all >lines &&\n+\ttest_line_count = 5 lines\n '\n \n test_expect_success 'shallow clone with shallow submodule' '\n \ttest_when_finished \"rm -rf super_clone\" &&\n \ttest_config_global protocol.file.allow always &&\n \tgit clone --recurse-submodules --depth 2 --shallow-submodules \"file://$pwd/.\" super_clone &&\n-\tgit -C super_clone log --oneline >lines &&\n+\tgit -C super_clone log --oneline --all >lines &&\n \ttest_line_count = 2 lines &&\n-\tgit -C super_clone/sub log --oneline >lines &&\n+\tgit -C super_clone/sub log --oneline --all >lines &&\n \ttest_line_count = 1 lines\n '\n \n@@ -50,7 +56,9 @@ test_expect_success 'shallow clone does not imply shallow submodule' '\n \tgit -C super_clone log --oneline >lines &&\n \ttest_line_count = 2 lines &&\n \tgit -C super_clone/sub log --oneline >lines &&\n-\ttest_line_count = 3 lines\n+\ttest_line_count = 3 lines  &&\n+\tgit -C super_clone/sub log --oneline --all >lines &&\n+\ttest_line_count = 5 lines\n '\n \n test_expect_success 'shallow clone with non shallow submodule' '\n@@ -60,7 +68,9 @@ test_expect_success 'shallow clone with non shallow submodule' '\n \tgit -C super_clone log --oneline >lines &&\n \ttest_line_count = 2 lines &&\n \tgit -C super_clone/sub log --oneline >lines &&\n-\ttest_line_count = 3 lines\n+\ttest_line_count = 3 lines  &&\n+\tgit -C super_clone/sub log --oneline --all >lines &&\n+\ttest_line_count = 5 lines\n '\n \n test_expect_success 'non shallow clone with shallow submodule' '\n@@ -69,7 +79,7 @@ test_expect_success 'non shallow clone with shallow submodule' '\n \tgit clone --recurse-submodules --no-local --shallow-submodules \"file://$pwd/.\" super_clone &&\n \tgit -C super_clone log --oneline >lines &&\n \ttest_line_count = 3 lines &&\n-\tgit -C super_clone/sub log --oneline >lines &&\n+\tgit -C super_clone/sub log --oneline --all >lines &&\n \ttest_line_count = 1 lines\n '\n \n@@ -87,7 +97,7 @@ test_expect_success 'clone follows shallow recommendation' '\n \t) &&\n \t(\n \t\tcd super_clone/sub &&\n-\t\tgit log --oneline >lines &&\n+\t\tgit log --oneline --all >lines &&\n \t\ttest_line_count = 1 lines\n \t)\n '\n@@ -105,7 +115,9 @@ test_expect_success 'get unshallow recommended shallow submodule' '\n \t(\n \t\tcd super_clone/sub &&\n \t\tgit log --oneline >lines &&\n-\t\ttest_line_count = 3 lines\n+\t\ttest_line_count = 3 lines &&\n+\t\tgit log --oneline --all >lines &&\n+\t\ttest_line_count = 5 lines\n \t)\n '\n \n@@ -124,7 +136,9 @@ test_expect_success 'clone follows non shallow recommendation' '\n \t(\n \t\tcd super_clone/sub &&\n \t\tgit log --oneline >lines &&\n-\t\ttest_line_count = 3 lines\n+\t\ttest_line_count = 3 lines &&\n+\t\tgit log --oneline --all >lines &&\n+\t\ttest_line_count = 5 lines\n \t)\n '\n \n-- \ngitgitgadget\n\n"},{"id":"497987","messageId":"1679ab7b7a0db40733ad60ada8b226657782d33e.1719947271.git.gitgitgadget@gmail.com","threadId":"61716","inReplyTo":"pull.1740.git.git.1719947271.gitgitgadget@gmail.com","subject":"[PATCH 2/2] clone: no-shallow-submodules clone overrides option in gitmodules","fromName":"Bruce Perry via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2024-07-02T19:07:50Z","receivedAt":"2024-07-02T19:07:57Z","isPatch":true,"sender":{"key":"bruce.a.perry@gmail.com","avatar":null},"body":"From: Bruce Perry <bruce.perry@nrel.gov>\n\nWhen the `--no-shallow-submodules` option is used for cloning, pass\nthe `--no-recommend-shallow` option to the internal submodule update\ncommand, which will override an option for shallow in .gitmodules\nif present. This allows the user to force a non-shallow clone of\nthe submodules if desired. It brings the behavior in line with\nthe present documentation, which states the option in gitmodules is\nused unless explitcitly overridden by the user. Add a test to confirm\nthat the override is done when using the clone command (similar to\na current test that validates similar behavior for the submodule\nupdate command).\n\nSigned-off-by: Bruce Perry <bruce.perry@nrel.gov>\n---\n builtin/clone.c                     |  4 +++-\n t/t5614-clone-submodules-shallow.sh | 16 ++++++++++++++++\n 2 files changed, 19 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 50ccce8902d..63cfb48484c 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -61,7 +61,7 @@ static int option_no_checkout, option_bare, option_mirror, option_single_branch\n static int option_single_branch_submodules;\n static int option_local = -1, option_no_hardlinks, option_shared;\n static int option_no_tags;\n-static int option_shallow_submodules;\n+static int option_shallow_submodules = -1;\n static int option_reject_shallow = -1;    /* unspecified */\n static int config_reject_shallow = -1;    /* unspecified */\n static int deepen;\n@@ -798,6 +798,8 @@ static int checkout(int submodule_progress, int filter_submodules)\n \n \t\tif (option_shallow_submodules == 1)\n \t\t\tstrvec_push(&cmd.args, \"--depth=1\");\n+\t\telse if (option_shallow_submodules == 0)\n+\t\t\tstrvec_push(&cmd.args, \"--no-recommend-shallow\");\n \n \t\tif (max_jobs != -1)\n \t\t\tstrvec_pushf(&cmd.args, \"--jobs=%d\", max_jobs);\ndiff --git a/t/t5614-clone-submodules-shallow.sh b/t/t5614-clone-submodules-shallow.sh\nindex b23c7d085aa..8e2965248a2 100755\n--- a/t/t5614-clone-submodules-shallow.sh\n+++ b/t/t5614-clone-submodules-shallow.sh\n@@ -102,6 +102,22 @@ test_expect_success 'clone follows shallow recommendation' '\n \t)\n '\n \n+test_expect_success 'no-shallow-submodules clone option overrides gitmodules' '\n+\ttest_when_finished \"rm -rf super_clone\" &&\n+\ttest_config_global protocol.file.allow always &&\n+\tgit clone --recurse-submodules --no-shallow-submodules --no-local \"file://$pwd/.\" super_clone &&\n+\t(\n+\t\tcd super_clone &&\n+\t\tgit log --oneline >lines &&\n+\t\ttest_line_count = 4 lines\n+\t) &&\n+\t(\n+\t\tcd super_clone/sub &&\n+\t\tgit log --oneline --all >lines &&\n+\t\ttest_line_count = 5 lines\n+\t)\n+'\n+\n test_expect_success 'get unshallow recommended shallow submodule' '\n \ttest_when_finished \"rm -rf super_clone\" &&\n \ttest_config_global protocol.file.allow always &&\n-- \ngitgitgadget\n"},{"id":"497988","messageId":"07d801daccb3$c1de13e0$459a3ba0$@nexbridge.com","threadId":"61716","inReplyTo":"pull.1740.git.git.1719947271.gitgitgadget@gmail.com","subject":"RE: [PATCH 0/2] clone: shallow-submodules should be single-branch by default","fromName":"","fromEmail":"rsbecker@nexbridge.com","sentAt":"2024-07-02T19:12:12Z","receivedAt":"2024-07-02T19:12:22Z","isPatch":true,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"On Tuesday, July 2, 2024 3:08 PM, Bruce Perry wrote:\n>I noticed a couple places where the behavior of recursive clones for shallow\n>submodules does not match what is implied by the documentation. Shallow\n>submodules should be, but aren't, single branch by default. It would also be useful\n>to allow users to override the shallow specification in gitmodules on the command\n>line for clones as they can for submodule update. The modification here for the\n>former is a bit ugly, but hopefully at least gets the point across to start a discussion.\n>First time submitting a patch here, hopefully I'm getting the process right.\n>\n>Bruce Perry (2):\n>  clone: shallow-submodules should be single-branch by default\n>  clone: no-shallow-submodules clone overrides option in gitmodules\n>\n> Documentation/git-clone.txt         |  3 ++\n> Documentation/gitmodules.txt        |  4 +--\n> builtin/clone.c                     | 10 ++++--\n> t/t5614-clone-submodules-shallow.sh | 52 +++++++++++++++++++++++------\n> 4 files changed, 53 insertions(+), 16 deletions(-)\n>\n>\n>base-commit: daed0c68e94967bfbb3f87e15f7c9090dc1aa1e1\n>Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-\n>1740%2Fbaperry2%2Fsubmods-clone-bug-v1\n>Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-\n>1740/baperry2/submods-clone-bug-v1\n>Pull-Request: https://github.com/git/git/pull/1740\n\nI am concerned about this one. Many CI systems (including Jenkins GitSCM) assume a detached head for submodule clone/checkout. Adding a branch to the mix will change the expected semantics. Am I missing something?\n--Randall\n\n"},{"id":"498013","messageId":"CAJ_CbHX5nyvMy3ZO+YYCWnPhUmS2QZJjTzsePqXT2TEy-LBQfQ@mail.gmail.com","threadId":"61716","inReplyTo":"07d801daccb3$c1de13e0$459a3ba0$@nexbridge.com","subject":"Re: [PATCH 0/2] clone: shallow-submodules should be single-branch by default","fromName":"Bruce Perry","fromEmail":"bruce.a.perry@gmail.com","sentAt":"2024-07-03T05:00:10Z","receivedAt":"2024-07-03T05:00:37Z","isPatch":true,"sender":{"key":"bruce.a.perry@gmail.com","avatar":null},"body":"Randall,\n\nPerhaps I was using imprecise terminology. This change should not\nimpact whether submodule clones land in a detached head state, so it\nshould not impact anything that assumes submodule clones are detached\nhead.\n\nThe change being made is this: \"git clone --recurse-submodules\n--shallow-submodules\" currently gives you a submodule with a detached\nhead at the desired state, but also downloads data for the tips of all\nbranches in the remote being cloned (potentially a lot of unneeded\ndata as in my use case). The modification means the same command would\ngive you a detached head at the desired state, plus the tip of only\nthe default branch in the remote. The modified behavior matches the\ncurrent behavior for a simple \"git clone\" followed by \"git submodule\nupdate --init --recurse--submodules --depth=1\".\n\nThanks,\nBruce\n\n(Resent due to a formatting failure)\n\nOn Tue, Jul 2, 2024, 1:12 PM <rsbecker@nexbridge.com> wrote:\n>\n> On Tuesday, July 2, 2024 3:08 PM, Bruce Perry wrote:\n> >I noticed a couple places where the behavior of recursive clones for shallow\n> >submodules does not match what is implied by the documentation. Shallow\n> >submodules should be, but aren't, single branch by default. It would also be useful\n> >to allow users to override the shallow specification in gitmodules on the command\n> >line for clones as they can for submodule update. The modification here for the\n> >former is a bit ugly, but hopefully at least gets the point across to start a discussion.\n> >First time submitting a patch here, hopefully I'm getting the process right.\n> >\n> >Bruce Perry (2):\n> >  clone: shallow-submodules should be single-branch by default\n> >  clone: no-shallow-submodules clone overrides option in gitmodules\n> >\n> > Documentation/git-clone.txt         |  3 ++\n> > Documentation/gitmodules.txt        |  4 +--\n> > builtin/clone.c                     | 10 ++++--\n> > t/t5614-clone-submodules-shallow.sh | 52 +++++++++++++++++++++++------\n> > 4 files changed, 53 insertions(+), 16 deletions(-)\n> >\n> >\n> >base-commit: daed0c68e94967bfbb3f87e15f7c9090dc1aa1e1\n> >Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-\n> >1740%2Fbaperry2%2Fsubmods-clone-bug-v1\n> >Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-\n> >1740/baperry2/submods-clone-bug-v1\n> >Pull-Request: https://github.com/git/git/pull/1740\n>\n> I am concerned about this one. Many CI systems (including Jenkins GitSCM) assume a detached head for submodule clone/checkout. Adding a branch to the mix will change the expected semantics. Am I missing something?\n> --Randall\n>\n"},{"id":"498029","messageId":"082a01dacd52$056ddf70$10499e50$@nexbridge.com","threadId":"61716","inReplyTo":"CAJ_CbHX5nyvMy3ZO+YYCWnPhUmS2QZJjTzsePqXT2TEy-LBQfQ@mail.gmail.com","subject":"RE: [PATCH 0/2] clone: shallow-submodules should be single-branch by default","fromName":"","fromEmail":"rsbecker@nexbridge.com","sentAt":"2024-07-03T14:05:06Z","receivedAt":"2024-07-03T14:05:22Z","isPatch":true,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"On Wednesday, July 3, 2024 1:00 AM, Bruce Perry wrote:\n>Perhaps I was using imprecise terminology. This change should not impact whether\n>submodule clones land in a detached head state, so it should not impact anything\n>that assumes submodule clones are detached head.\n>\n>The change being made is this: \"git clone --recurse-submodules --shallow-\n>submodules\" currently gives you a submodule with a detached head at the desired\n>state, but also downloads data for the tips of all branches in the remote being\n>cloned (potentially a lot of unneeded data as in my use case). The modification\n>means the same command would give you a detached head at the desired state,\n>plus the tip of only the default branch in the remote. The modified behavior\n>matches the current behavior for a simple \"git clone\" followed by \"git submodule\n>update --init --recurse--submodules --depth=1\".\n>\n>Thanks,\n>Bruce\n>\n>(Resent due to a formatting failure)\n>\n>On Tue, Jul 2, 2024, 1:12 PM <rsbecker@nexbridge.com> wrote:\n>>\n>> On Tuesday, July 2, 2024 3:08 PM, Bruce Perry wrote:\n>> >I noticed a couple places where the behavior of recursive clones for\n>> >shallow submodules does not match what is implied by the\n>> >documentation. Shallow submodules should be, but aren't, single\n>> >branch by default. It would also be useful to allow users to override\n>> >the shallow specification in gitmodules on the command line for\n>> >clones as they can for submodule update. The modification here for the former is\n>a bit ugly, but hopefully at least gets the point across to start a discussion.\n>> >First time submitting a patch here, hopefully I'm getting the process right.\n>> >\n>> >Bruce Perry (2):\n>> >  clone: shallow-submodules should be single-branch by default\n>> >  clone: no-shallow-submodules clone overrides option in gitmodules\n>> >\n>> > Documentation/git-clone.txt         |  3 ++\n>> > Documentation/gitmodules.txt        |  4 +--\n>> > builtin/clone.c                     | 10 ++++--\n>> > t/t5614-clone-submodules-shallow.sh | 52\n>> > +++++++++++++++++++++++------\n>> > 4 files changed, 53 insertions(+), 16 deletions(-)\n>> >\n>> >\n>> >base-commit: daed0c68e94967bfbb3f87e15f7c9090dc1aa1e1\n>> >Published-As:\n>> >https://github.com/gitgitgadget/git/releases/tag/pr-git-\n>> >1740%2Fbaperry2%2Fsubmods-clone-bug-v1\n>> >Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-\n>> >1740/baperry2/submods-clone-bug-v1\n>> >Pull-Request: https://github.com/git/git/pull/1740\n>>\n>> I am concerned about this one. Many CI systems (including Jenkins GitSCM)\n>assume a detached head for submodule clone/checkout. Adding a branch to the mix\n>will change the expected semantics. Am I missing something?\n\nThanks for clearing that up. Fine with me.\nRegards\nRandall\n\n"},{"id":"499369","messageId":"CAJ_CbHWMiU0+6kB7mxE+n3x7N4A6GugMkmEQwHLzZiF-_GrxbQ@mail.gmail.com","threadId":"61716","inReplyTo":"082a01dacd52$056ddf70$10499e50$@nexbridge.com","subject":"Re: [PATCH 0/2] clone: shallow-submodules should be single-branch by default","fromName":"Bruce Perry","fromEmail":"bruce.a.perry@gmail.com","sentAt":"2024-07-25T17:10:02Z","receivedAt":"2024-07-25T17:10:32Z","isPatch":true,"sender":{"key":"bruce.a.perry@gmail.com","avatar":null},"body":"Any further comments on this or changes I should make so it can be merged?\n\nThe current code behavior does not match the documentation, so\nsomething should be changed. If these changes are not desired, I could\nsubmit an alternative patch that changes the documentation to clarify\nwhat currently happens instead.\n\n\nOn Wed, Jul 3, 2024 at 8:05 AM <rsbecker@nexbridge.com> wrote:\n>\n> On Wednesday, July 3, 2024 1:00 AM, Bruce Perry wrote:\n> >Perhaps I was using imprecise terminology. This change should not impact whether\n> >submodule clones land in a detached head state, so it should not impact anything\n> >that assumes submodule clones are detached head.\n> >\n> >The change being made is this: \"git clone --recurse-submodules --shallow-\n> >submodules\" currently gives you a submodule with a detached head at the desired\n> >state, but also downloads data for the tips of all branches in the remote being\n> >cloned (potentially a lot of unneeded data as in my use case). The modification\n> >means the same command would give you a detached head at the desired state,\n> >plus the tip of only the default branch in the remote. The modified behavior\n> >matches the current behavior for a simple \"git clone\" followed by \"git submodule\n> >update --init --recurse--submodules --depth=1\".\n> >\n> >Thanks,\n> >Bruce\n> >\n> >(Resent due to a formatting failure)\n> >\n> >On Tue, Jul 2, 2024, 1:12 PM <rsbecker@nexbridge.com> wrote:\n> >>\n> >> On Tuesday, July 2, 2024 3:08 PM, Bruce Perry wrote:\n> >> >I noticed a couple places where the behavior of recursive clones for\n> >> >shallow submodules does not match what is implied by the\n> >> >documentation. Shallow submodules should be, but aren't, single\n> >> >branch by default. It would also be useful to allow users to override\n> >> >the shallow specification in gitmodules on the command line for\n> >> >clones as they can for submodule update. The modification here for the former is\n> >a bit ugly, but hopefully at least gets the point across to start a discussion.\n> >> >First time submitting a patch here, hopefully I'm getting the process right.\n> >> >\n> >> >Bruce Perry (2):\n> >> >  clone: shallow-submodules should be single-branch by default\n> >> >  clone: no-shallow-submodules clone overrides option in gitmodules\n> >> >\n> >> > Documentation/git-clone.txt         |  3 ++\n> >> > Documentation/gitmodules.txt        |  4 +--\n> >> > builtin/clone.c                     | 10 ++++--\n> >> > t/t5614-clone-submodules-shallow.sh | 52\n> >> > +++++++++++++++++++++++------\n> >> > 4 files changed, 53 insertions(+), 16 deletions(-)\n> >> >\n> >> >\n> >> >base-commit: daed0c68e94967bfbb3f87e15f7c9090dc1aa1e1\n> >> >Published-As:\n> >> >https://github.com/gitgitgadget/git/releases/tag/pr-git-\n> >> >1740%2Fbaperry2%2Fsubmods-clone-bug-v1\n> >> >Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-\n> >> >1740/baperry2/submods-clone-bug-v1\n> >> >Pull-Request: https://github.com/git/git/pull/1740\n> >>\n> >> I am concerned about this one. Many CI systems (including Jenkins GitSCM)\n> >assume a detached head for submodule clone/checkout. Adding a branch to the mix\n> >will change the expected semantics. Am I missing something?\n>\n> Thanks for clearing that up. Fine with me.\n> Regards\n> Randall\n>\n"}]}