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

Re: [RFC PATCHv2 17/17] checkout: add config option to recurse into submodules by default

From
Stefan Beller <sbeller@google.com>
Date
Dec 5, 2016, 22:23 UTC
Message-ID
<CAGZ79kaMXmNUaUCZJaTrcodAoSBPSxXr5JPrZGQeg=m-HrN11w@mail.gmail.com>
In-Reply-To
<20161205192918.GB68588@google.com>
On Mon, Dec 5, 2016 at 11:29 AM, Brandon Williams <bmwill@google.com> wrote:
Show 21 quoted lines
> On 12/02, Stefan Beller wrote:
>> +test_expect_success 'option checkout.recurseSubmodules updates submodule' '
>> +     test_config checkout.recurseSubmodules 1 &&
>> +     git checkout base &&
>> +     git checkout -b advanced-base &&
>> +     git -C submodule commit --allow-empty -m "empty commit" &&
>> +     git add submodule &&
>> +     git commit -m "advance submodule" &&
>> +     git checkout base &&
>> +     git diff-files --quiet &&
>> +     git diff-index --quiet --cached base &&
>> +     git checkout advanced-base &&
>> +     git diff-files --quiet &&
>> +     git diff-index --quiet --cached advanced-base &&
>> +     git checkout --recurse-submodules base
>> +'
>> +
>
> This test doesn't look like it looks into the submodule to see if the
> submodule has indeed changed.  Unless diff-index and diff-files recurse
> into the submodules?

I took the code from Jens once upon a time. Rereading the code, I agree it is not obvious how this checks the submodule state.

However `git diff-files --quiet` is perfectly fine, as we have submodule support by default via:

  Omitting the --submodule option or specifying --submodule=short,
  uses the short format.  This format just shows the names of the commits
  at the beginning and end of the range.
and then we turn it into an exit code via
       --quiet
           Disable all output of the program. Implies --exit-code.
       --exit-code
           Make the program exit with codes similar to diff(1).
  That is, it exits with 1 if there were differences and 0 means no differences.
Same for diff-index.

The main purpose of this specific test is to have checkout.recurseSubmodules "to just make it work" without having to give --recurse-submodules manually. All the other tests with the manual --recurse-submodules should test for correctness of the behavior within the submodule.

So maybe I'll need to rewrite submodule_creation_must_succeed() in the previous patch to be more obvious. (Well that already has some tests for files/directories in there, so it is a little more.)

But to be sure we can also add tests here that look more into the submodule. I am thinking of "{new,old}_sub_sha1=$(git -C submodule rev-parse HEAD)" and comparing them?

Previous: Brandon WilliamsNext: Brandon Williams
Message 29 of 30 in “[RFC PATCHv2 00/17] Checkout aware of Submodules!”
  1. Stefan BellerDec 3, 2016
  2. 02/17 submodule: modernize ok_to_remove_submodule to use argv_arrayStefan Beller, Dec 3, 2016
  3. 12/17 unpack-trees: remove submodule contents if interestingStefan Beller, Dec 3, 2016
  4. 09/17 update submodules: add scheduling to update submodulesStefan Beller, Dec 3, 2016
  5. David TurnerDec 5, 2016
  6. Stefan BellerDec 5, 2016
  7. 07/17 update submodules: introduce submodule_is_interestingStefan Beller, Dec 3, 2016
  8. 08/17 update submodules: add depopulate_submoduleStefan Beller, Dec 3, 2016
  9. David TurnerDec 5, 2016
  10. Stefan BellerDec 6, 2016
  11. 04/17 update submodules: add is_submodule_populatedStefan Beller, Dec 3, 2016
  12. 10/17 update submodules: is_submodule_checkout_safeStefan Beller, Dec 3, 2016
  13. 05/17 update submodules: add submodule config parsingStefan Beller, Dec 3, 2016
  14. 15/17 checkout: recurse into submodules if asked toStefan Beller, Dec 3, 2016
  15. Brandon WilliamsDec 5, 2016
  16. Stefan BellerDec 5, 2016
  17. Brandon WilliamsDec 5, 2016
  18. David TurnerDec 5, 2016
  19. 03/17 update submodules: move up prepare_submodule_repo_envStefan Beller, Dec 3, 2016
  20. 16/17 completion: add '--recurse-submodules' to checkoutStefan Beller, Dec 3, 2016
  21. 01/17 submodule.h: add extern keyword to functionsStefan Beller, Dec 3, 2016
  22. 14/17 submodule: teach unpack_trees() to update submodulesStefan Beller, Dec 3, 2016
  23. David TurnerDec 5, 2016
  24. 06/17 update submodules: add a config option to determine if submodules are updatedStefan Beller, Dec 3, 2016
  25. 13/17 entry: write_entry to write populate submodulesStefan Beller, Dec 3, 2016
  26. 11/17 unpack-trees: teach verify_clean_submodule to inspect submodulesStefan Beller, Dec 3, 2016
  27. 17/17 checkout: add config option to recurse into submodules by defaultStefan Beller, Dec 3, 2016
  28. Brandon WilliamsDec 5, 2016
  29. Stefan BellerDec 5, 2016
  30. Brandon WilliamsDec 5, 2016

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.