Re: [PATCH v5 0/3] Cloning with remote unborn HEAD
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 27, 2021, 01:11 UTC
- Message-ID
- <xmqqeei7yyi9.fsf@gitster.c.googlers.com>
- In-Reply-To
- <cover.1611686656.git.jonathantanmy@google.com>
Jonathan Tan <jonathantanmy@google.com> writes:
Show 7 quoted lines
> Thanks, Peff, for your review. I have addressed your comments (through > replies to your emails and here in this v5 patch set). > > Jonathan Tan (3): > ls-refs: report unborn targets of symrefs > connect, transport: encapsulate arg in struct > clone: respect remote unborn HEAD
Applying this alone to 'master' seems to pass all tests, but the topic seems to have funny interactions with another topic in flight, jk/peel-iterated-oid
There is textual conflict whose resolution seems trivial, but with that resolved ...
diff --cc builtin/clone.c
index e335734b4c,77fdc61f4d..0000000000
--- i/builtin/clone.c
+++ w/builtin/clone.c
@@@ -1326,10 -1330,21 +1330,21 @@@ int cmd_clone(int argc, const char **ar
remote_head = NULL;
option_no_checkout = 1;
if (!option_bare) {
- const char *branch = git_default_branch_name(0);
- char *ref = xstrfmt("refs/heads/%s", branch);
+ const char *branch;
+ char *ref;
+
+ if (transport_ls_refs_options.unborn_head_target &&
+ skip_prefix(transport_ls_refs_options.unborn_head_target,
+ "refs/heads/", &branch)) {
+ ref = transport_ls_refs_options.unborn_head_target;
+ transport_ls_refs_options.unborn_head_target = NULL;
+ } else {
- branch = git_default_branch_name();
++ branch = git_default_branch_name(0);
+ ref = xstrfmt("refs/heads/%s", branch);
+ }
install_branch_config(0, branch, remote_name, ref);
+ create_symref("HEAD", ref, "");
free(ref);
}
}... numerous tests fail.
For example, t5702 dies like so:
expecting success of 5702.15 'clone of empty repo propagates name of default branch':
test_when_finished "rm -rf file_empty_parent file_empty_child" && GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
git -c init.defaultBranch=mydefaultbranch init file_empty_parent && GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
git -c init.defaultBranch=main -c protocol.version=2 \
clone "file://$(pwd)/file_empty_parent" file_empty_child &&
grep "refs/heads/mydefaultbranch" file_empty_child/.git/HEADInitialized empty Git repository in /usr/local/google/home/jch/w/git.git/t/trash directory.t5702-protocol-v2/file_empty_parent/.git/ Cloning into 'file_empty_child'... fatal: expected flush after ref listing not ok 15 - clone of empty repo propagates name of default branch