On 04-Jun-2021, at 16:35, Atharva Raykar <raykar.ath@xxxxxxxxx> 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 <raykar.ath@xxxxxxxxx> > Mentored-by: Christian Couder <christian.couder@xxxxxxxxx> > Mentored-by: Shourya Shukla <shouryashukla.oo@xxxxxxxxx> > Based-on-patch-by: Shourya Shukla <shouryashukla.oo@xxxxxxxxx> > Based-on-patch-by: Prathamesh Chavan <pc44800@xxxxxxxxx> > --- > > 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