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

Re: Repository cloned using SSH does not respect bare repository initial branch

From
Jeff King <peff@peff.net>
Date
Oct 30, 2023, 17:43 UTC
Message-ID
<20231030174307.GA854621@coredump.intra.peff.net>
In-Reply-To
<b310e254-f6d3-4715-b042-341bf5a98bbc@gmail.com>
On Tue, Oct 31, 2023 at 02:24:46AM +1100, Sheik wrote:
> Server version is same as client (v2.42.0) as I ran these commands all on
> the same machine.
OK. The next thing I'd check is running both commands with:
  GIT_TRACE_PACKET=1 git clone ...

to see the protocol trace, and how it differs between the two. What I suspect you may see is that the local clone is using the "v2" protocol (a capabilities report, followed by "ls-refs", which mentions the symref value of HEAD), and the ssh one uses the older "v0" (it goes straight to the ref advertisement).

Quoting from 59e1205d16 (ls-refs: report unborn targets of symrefs, 2021-02-05), the commit I mentioned before:

    This change is only for protocol v2. A similar change for protocol
    v0 would require independent protocol design (there being no
    analogous position to signal support for "unborn") and client-side
    plumbing of the data required, so the scope of this patch set is
    limited to protocol v2.

So in v0 the server doesn't pass back sufficient information for the client to know about the name of the unborn HEAD branch.

If that's the culprit, the next question of course is why we'd do v2 locally versus v0 overssh. And that probably has to do with how we trigger the protocol upgrade. To see if the server supports v2, the client passes extra information "out of band". For git-over-http, this happens in an extra HTTP header. For local repositories, it happens in an environment variable ($GIT_PROTOCOL). For git-over-ssh it happens in that sameenvironment variable, which we instruct the ssh client to pass using "-o SendEnv". But:

  1. If your ssh client doesn't look like openssh, we don't know if it
     supports "-o" and may skip it. See the discussion in ssh.variant in
     "git help config".
  2. Some servers need to be configured to allow the client to set
     environment variables. In the case of openssh, you'd want a line
     like this in your sshd_config file:
       AcceptEnv GIT_PROTOCOL

Of the two, I'd guess that the second one is more likely to be your problem (since you're running Linux, where openssh is the norm).

-Peff
Previous: SheikNext: Sheik
Message 4 of 7 in “Repository cloned using SSH does not respect bare repository initial branch”
  1. SheikOct 25, 2023
  2. Jeff KingOct 30, 2023
  3. SheikOct 30, 2023
  4. Jeff KingOct 30, 2023
  5. SheikOct 30, 2023
  6. SheikOct 31, 2023
  7. SheikOct 30, 2023

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.