git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH/RFC 1/2] submodule: add ability to shallowly clone any branch in a repo as a submodule

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Sep 14, 2014, 23:41 UTC
Message-ID
<CAPig+cSdJGzbwWGQTTO1JJpHSk9gfZcdCqFmG4DeSDewDbgbXQ@mail.gmail.com>
In-Reply-To
<ede7b63c6028591281a7eefea5e9cd45cccd0a93.1410691049.git.cole.minnaar@gmail.com>
On Sun, Sep 14, 2014 at 6:38 AM, Cole Minnaar <cole.minnaar@gmail.com> wrote:
Show 61 quoted lines
> Currently when specifying the `--depth` option to the 'submodule add'
> command, it can only create a shallow submodule clone of the currently
> active branch from the cloned repository. If a branch is specified using
> the `--branch` option, and the `--depth` option is also specified, the
> 'submodule add' command will result in an error as the branch will not
> be present in the cloned repository. If a repository is shallowly cloned
> as a submodule, there is no way to specify that the shallowly cloned
> submodule should setup remote-tracking branches.
>
> Added the ability to shallowly clone any branch as a submodule, not just
> the current active branch in the cloned repository.
> Added support to the 'submodule add' and 'submodule update' commands to
> handle `--no-single-branch` option, which is in turn passed to the clone
> command in order to setup remote-tracking branches in the shallowly
> cloned submodule.
>
> Signed-off-by: Cole Minnaar <cole.minnaar@gmail.com>
> ---
> diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
> index 7c88245..81c05ae 100755
> --- a/t/t7400-submodule-basic.sh
> +++ b/t/t7400-submodule-basic.sh
> @@ -136,7 +136,6 @@ test_expect_success 'submodule add --branch' '
>         echo "refs/heads/initial" >expect-head &&
>         cat <<-\EOF >expect-heads &&
>         refs/heads/initial
> -       refs/heads/master
>         EOF
>         >empty &&
>
> @@ -982,5 +981,37 @@ test_expect_success 'submodule add clone shallow submodule' '
>         )
>  '
>
> +test_expect_success 'submodule add --branch --depth' '
> +       (
> +               cd addtest2 &&
> +               git submodule add -b initial --depth 1 -- file://"$submodurl" submod-branch-depth &&
> +               test "initial" = "$(git config -f .gitmodules submodule.submod-branch-depth.branch)" &&
> +               (
> +                       cd submod-branch-depth &&
> +                       test 1 = $(git log --oneline | wc -l)
> +               )
> +       )
> +'
> +
> +cat >remote <<\EOF
> +  origin/HEAD -> origin/second
> +  origin/initial
> +  origin/master
> +  origin/second
> +EOF
> +
> +test_expect_success 'submodule add --branch --depth --no-single-branch' '
> +       (
> +               cd addtest2 &&
> +               git submodule add -b initial --depth 1 --no-single-branch -- file://"$submodurl" submod-branch-depth-all &&
> +               test "initial" = "$(git config -f .gitmodules submodule.submod-branch-depth-all.branch)" &&
> +               (
> +                       cd submod-branch-depth-all &&
> +                       test 1 = $(git log --oneline | wc -l)
Broken &&-chain.
Show 9 quoted lines
> +                       git branch -r >../../remote-out
> +               )
> +       ) &&
> +       test_cmp remote remote-out
> +'
>
>  test_done
> --
> 2.1.0.238.gce1d3a9.dirty
Previous: Cole Minnaar
Message 3 of 3 in “submodule: add ability to shallowly clone any branch in a repo as a submodule”
  1. 1/2 submodule: add ability to shallowly clone any branch in a repo as a submoduleCole Minnaar, Sep 14, 2014
  2. 2/2 submodule: modify clone command to recursively shallow clone submodulesCole Minnaar, Sep 14, 2014
  3. Eric SunshineSep 14, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.