On 9/1/2021 12:45 PM, Junio C Hamano wrote: > "Johannes Schindelin via GitGitGadget" <gitgitgadget@xxxxxxxxx> > writes: > ... >> + dir = xstrfmt("%s/src", enlistment); >> + >> + strbuf_reset(&buf); >> + if (branch) >> + strbuf_addf(&buf, "init.defaultBranch=%s", branch); >> + else { >> + char *b = repo_default_branch_name(the_repository, 1); >> + strbuf_addf(&buf, "init.defaultBranch=%s", b); >> + free(b); > > Doesn't "git clone" already use their HEAD without having to make an > extra "git ls-remote" roundtrip? > > Ahh, you do not do "git clone"; you do "git init", set things up, > and then "git fetch" and checkout, all manually. > > Which is kind of shame. > > I wonder if it is a cleaner implementation to give a new option to > "git clone" that gives a command sequence (not necessarily have to > be implemented as a shell script) that specifies necessary > pre-configuration steps to be done before the command starts the > transfer step. I agree that 'git clone' plus maybe some more improvements like '--sparse=cone' to set up cone-mode sparse-checkout would be good. And also the implementation being contributed here is cleaner if we can use 'git clone'. We are trying to balance a clean upstream implementation with some custom things that we still need in our microsoft/git fork to handle the integration with the GVFS Protocol (i.e. partial clone on Azure Repos). That customization is cleaner to keep here in the scalar code instead of adding an option to 'git clone'. It is difficult to justify code patterns here due to choices we have made in our fork, so I _could_ see a way to replace those custom bits with new, custom flags to 'git clone'. It just requires additional investment during our integration when we incorporate these upstream changes. Naturally, I'm motivated to avoid that extra work. If your opinion to switch to 'git clone' is a strong one, then I could see us doing that change. I just want you to be aware of the hidden reasons for choices like these. Thanks, -Stolee