pr-git-1282/chooglen/submodule/remove-recursive-prefix-v2
tagged this
30 Jun 21:19
Thanks Ævar for the feedback! I've incorporated all of the suggestions, except breaking up the tests in 1/6 into their own patch - I wasn't convinced of the value of having prescriptive tests (with test_expect_failure), and I found it difficult to discuss descriptive tests (with test_expect_success) without also having the code in the same diff. FWIW, this version (and the previous one) "git rebase -x 'make test'" cleanly :) Note for Junio: this version is based on ab/submodule-cleanup (and so will future versions). = Description This series is a refactor of "git submodule--helper update" that replaces "--recursive-prefix" with "--super-prefix" (see Background). This was initially motivated by: * Junio's suggestion to simplify the code [1] (in response to a memory leak found by Johannes Schindelin [2]). * A desire to use the module_list API + get_submodule_displaypath() outside of builtin/submodule--helper.c (I expect to use this to check out branches in each submodule). But it also happens to remove some overly complicated/duplicated code that was literally converted from shell :) = Background When recursing into nested submodules, Git commands keep track of the path from the superproject to the submodule in order to print a "display path" to the user, e.g. Submodule path '../super/sub/nested-sub': checked out 'abcdef' For historical reasons, "git submodule--helper update" uses "--recursive-prefix" for this purpose, but it should use "--super-prefix" instead because: * That's what every other command uses (not just submodule--helper subcommands). * Using the "--super-prefix" helper functions makes the "git submodule--helper update" code simpler = Patch organization * Patch 1/6 makes sure that display paths are only computed using display path helper functions ([do_]get_submodule_displaypath()) and fixes some display paths that we never realized were broken. * Patches 2-3/6 simplify and deduplicate some display path computations. * Patch 4/6 (authored by Ævar) removes SUPPORT_SUPER_PREFIX where it's not needed. * This doesn't affect correctness, but we want to do this eventually, so do it now to make 5/6 a bit cleaner. * Patch 5/6 replaces "--recursive-prefix" with "--super-prefix", making do_get_submodule_displaypath() obsolete. * GGG outputs an odd diff; I recommend viewing it with "--histogram" * Patch 6/6 removes do_get_submodule_displaypath(). = Series history Changes in v2: * Rebase onto ab/submodule-cleanup (previously master) * Cherry pick https://github.com/avar/git/commit/f445c57490d into 4/6 * Style fixes in .c and tests = Future work At the end of this series, get_submodule_displaypath() can be moved to submodule.h, which would make submodule.c:get_super_prefix_or_empty() obsolete. I have a patch that demonstrates this (CI run: [4]), but I decided to keep this series more focused on "git submodule--helper update" so that it's easier to review. [1] https://lore.kernel.org/git/xmqq35g5xmmv.fsf@gitster.g [2] https://lore.kernel.org/git/877a45867ae368bf9e053caedcb6cf421e02344d.1655336146.git.gitgitgadget@gmail.com [3] https://lore.kernel.org/git/patch-v3-02.12-082e015781e-20220622T142012Z-avarab@gmail.com [4] https://github.com/chooglen/git/actions/runs/2572557584 Glen Choo (6): submodule--helper: eliminate internal "--update" option submodule--helper update: use display path helper submodule--helper: don't recreate recursive prefix submodule--helper: use correct display path helper submodule--helper update: use --super-prefix submodule--helper: remove display path helper Ævar Arnfjörð Bjarmason (12): git-submodule.sh: remove unused sanitize_submodule_env() git-submodule.sh: remove unused $prefix variable git-submodule.sh: make the "$cached" variable a boolean git-submodule.sh: remove unused top-level "--branch" argument submodule--helper: have --require-init imply --init submodule update: remove "-v" option submodule--helper: rename "absorb-git-dirs" to "absorbgitdirs" submodule--helper: report "submodule" as our name in some "-h" output submodule--helper: understand --checkout, --merge and --rebase synonyms git-submodule.sh: use "$quiet", not "$GIT_QUIET" git-sh-setup.sh: remove "say" function, change last users submodule--helper: remove unused SUPPORT_SUPER_PREFIX flags builtin/submodule--helper.c | 161 +++++++++++++++------------------ contrib/subtree/git-subtree.sh | 15 ++- git-instaweb.sh | 2 +- git-sh-setup.sh | 16 ---- git-submodule.sh | 88 +++++++----------- submodule.c | 2 +- t/t7406-submodule-update.sh | 58 +++++++++++- 7 files changed, 175 insertions(+), 167 deletions(-) base-commit: 8168d5e9c23ed44ae3d604f392320d66556453c9 Submitted-As: https://lore.kernel.org/git/pull.1282.v2.git.git.1656623978.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.1282.git.git.1656372017.gitgitgadget@gmail.com
Assets 2
-
2022-06-30T21:19:38Z -
2022-06-30T21:19:38Z - Loading