Port `submodule init` to C
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest2 patches 3 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | submodule: port resolve_relative_url from shell to Cbuiltin/ git-submodule.sh t/ | +255 | 2 replies | |
| 2/2 | submodule: port init from shell to Cbuiltin/ git-submodule.sh submodule.c +1 more | +138 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/2] Port `submodule init` to C
This is another round for sb/submodule-init.
Changes since last round:
* Also iterate over the submodules in the C helper. With that missing piece git submodule init is completely handled in C now except for the usage string and the command->subcommand selection. (i.e. when calling git submodule init, we still go through git.c -> git-submodule.sh -> submodule--helper.c, but we do not go back into the shell after parsing init and calling module_init for it.
* This applies on another base commit, such that we make use of the tests written in origin/sb/submodule-path-misc-bugs. (I am not sure if I have too many series in flight stomping on each other here)
* This time I actually fix what Ramsay was hinting at:
strbuf_detach(&sb, NULL) instead of strbuf_detach(&sb, 0);
Where do these patches apply?
=============================
I ran the following commands for a new starting point of this series:
git checkout --detach origin/sb/submodule-parallel-update git merge origin/sb/submodule-helper-clone-regression-fix git merge origin/sb/submodule-path-misc-bugs
The second merge produces 2 conflicts, which can be resolved like this:
(I am unsure about the second comment in strbuf.h though)
builtin/fetch.c +0 -0
@@@ -37,7 -37,8 +37,8 @@@ static int prune = -1; /* unspecified *static int all, append, dry_run, force, keep, multiple, update_head_ok, verbosity;static int progress =-1 , recurse_submodules =RECURSE_SUBMODULES_DEFAULT ;static int tags =TAGS_DEFAULT , unshallow, update_shallow; -static int max_children = 1; +static int max_children = -1; +static enum transport_family family;static const char *depth;static const char *upload_pack;static struct strbuf default_rla =STRBUF_INIT ;
strbuf.h +0 -0
@@@ -387,15 -387,10 +387,16 @@@ extern ssize_t strbuf_read_file(structextern int strbuf_readlink (struct strbuf *sb,const char *path,size_t hint);/** + * Write the whole content of the strbuf to the stream not stopping at + * NUL bytes. + */ +extern ssize_t strbuf_write(struct strbuf *sb, FILE *stream); + +/** -* Read a line from a FILE *, overwriting the existing contents -* of the strbuf. The second argument specifies the line -* terminator character, typically `'\n'`. +* Read a line from a FILE *, overwriting the existing contents of +* the strbuf. The strbuf_getline*() family of functions share +* this signature, but have different line termination conventions. +* * Reading stops after the terminator or at EOF. The terminator * is removed from the buffer before returning. Returns 0 unless * there was nothing left before EOF, in which case it returns `EOF`.
As sb/submodule-parallel-update and sb/submodule-helper-clone-regression-fix both touch builtin/submodule--helper.c, so we need those.
We need origin/sb/submodule-path-misc-bugs as it tests submodule add output.
Thanks,
Stefan
Stefan Beller (2):
submodule: port resolve_relative_url from shell to C
submodule: port init from shell to C
builtin/submodule--helper.c | 322 +++++++++++++++++++++++++++++++++++++++++++- git-submodule.sh | 127 +---------------- submodule.c | 21 +++ submodule.h | 1 + t/t0060-path-utils.sh | 43 ++++++ 5 files changed, 392 insertions(+), 122 deletions(-)
Signature · 1 line
2.8.0.26.g0341e85