On 04-Jun-2021, at 16:35, Atharva Raykar [off-list ref] wrote:
Let's add a new "add-clone" subcommand to `git submodule--helper` with
the goal of converting part of the shell code in git-submodule.sh
related to `git submodule add` into C code. This new subcommand clones
the repository that is to be added, and checks out to the appropriate
branch.
This is meant to be a faithful conversion that leaves the behaviour of
'submodule add' unchanged. The only minor change is that if a submodule name has
been supplied with a name that clashes with a local submodule, the message shown
to the user ("A git directory for 'foo' is found locally...") is prepended with
"error" for clarity.
This is part of a series of changes that will result in all of 'submodule add'
being converted to C.
Signed-off-by: Atharva Raykar <redacted>
Mentored-by: Christian Couder [off-list ref]
Mentored-by: Shourya Shukla [off-list ref]
Based-on-patch-by: Shourya Shukla [off-list ref]
Based-on-patch-by: Prathamesh Chavan [off-list ref]
---
Changes since v2:
* Remove printf debug statement that was accidentally inserted into the final
patch
* Rename 'struct add_data info' to the more descriptive
'struct add_data add_data'
* Remove unnecessary variables while parsing flags, and insert into the struct
members directly
* Eliminate extra heap allocation via 'xstrndup()' in parse_token()
(I learnt this trick from Junio's comment on Shourya's v2 review of a similar
patch :^) )
I forgot to mention, but this patch can be fetched via GitHub from:
https://github.com/tfidfwastaken/git/tree/submodule-add-in-c-add-clone-v3