Re: [PATCHv5 3/3] submodule: Reimplement `module_clone` shell function in C
On Wed, Sep 2, 2015 at 5:42 PM, Stefan Beller <sbeller@google.com> wrote:
Show 17 quoted lines
> This reimplements the helper function `module_clone` in shell
> in C as `clone`. This functionality is needed for converting
> `git submodule update` later on, which we want to add threading
> to.
>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
> +static int module_clone(int argc, const char **argv, const char *prefix)
> +{
> + /* Write a .git file in the submodule to redirect to the superproject. */
> + if (safe_create_leading_directories_const(path) < 0)
> + die(_("could not create directory '%s'"), path);
> +
> + if (path && *path)
> + strbuf_addf(&sb, "%s/.git", path);
> + else
> + strbuf_addf(&sb, ".git");Minor: strbuf_addstr(...);
Show 6 quoted lines
> + if (safe_create_leading_directories_const(sb.buf) < 0)
> + die(_("could not create leading directories of '%s'"), sb.buf);
> + submodule_dot_git = fopen(sb.buf, "w");
> + if (!submodule_dot_git)
> + die_errno(_("cannot open file '%s'"), sb.buf);
> +}