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

[RFC PATCH 0/4] git: remove --super-prefix

From
Glen Choo <chooglen@google.com>
Date
Nov 9, 2022, 00:47 UTC
Message-ID
<20221109004708.97668-1-chooglen@google.com>
*Note to maintainer*: See "Interactions with other series".

Given the work on ab/submodule-helper-prep-only, I'm sending this early for feedback, and to see if I can avoid blocking Ævar's follow-up work. This is pretty much done, but I haven't scrutinized the patches too closely to see if all of the relevant paths are tested.

The main motivation behind this is the partial clone bug demonstrated by the test in Patch 3/4, but instead of just fixing that one issue, I'd prefer to get rid of this class of error once and for all.

= Description

When we introduced the internal-only "--super-prefix" in 74866d7579 (git: make super-prefix option, 2016-10-07), we specified that commands must prefix paths by it, and pathspecs must be parsed relative to it. That commit also includes safeguards to ensure that "--super-prefix" is used correctly, namely:

- Only commands marked SUPPORT_SUPER_PREFIX can be invoked with
  "--super-prefix".
- The super prefix is propagated via the GIT_INTERNAL_SUPER_PREFIX env
  var, so a non-SUPPORT_SUPER_PREFIX command cannot be invoked by a
  SUPPORT_SUPER_PREFIX one.

However, its use is inconsistent, which is a strong reason to consider using better-scoped flags instead. For example..

- Of the 4 commands that are SUPPORT_SUPER_PREFIX, only "read-tree" and
  "submodule--helper" do anything useful with it. "fsmonitor--daemon"
  has it to avoid the SUPPORT_SUPER_PREFIX warning [1].
  "checkout--worker" doesn't have a documented reason, but since it can
  be invoked by "read-tree", it's presumably also a workaround.
- "read-tree" and "submodule--helper" use different values for the super
  prefix; "read-tree" passes the path from the root of the
  superproject's tree to the submodule's gitlink, while
  "submodule--helper" passes the relative path of the original CWD to
  the submodule.
- "submodule--helper" doesn't use "--super-prefix" to parse pathspecs,
  only to display paths.

This series replaces the top-level "--super-prefix" with better-scoped, per-command flags.

= Interactions with other series

As noted in the conversation starting at [2], the submodule--helper bits in this series have substantial overlap with ab/submodule-helper-prep-only and the work that series is prep for. I've based this series off ab/submodule-helper-prep-only, since the conversion of builtin/submodule--helper.c to use options parsing makes patch 1 much easier to reason about.

Ævar: The patch of interest is 1/4, which removes the super prefix check from submodule--helper. Hopefully you find this useful, I strongly suspect that it will save time and churn for us to move this series forward and to base your follow up work on this. But if this does end up stalling, however, I'm happy to rebase this on top of your follow up work.

= Patch summary
- Patch 1/4 introduces a "--toplevel-cwd-prefix" flag for "git
  submodule--helper" (replacing "--super-prefix" for "git
  submodule--helper").
- Patches 2-3/4 refactors "--submodule-prefix" for "git fetch" and
  reuses that implementation for "git read-tree" (replacing
  "--super-prefix" for "git read-tree").
- Patch 4 drops "--super-prefix" and a now-defunct fsmonitor test.

[1]: 53fcfbc84f (fsmonitor--daemon: allow --super-prefix argument, 2022-05-26) [2]: https://lore.kernel.org/git/221104.86wn8bzeus.gmgdl@evledraar.gmail.com

Glen Choo (4):
  submodule--helper: teach --toplevel-cwd-prefix
  fetch: refactor --submodule-prefix
  read-tree: teach --submodule-prefix
  git: remove --super-prefix
 Documentation/fetch-options.txt    |  5 --
 Documentation/git.txt              |  7 +--
 builtin.h                          |  4 --
 builtin/fetch.c                    |  7 ++-
 builtin/read-tree.c                |  4 ++
 builtin/submodule--helper.c        | 52 ++++++++-----------
 cache.h                            |  2 -
 environment.c                      | 13 -----
 git.c                              | 40 +++-----------
 repository.c                       |  1 +
 repository.h                       |  9 +++-
 submodule.c                        | 83 ++++++++++++++++++------------
 submodule.h                        | 20 ++++++-
 t/t1001-read-tree-m-2way.sh        |  4 +-
 t/t5616-partial-clone.sh           | 43 ++++++++++++++++
 t/t7412-submodule-absorbgitdirs.sh | 13 ++++-
 t/t7527-builtin-fsmonitor.sh       | 50 ------------------
 unpack-trees.c                     | 32 ++++++------
 18 files changed, 187 insertions(+), 202 deletions(-)
base-commit: 69d94464e14de859ff56bcde7ebe0132201eceb9
-- 
2.38.1.431.g37b22c650d-goog
Next: Glen Choo
Message 1 of 105 in “git: remove --super-prefix”
  1. 0/4 git: remove --super-prefixGlen Choo, Nov 9, 2022
  2. 1/4 submodule--helper: teach --toplevel-cwd-prefixGlen Choo, Nov 9, 2022
  3. Ævar Arnfjörð BjarmasonNov 9, 2022
  4. 2/4 fetch: refactor --submodule-prefixGlen Choo, Nov 9, 2022
  5. Ævar Arnfjörð BjarmasonNov 9, 2022
  6. 3/4 read-tree: teach --submodule-prefixGlen Choo, Nov 9, 2022
  7. Ævar Arnfjörð BjarmasonNov 9, 2022
  8. 4/4 git: remove --super-prefixGlen Choo, Nov 9, 2022
  9. 0/8 Get rid of "git --super-prefix"Ævar Arnfjörð Bjarmason, Nov 9, 2022
  10. 1/8 submodule--helper: don't use global --super-prefix in "absorbgitdirs"Ævar Arnfjörð Bjarmason, Nov 9, 2022
  11. Glen ChooNov 11, 2022
  12. 2/8 submodule--helper: "deinit" has never used "--super-prefix"Ævar Arnfjörð Bjarmason, Nov 9, 2022
  13. 3/8 submodule--helper: convert "foreach" to its own "--super-prefix"Ævar Arnfjörð Bjarmason, Nov 9, 2022
  14. 4/8 submodule--helper: convert "sync" to its own "--super-prefix"Ævar Arnfjörð Bjarmason, Nov 9, 2022
  15. 5/8 submodule--helper: convert "status" to its own "--super-prefix"Ævar Arnfjörð Bjarmason, Nov 9, 2022
  16. 6/8 submodule--helper: convert "{update,clone}" to their own "--super-prefix"Ævar Arnfjörð Bjarmason, Nov 9, 2022
  17. 7/8 submodule tests: test "git branch -t" output and stderrÆvar Arnfjörð Bjarmason, Nov 9, 2022
  18. 8/8 read-tree: add "--super-prefix" option, eliminate globalÆvar Arnfjörð Bjarmason, Nov 9, 2022
  19. Glen ChooNov 11, 2022
  20. Taylor BlauNov 9, 2022
  21. Ævar Arnfjörð BjarmasonNov 9, 2022
  22. Taylor BlauNov 9, 2022
  23. Ævar Arnfjörð BjarmasonNov 9, 2022
  24. Glen ChooNov 10, 2022
  25. Ævar Arnfjörð BjarmasonNov 10, 2022
  26. Glen ChooNov 11, 2022
  27. Glen ChooNov 11, 2022
  28. Ævar Arnfjörð BjarmasonNov 11, 2022
  29. Taylor BlauNov 11, 2022
  30. Glen ChooNov 12, 2022
  31. Ævar Arnfjörð BjarmasonNov 14, 2022
  32. Glen ChooNov 14, 2022
  33. Ævar Arnfjörð BjarmasonNov 15, 2022
  34. 00/10 Get rid of "git --super-prefix"Ævar Arnfjörð Bjarmason, Nov 14, 2022
  35. 01/10 read-tree + fetch tests: test failing "--super-prefix" interactionÆvar Arnfjörð Bjarmason, Nov 14, 2022
  36. Glen ChooNov 14, 2022
  37. Ævar Arnfjörð BjarmasonNov 14, 2022
  38. Glen ChooNov 14, 2022
  39. 02/10 submodule--helper: don't use global --super-prefix in "absorbgitdirs"Ævar Arnfjörð Bjarmason, Nov 14, 2022
  40. Glen ChooNov 14, 2022
  41. Ævar Arnfjörð BjarmasonNov 17, 2022
  42. 03/10 submodule--helper: "deinit" has never used "--super-prefix"Ævar Arnfjörð Bjarmason, Nov 14, 2022
  43. 04/10 submodule--helper: convert "foreach" to its own "--super-prefix"Ævar Arnfjörð Bjarmason, Nov 14, 2022
  44. Glen ChooNov 14, 2022
  45. Ævar Arnfjörð BjarmasonNov 17, 2022
  46. 05/10 submodule--helper: convert "sync" to its own "--super-prefix"Ævar Arnfjörð Bjarmason, Nov 14, 2022
  47. 06/10 submodule--helper: convert "status" to its own "--super-prefix"Ævar Arnfjörð Bjarmason, Nov 14, 2022
  48. 07/10 submodule--helper: convert "{update,clone}" to their own "--super-prefix"Ævar Arnfjörð Bjarmason, Nov 14, 2022
  49. Glen ChooNov 14, 2022
  50. 08/10 submodule tests: test "git branch -t" output and stderrÆvar Arnfjörð Bjarmason, Nov 14, 2022
  51. Glen ChooNov 14, 2022
  52. 10/10 fetch: rename "--submodule-prefix" to "--super-prefix"Ævar Arnfjörð Bjarmason, Nov 14, 2022
  53. Glen ChooNov 14, 2022
  54. 09/10 read-tree: add "--super-prefix" option, eliminate globalÆvar Arnfjörð Bjarmason, Nov 14, 2022
  55. Glen ChooNov 14, 2022
  56. Taylor BlauNov 14, 2022
  57. Glen ChooNov 14, 2022
  58. Glen ChooNov 14, 2022
  59. Ævar Arnfjörð BjarmasonNov 15, 2022
  60. Glen ChooNov 16, 2022
  61. Ævar Arnfjörð BjarmasonNov 17, 2022
  62. Glen ChooNov 21, 2022
  63. 0/9 Get rid of "git --super-prefix"Ævar Arnfjörð Bjarmason, Nov 19, 2022
  64. 1/9 read-tree + fetch tests: test failing "--super-prefix" interactionÆvar Arnfjörð Bjarmason, Nov 19, 2022
  65. 3/9 submodule--helper: don't use global --super-prefix in "absorbgitdirs"Ævar Arnfjörð Bjarmason, Nov 19, 2022
  66. Glen ChooNov 22, 2022
  67. 2/9 submodule.c & submodule--helper: pass along "super_prefix" paramÆvar Arnfjörð Bjarmason, Nov 19, 2022
  68. 4/9 submodule--helper: convert "foreach" to its own "--super-prefix"Ævar Arnfjörð Bjarmason, Nov 19, 2022
  69. 6/9 submodule--helper: convert "status" to its own "--super-prefix"Ævar Arnfjörð Bjarmason, Nov 19, 2022
  70. 5/9 submodule--helper: convert "sync" to its own "--super-prefix"Ævar Arnfjörð Bjarmason, Nov 19, 2022
  71. 7/9 submodule--helper: convert "{update,clone}" to their own "--super-prefix"Ævar Arnfjörð Bjarmason, Nov 19, 2022
  72. 9/9 fetch: rename "--submodule-prefix" to "--super-prefix"Ævar Arnfjörð Bjarmason, Nov 19, 2022
  73. 8/9 read-tree: add "--super-prefix" option, eliminate globalÆvar Arnfjörð Bjarmason, Nov 19, 2022
  74. Glen ChooNov 22, 2022
  75. Glen ChooNov 22, 2022
  76. 0/9 Get rid of "git --super-prefix"Ævar Arnfjörð Bjarmason, Dec 15, 2022
  77. 2/9 read-tree + fetch tests: test failing "--super-prefix" interactionÆvar Arnfjörð Bjarmason, Dec 15, 2022
  78. 1/9 submodule absorbgitdirs tests: add missing "Migrating git..." testsÆvar Arnfjörð Bjarmason, Dec 15, 2022
  79. Glen ChooDec 15, 2022
  80. Ævar Arnfjörð BjarmasonDec 20, 2022
  81. 3/9 submodule.c & submodule--helper: pass along "super_prefix" paramÆvar Arnfjörð Bjarmason, Dec 15, 2022
  82. 5/9 submodule--helper: convert "foreach" to its own "--super-prefix"Ævar Arnfjörð Bjarmason, Dec 15, 2022
  83. 4/9 submodule--helper: don't use global --super-prefix in "absorbgitdirs"Ævar Arnfjörð Bjarmason, Dec 15, 2022
  84. Glen ChooDec 15, 2022
  85. 6/9 submodule--helper: convert "sync" to its own "--super-prefix"Ævar Arnfjörð Bjarmason, Dec 15, 2022
  86. 7/9 submodule--helper: convert "status" to its own "--super-prefix"Ævar Arnfjörð Bjarmason, Dec 15, 2022
  87. 8/9 submodule--helper: convert "{update,clone}" to their own "--super-prefix"Ævar Arnfjörð Bjarmason, Dec 15, 2022
  88. 9/9 read-tree: add "--super-prefix" option, eliminate globalÆvar Arnfjörð Bjarmason, Dec 15, 2022
  89. Glen ChooDec 15, 2022
  90. Junio C HamanoDec 15, 2022
  91. Junio C HamanoDec 15, 2022
  92. 0/9 Get rid of "git --super-prefix"Ævar Arnfjörð Bjarmason, Dec 20, 2022
  93. 2/9 read-tree + fetch tests: test failing "--super-prefix" interactionÆvar Arnfjörð Bjarmason, Dec 20, 2022
  94. 1/9 submodule absorbgitdirs tests: add missing "Migrating git..." testsÆvar Arnfjörð Bjarmason, Dec 20, 2022
  95. 3/9 submodule.c & submodule--helper: pass along "super_prefix" paramÆvar Arnfjörð Bjarmason, Dec 20, 2022
  96. 5/9 submodule--helper: convert "foreach" to its own "--super-prefix"Ævar Arnfjörð Bjarmason, Dec 20, 2022
  97. 4/9 submodule--helper: don't use global --super-prefix in "absorbgitdirs"Ævar Arnfjörð Bjarmason, Dec 20, 2022
  98. 6/9 submodule--helper: convert "sync" to its own "--super-prefix"Ævar Arnfjörð Bjarmason, Dec 20, 2022
  99. 7/9 submodule--helper: convert "status" to its own "--super-prefix"Ævar Arnfjörð Bjarmason, Dec 20, 2022
  100. 8/9 submodule--helper: convert "{update,clone}" to their own "--super-prefix"Ævar Arnfjörð Bjarmason, Dec 20, 2022
  101. 9/9 read-tree: add "--super-prefix" option, eliminate globalÆvar Arnfjörð Bjarmason, Dec 20, 2022
  102. Taylor BlauNov 9, 2022
  103. Glen ChooNov 9, 2022
  104. Taylor BlauNov 10, 2022
  105. Glen ChooNov 10, 2022

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.