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

Re: [PATCH v4 1/3] fetch: add test to make sure we stay backwards compatible

From
Stefan Beller <sbeller@google.com>
Date
Oct 17, 2017, 17:56 UTC
Message-ID
<CAGZ79kaA6myLpDcN2H4sdbMKvkuVRp4Zud==k=p1BNfWn95a4Q@mail.gmail.com>
In-Reply-To
<20171016135715.GB12756@book.hvoigt.net>
On Mon, Oct 16, 2017 at 6:57 AM, Heiko Voigt <hvoigt@hvoigt.net> wrote:
Show 23 quoted lines
> The current implementation of submodules supports on-demand fetch if
> there is no .gitmodules entry for a submodule. Let's add a test to
> document this behavior.
>
> Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
> ---
>  t/t5526-fetch-submodules.sh | 42 +++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 41 insertions(+), 1 deletion(-)
>
> diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh
> index 42251f7f3a..43a22f680f 100755
> --- a/t/t5526-fetch-submodules.sh
> +++ b/t/t5526-fetch-submodules.sh
> @@ -478,7 +478,47 @@ test_expect_success "don't fetch submodule when newly recorded commits are alrea
>                 git fetch >../actual.out 2>../actual.err
>         ) &&
>         ! test -s actual.out &&
> -       test_i18ncmp expect.err actual.err
> +       test_i18ncmp expect.err actual.err &&
> +       (
> +               cd submodule &&
> +               git checkout -q master
> +       )

For few instructions inside another repo, I tend to use the -C option:

  git -C submodule checkout -q master

That saves a shell, which is noticeable cost on Windows I was told. (also fewer lines to type).

Oh, I see, that is consistent with the rest of the file. Oh well. (Otherwise I would have lobbied to even move it further up and put it inside a test_when_finished "<cmd>"

Show 7 quoted lines
> +'
> +
> +test_expect_success "'fetch.recurseSubmodules=on-demand' works also without .gitmodule entry" '
> +       (
> +               cd downstream &&
> +               git fetch --recurse-submodules
> +       ) &&

This is consistent with the rest of the file as well, so I shall refrain from complaining. ;)

Show 6 quoted lines
> +       add_upstream_commit &&
> +       head1=$(git rev-parse --short HEAD) &&
> +       git add submodule &&
> +       git rm .gitmodules &&
> +       git commit -m "new submodule without .gitmodules" &&
> +       printf "" >expect.out &&
This could be just
    : >expect.out
no need to invoke a function to print nothing.
Show 24 quoted lines
> +       head2=$(git rev-parse --short HEAD) &&
> +       echo "From $pwd/." >expect.err.2 &&
> +       echo "   $head1..$head2  master     -> origin/master" >>expect.err.2 &&
> +       head -3 expect.err >>expect.err.2 &&
> +       (
> +               cd downstream &&
> +               rm .gitmodules &&
> +               git config fetch.recurseSubmodules on-demand &&
> +               # fake submodule configuration to avoid skipping submodule handling
> +               git config -f .gitmodules submodule.fake.path fake &&
> +               git config -f .gitmodules submodule.fake.url fakeurl &&
> +               git add .gitmodules &&
> +               git config --unset submodule.submodule.url &&
> +               git fetch >../actual.out 2>../actual.err &&
> +               # cleanup
> +               git config --unset fetch.recurseSubmodules &&
> +               git reset --hard
> +       ) &&
> +       test_i18ncmp expect.out actual.out &&
> +       test_i18ncmp expect.err.2 actual.err &&
> +       git checkout HEAD^ -- .gitmodules &&
> +       git add .gitmodules &&
> +       git commit -m "new submodule restored .gitmodules"
>  '

Thanks for writing this test. With or without the nits addressed, this is

Reviewed-by: Stefan Beller <sbeller@google.com>
Previous: Heiko VoigtNext: Heiko Voigt
Message 3 of 24 in “implement fetching of moved submodules”
  1. 0/3 implement fetching of moved submodulesHeiko Voigt, Oct 16, 2017
  2. 1/3 fetch: add test to make sure we stay backwards compatibleHeiko Voigt, Oct 16, 2017
  3. Stefan BellerOct 17, 2017
  4. 3/3 submodule: simplify decision tree whether to or not to fetchHeiko Voigt, Oct 16, 2017
  5. Stefan BellerOct 17, 2017
  6. Junio C HamanoOct 18, 2017
  7. Brandon WilliamsOct 18, 2017
  8. Junio C HamanoOct 19, 2017
  9. Heiko VoigtOct 19, 2017
  10. Brandon WilliamsOct 19, 2017
  11. 2/3 implement fetching of moved submodulesHeiko Voigt, Oct 16, 2017
  12. Stefan BellerOct 17, 2017
  13. Junio C HamanoOct 18, 2017
  14. Stefan BellerOct 18, 2017
  15. Junio C HamanoOct 19, 2017
  16. 1/2 t5526: check for name/path collision in submodule fetchStefan Beller, Oct 19, 2017
  17. 2/2 fetch, push: keep separate lists of submodules and gitlinksStefan Beller, Oct 19, 2017
  18. Heiko VoigtOct 23, 2017
  19. Stefan BellerOct 23, 2017
  20. Junio C HamanoOct 24, 2017
  21. Heiko VoigtOct 23, 2017
  22. Stefan BellerOct 23, 2017
  23. Stefan BellerOct 19, 2017
  24. Junio C HamanoOct 17, 2017

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.