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

Re: [PATCH 7/7] submodule.c: correctly handle nested submodules in is_submodule_modified

From
Stefan Beller <sbeller@google.com>
Date
Mar 28, 2017, 21:20 UTC
Message-ID
<CAGZ79kYmWW5tp26aCkWeYjyp8KeP2jcL43JGiPO3pHW=wo7uzw@mail.gmail.com>
In-Reply-To
<xmqqpoh2z93q.fsf@gitster.mtv.corp.google.com>
On Mon, Mar 27, 2017 at 2:46 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 8 quoted lines
> Stefan Beller <sbeller@google.com> writes:
>
>> When a nested submodule has untracked files, it would be reported as
>> "modified submodule" in the superproject, because submodules are not
>> parsed correctly in is_submodule_modified as they are bucketed into
>> the modified pile as "they are not an untracked file".
>
> I cannot quite parse the above.

I tried to describe the example Jonathan gave in his reply in a shorter form. I'll

Show 20 quoted lines
>> +                     /* regular unmerged and renamed files */
>> +                     if (buf.buf[5] == 'S' && buf.buf[8] == 'U')
>> +                             /* nested untracked file */
>> +                             dirty_submodule |= DIRTY_SUBMODULE_UNTRACKED;
>
> OK, we have untracked one.
>
>> +                     if (memcmp(buf.buf + 5, "S..U", 4))
>> +                             /* other change */
>> +                             dirty_submodule |= DIRTY_SUBMODULE_MODIFIED;
>
> And for other cases like C at buf.buf[6] or M at buf.buf[7],
> i.e. where the submodule not just has untracked files but has real
> changes, we say it is truly MODIFIED here.
>
> If there are changes to paths that is not a submodule but a tracked
> file in the submodule in question would have N at buf.buf[5] and is
> also caught with the same "not S..U so that's MODIFIED" logic.
>
> OK.
ok, thanks for checking.
>
> Shouldn't this done as part of 4/7 where is_submodule_modified()
> starts reading from the porcelain v2 output?

I did that in an earlier version of the series. However the change from porcelain=1 to 2 should not be observable by the end user.

Show 5 quoted lines
>  4/7 does adjust for
> the change from double question mark (porcelain v1) to a single one
> for untracked, but at the same time it needs to prepare for these
> 'u' (unmerged), '1' (normal modification) and '2' (mods with rename)
> to appear in the output, no?

No, up to patch 5/7 we only had refactors, no user visible changes intended. And until then we had "has untracked files" and "everything else". The nice part of the conversion was to cover the "everything else" part easily.

This patch transforms it into "has untracked files or submodule reports untracked files (possibly nested)" and "everything else", but the former is more complicated to compute.

> IOW, with 4/7 and 7/7 done as separate steps, isn't the system
> broken between these steps?
No, see Jonathans answer.

We could argue, that 6/7 and 7/7 done as separate steps is broken, because since 6/7 we promise to report untracked files inside submodules as " ?", but we do not report them properly for nested submodules.

Suppose I have a superproject 'parent', with two submodules 'parent/sub' and 'parent/sub1'. 'parent/sub' itself contains a submodule 'parent/sub/subsub'. Now suppose I run, from within 'parent':

    echo hi >sub/subsub/stray-file
    echo hi >sub1/stray-file
with patches 1..5:
    git status --short
     M sub
     M sub1
patch 6:
    git status --short
     m sub
     ? sub1
with patch 7:
    git status --short
     ? sub
     ? sub1

The documentation update in patch 6 is unclear what to expect from nested submodules, so that documentation is technically not wrong, but maybe misleading.

I want to resend patch 7 with a documentation update as well as tests.

Thanks, Stefan

Previous: Junio C HamanoNext: Stefan Beller
Message 56 of 73 in “[PATCHv3 0/3] short status: improve reporting for submodule changes”
  1. Stefan BellerMar 23, 2017
  2. 1/3 submodule.c: port is_submodule_modified to use porcelain 2Stefan Beller, Mar 23, 2017
  3. Jonathan NiederMar 23, 2017
  4. Junio C HamanoMar 23, 2017
  5. Stefan BellerMar 23, 2017
  6. 2/3 submodule.c, is_submodule_modified: stricter checking for submodulesStefan Beller, Mar 23, 2017
  7. Jonathan NiederMar 23, 2017
  8. 3/3 short status: improve reporting for submodule changesStefan Beller, Mar 23, 2017
  9. Jonathan NiederMar 23, 2017
  10. 0/8 short status: improve reporting for submodule changesStefan Beller, Mar 23, 2017
  11. 3/8 submodule.c: convert is_submodule_modified to use strbuf_getwholeline_fdStefan Beller, Mar 23, 2017
  12. 1/8 submodule.c: port is_submodule_modified to use porcelain 2Stefan Beller, Mar 23, 2017
  13. 5/8 submodule.c: factor out early loop termination in is_submodule_modifiedStefan Beller, Mar 23, 2017
  14. 2/8 submodule.c: use argv_array in is_submodule_modifiedStefan Beller, Mar 23, 2017
  15. 4/8 submodule.c: port is_submodule_modified to use porcelain 2Stefan Beller, Mar 23, 2017
  16. 8/8 submodule.c: correctly handle nested submodules in is_submodule_modifiedStefan Beller, Mar 23, 2017
  17. 6/8 submodule.c: stricter checking for submodules in is_submodule_modifiedStefan Beller, Mar 23, 2017
  18. 7/8 short status: improve reporting for submodule changesStefan Beller, Mar 23, 2017
  19. Stefan BellerMar 23, 2017
  20. 0/7 short status: improve reporting for submodule changesStefan Beller, Mar 23, 2017
  21. 1/7 submodule.c: use argv_array in is_submodule_modifiedStefan Beller, Mar 23, 2017
  22. Jonathan NiederMar 23, 2017
  23. 4/7 submodule.c: factor out early loop termination in is_submodule_modifiedStefan Beller, Mar 23, 2017
  24. 5/7 submodule.c: stricter checking for submodules in is_submodule_modifiedStefan Beller, Mar 23, 2017
  25. 2/7 submodule.c: convert is_submodule_modified to use strbuf_getwholeline_fdStefan Beller, Mar 23, 2017
  26. Jonathan NiederMar 23, 2017
  27. Stefan BellerMar 23, 2017
  28. Stefan BellerMar 23, 2017
  29. 6/7 short status: improve reporting for submodule changesStefan Beller, Mar 23, 2017
  30. 0/7 short status: improve reporting for submodule changesStefan Beller, Mar 24, 2017
  31. 1/7 submodule.c: use argv_array in is_submodule_modifiedStefan Beller, Mar 24, 2017
  32. Jonathan NiederMar 24, 2017
  33. 2/7 submodule.c: factor out early loop termination in is_submodule_modifiedStefan Beller, Mar 24, 2017
  34. Jonathan NiederMar 24, 2017
  35. 3/7 submodule.c: convert is_submodule_modified to use strbuf_getwholelineStefan Beller, Mar 24, 2017
  36. Jonathan NiederMar 24, 2017
  37. Stefan BellerMar 25, 2017
  38. 5/7 submodule.c: stricter checking for submodules in is_submodule_modifiedStefan Beller, Mar 24, 2017
  39. Jonathan NiederMar 24, 2017
  40. 6/7 short status: improve reporting for submodule changesStefan Beller, Mar 24, 2017
  41. Jonathan NiederMar 24, 2017
  42. 7/7 submodule.c: correctly handle nested submodules in is_submodule_modifiedStefan Beller, Mar 24, 2017
  43. Jonathan NiederMar 24, 2017
  44. Stefan BellerMar 25, 2017
  45. 4/7 submodule.c: port is_submodule_modified to use porcelain 2Stefan Beller, Mar 24, 2017
  46. Jonathan NiederMar 24, 2017
  47. 0/7 short status: improve reporting for submodule changesStefan Beller, Mar 25, 2017
  48. 1/7 submodule.c: use argv_array in is_submodule_modifiedStefan Beller, Mar 25, 2017
  49. 2/7 submodule.c: factor out early loop termination in is_submodule_modifiedStefan Beller, Mar 25, 2017
  50. 3/7 submodule.c: convert is_submodule_modified to use strbuf_getwholelineStefan Beller, Mar 25, 2017
  51. 4/7 submodule.c: port is_submodule_modified to use porcelain 2Stefan Beller, Mar 25, 2017
  52. 7/7 submodule.c: correctly handle nested submodules in is_submodule_modifiedStefan Beller, Mar 25, 2017
  53. Junio C HamanoMar 27, 2017
  54. Jonathan NiederMar 28, 2017
  55. Junio C HamanoMar 30, 2017
  56. Stefan BellerMar 28, 2017
  57. 6/7 short status: improve reporting for submodule changesStefan Beller, Mar 25, 2017
  58. 5/7 submodule.c: stricter checking for submodules in is_submodule_modifiedStefan Beller, Mar 25, 2017
  59. Jonathan NiederMar 25, 2017
  60. 0/7 short status: improve reporting for submodule changesStefan Beller, Mar 28, 2017
  61. 2/2 submodule.c: correctly handle nested submodules in is_submodule_modifiedStefan Beller, Mar 28, 2017
  62. Jonathan NiederMar 28, 2017
  63. Stefan BellerMar 29, 2017
  64. 1/2 short status: improve reporting for submodule changesStefan Beller, Mar 28, 2017
  65. Jonathan NiederMar 28, 2017
  66. [PATCHv9 (6,7)/7] short status: improve reporting for submodule changesStefan Beller, Mar 29, 2017
  67. 1/2 short status: improve reporting for submodule changesStefan Beller, Mar 29, 2017
  68. Jonathan NiederMar 29, 2017
  69. 2/2 submodule.c: correctly handle nested submodules in is_submodule_modifiedStefan Beller, Mar 29, 2017
  70. Jonathan NiederMar 29, 2017
  71. Junio C HamanoMar 30, 2017
  72. 3/7 submodule.c: port is_submodule_modified to use porcelain 2Stefan Beller, Mar 23, 2017
  73. 7/7 submodule.c: correctly handle nested submodules in is_submodule_modifiedStefan Beller, Mar 23, 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.