From: Eric Sunshine Date: Thu, 03 Sep 2015 23:17:50 GMT Subject: Re: [PATCHv5 3/3] submodule: Reimplement `module_clone` shell function in C Message-ID: In-Reply-To: <1441230146-26921-4-git-send-email-sbeller@google.com> On Wed, Sep 2, 2015 at 5:42 PM, Stefan Beller wrote: > 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 > --- > +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(...); > + 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); > +}