Re: [GSoC][PATCH v5] submodule: port subcommand 'set-branch' from shell to C
From: Junio C Hamano <hidden>
Date: 2020-06-04 15:03:40
Shourya Shukla [off-list ref] writes:
On 03/06 01:02, Junio C Hamano wrote:quoted
I'd expect that when that day with no scripted parts of "git submodule" remains comes, the main entry point functions in builtin/submodule--helper.c (like module_list(), update_clone(), module_set_branch(), etc.) will become helper functions that live in submodule-lib.c and would be called from builtin/submodule.c. And the conversion would rip out calls to parse_options() in each of these functions that would migrate to submodule-lib.c Side note: instead of adding submodule-lib.c, you could add them directly to submodule.c if they are small enough. I am however modeling after how the "diff" family was converted to C; the diff-lib.c layer is "library-ish helpers that get pre-parsed command line arguments and performs a single unit of work" that utilizes service routines at the lower layer that are in diff.c and submodule-lib.c and submodule.c will be in a similar kind of relationship.There does exist a `submodule.c` outside of `builtin/` which has various helper functions. Will that require renaming to `submodule-lib.c`?
No, that is different from what I wrote above. Just like there is the middle-layer diff-lib.c between the top-layer builtin/diff.c and the low-level helper sets in diff.c, I envision that between the top-layer builtin/submodule.c and the low-level helper sets in submodule.c, there would be the middle layer submodule-lib.c. If a single cmd_submodule_set_url() function implements the whole of "git submoduel set-url" (by calling helper routines in submodule.c and those currently in builtin/submodule--helper.c), I would expect it to reside in builtin/submodule.c.