submodule--helper: remove unused "list" helper

Remove the "submodule--helper list" sub-command, which hasn't been used by git-submodule.sh since 2964d6e5e1e (submodule: port subcommand 'set-branch' from shell to C, 2020-06-02). There was a test added in 2b56bb7a87a (submodule helper list: respect correct path prefix, 2016-02-24) which relied on it, but the right thing to do here is to delete that test as well. That test was regression testing the "list" subcommand itself. We're not getting anything useful from the "list | cut -f2" invocation that we couldn't get from "foreach 'echo $sm_path'". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Reviewed-by: Glen Choo <chooglen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Sep 1, 2022 at 01:17 UTC 31955475d1c283120d5d84247eb3fd55d9f5fdd9
2 files changed -65
builtin/submodule--helper.c
-40
@@ -266,45 +266,6 @@ static char *get_up_path(const char *path)
266 return strbuf_detach(&sb, NULL);
267 }
268
269 -static int module_list(int argc, const char **argv, const char *prefix)
270 -{
271 - int i;
272 - struct pathspec pathspec;
273 - struct module_list list = MODULE_LIST_INIT;
274 -
275 - struct option module_list_options[] = {
276 - OPT_STRING(0, "prefix", &prefix,
277 - N_("path"),
278 - N_("alternative anchor for relative paths")),
279 - OPT_END()
280 - };
281 -
282 - const char *const git_submodule_helper_usage[] = {
283 - N_("git submodule--helper list [--prefix=<path>] [<path>...]"),
284 - NULL
285 - };
286 -
287 - argc = parse_options(argc, argv, prefix, module_list_options,
288 - git_submodule_helper_usage, 0);
289 -
290 - if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0)
291 - return 1;
292 -
293 - for (i = 0; i < list.nr; i++) {
294 - const struct cache_entry *ce = list.entries[i];
295 -
296 - if (ce_stage(ce))
297 - printf("%06o %s U\t", ce->ce_mode,
298 - oid_to_hex(null_oid()));
299 - else
300 - printf("%06o %s %d\t", ce->ce_mode,
301 - oid_to_hex(&ce->oid), ce_stage(ce));
302 -
303 - fprintf(stdout, "%s\n", ce->name);
304 - }
305 - return 0;
306 -}
307 -
269 static void for_each_listed_submodule(const struct module_list *list,
270 each_submodule_fn fn, void *cb_data)
271 {
@@ -3340,7 +3301,6 @@ struct cmd_struct {
3301 };
3302
3303 static struct cmd_struct commands[] = {
3343 - {"list", module_list, 0},
3304 {"clone", module_clone, SUPPORT_SUPER_PREFIX},
3305 {"add", module_add, 0},
3306 {"update", module_update, SUPPORT_SUPER_PREFIX},
t/t7400-submodule-basic.sh
-25
@@ -1255,31 +1255,6 @@ test_expect_success 'submodule add clone shallow submodule' '
1255 )
1256 '
1257
1258 -test_expect_success 'submodule helper list is not confused by common prefixes' '
1259 - mkdir -p dir1/b &&
1260 - (
1261 - cd dir1/b &&
1262 - git init &&
1263 - echo hi >testfile2 &&
1264 - git add . &&
1265 - git commit -m "test1"
1266 - ) &&
1267 - mkdir -p dir2/b &&
1268 - (
1269 - cd dir2/b &&
1270 - git init &&
1271 - echo hello >testfile1 &&
1272 - git add . &&
1273 - git commit -m "test2"
1274 - ) &&
1275 - git submodule add /dir1/b dir1/b &&
1276 - git submodule add /dir2/b dir2/b &&
1277 - git commit -m "first submodule commit" &&
1278 - git submodule--helper list dir1/b | cut -f 2 >actual &&
1279 - echo "dir1/b" >expect &&
1280 - test_cmp expect actual
1281 -'
1282 -
1258 test_expect_success 'setup superproject with submodules' '
1259 git init sub1 &&
1260 test_commit -C sub1 test &&