git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCHv4 3/3] submodule: implement `clone` as a builtin helper

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Sep 1, 2015, 19:15 UTC
Message-ID
<CAPig+cQUKVSmt6KNpo01wo8Wzq4YxoX130ROWEri7pVXv1YLqg@mail.gmail.com>
In-Reply-To
<20150901190506.GA8254@sigill.intra.peff.net>
On Tue, Sep 1, 2015 at 3:05 PM, Jeff King <peff@peff.net> wrote:
Show 25 quoted lines
> On Tue, Sep 01, 2015 at 02:52:54PM -0400, Eric Sunshine wrote:
>> > +       /* Redirect the worktree of the submodule in the superproject's config */
>> > +       if (strbuf_getcwd(&sb))
>> > +               die_errno(_("unable to get current working directory"));
>> > +
>> > +       if (!is_absolute_path(sm_gitdir)) {
>> > +               if (strbuf_getcwd(&sb))
>> > +                       die_errno(_("unable to get current working directory"));
>>
>> Why does this need to call getcwd() on 'sb' when it was called
>> immediately above the conditional and its value hasn't changed?
>
> Even weirder, the next code is:
>
>> > +               strbuf_addf(&sb, "/%s", sm_gitdir);
>> > +               free(sm_gitdir);
>> > +               sm_gitdir = strbuf_detach(&sb, NULL);
>> > +       }
>> > +
>> > +
>> > +       strbuf_addf(&sb, "/%s", path);
>
> So if it _was_ an absolute path, we are adding "/$path" to nothing
> (having just detached the strbuf in the conditional above). That seems
> weird.

Indeed, I saw that too, but didn't mention it since this appears to be an incomplete refactoring from the previous round, and my hope was that mentioning the getcwd() oddity would be enough to trigger a thorough check of the code before sending the next version.

Previous: Jeff KingNext: Junio C Hamano
Message 11 of 12 in “[PATCHv4 0/3] submodule--helper: Have some refactoring only patches first”
  1. Stefan BellerSep 1, 2015
  2. 1/3 submodule: implement `list` as a builtin helperStefan Beller, Sep 1, 2015
  3. Junio C HamanoSep 1, 2015
  4. Junio C HamanoSep 2, 2015
  5. Eric SunshineSep 1, 2015
  6. 2/3 submodule: implement `name` as a builtin helperStefan Beller, Sep 1, 2015
  7. Eric SunshineSep 1, 2015
  8. 3/3 submodule: implement `clone` as a builtin helperStefan Beller, Sep 1, 2015
  9. Eric SunshineSep 1, 2015
  10. Jeff KingSep 1, 2015
  11. Eric SunshineSep 1, 2015
  12. Junio C HamanoSep 1, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.