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

Re: [PATCH] clone: support 'clone --shared' from a worktree

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Dec 12, 2017, 00:40 UTC
Message-ID
<CAPig+cSTsuHdAqdBMvO80ybTSzfxncX8yQODSKd1bmaoNRQOjw@mail.gmail.com>
In-Reply-To
<20171212001802.GC177995@google.com>
On Mon, Dec 11, 2017 at 7:18 PM, Brandon Williams <bmwill@google.com> wrote:
Show 11 quoted lines
> On 12/11, Eric Sunshine wrote:
>>               struct strbuf alt = STRBUF_INIT;
>> -             strbuf_addf(&alt, "%s/objects", src_repo);
>> +             get_common_dir(&alt, src_repo);
>> +             strbuf_addstr(&alt, "/objects");
>
> If you wanted to do this in one function call you could either use
> 'strbuf_git_common_path()' or either 'strbuf_git_path()' or
> 'strbuf_repo_git_path()' which will do the proper path adjustments when
> working on a path which should be shared between worktrees (i.e. part of
> the common git dir).

Thanks for the pointers, however, the above fix mirrors the fix made by 744e469755 (clone: allow --local from a linked checkout, 2015-09-28) to code immediately below it in the 'else' arm:

    get_common_dir(&src, src_repo);
    get_common_dir(&dest, dest_repo);
    strbuf_addstr(&src, "/objects");
    strbuf_addstr(&dest, "/objects");

It would be poor form and confusing to use one of the mechanisms you suggest while leaving the 'else' arm untouched.

Re-working both arms of the 'if' to use one of the suggested functions would make a fine follow-on or preparatory patch, however, I'd rather not hold up this fix merely to re-roll for such a minor cleanup. (I also considered a follow-on patch to reduce the duplication between the two cases but decided against it, for the present, since such a patch would almost be noise without much gain.)

By the way, is there any documentation explaining the differences between all these similar functions and when one should be used over the others?

Previous: Brandon WilliamsNext: Brandon Williams
Message 4 of 8 in “clone: support 'clone --shared' from a worktree”
  1. clone: support 'clone --shared' from a worktreeEric Sunshine, Dec 11, 2017
  2. Junio C HamanoDec 12, 2017
  3. Brandon WilliamsDec 12, 2017
  4. Eric SunshineDec 12, 2017
  5. Brandon WilliamsDec 12, 2017
  6. path: document path functionsBrandon Williams, Dec 13, 2017
  7. Junio C HamanoDec 13, 2017
  8. Eric SunshineDec 20, 2017

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.