1. 18 Jan, 2019 1 commit
    • Jonathan Tan's avatar
      ls-refs: filter refs using namespace-stripped name · e2f41a0a
      Jonathan Tan authored
      If a user fetches refs/heads/master from a repo with namespace "ns", the
      remote is expected to (1) not send the real refs/heads/master, and (2)
      send refs/namespaces/ns/refs/heads/master with the name
      refs/heads/master. (1) indeed happens now, but not (2) - Git only sends
      refs that have the user-given prefix, but it checks them against the
      full name of the ref (the one starting with refs/namespaces), and not
      the namespace-stripped one.
      
      This is demonstrated by the patch in the test. Currently, it results in
      "fatal: couldn't find remote ref refs/heads/master" despite both
      unnamespaced and namespaced master being present. With the code change,
      it produces the expected result.
      
      Check the ref prefixes against the namespace-stripped name.
      
      This bug was discovered through applying patches [1] that override
      protocol.version to 2 in repositories when running tests, allowing us to
      notice differences in behavior across different protocol versions.
      
      [1] https://public-inbox.org/git/cover.1547677183.git.jonathantanmy@google.com/Signed-off-by: 's avatarJonathan Tan <jonathantanmy@google.com>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      e2f41a0a
  2. 10 Jan, 2019 1 commit
    • Jeff King's avatar
      upload-pack: support hidden refs with protocol v2 · e20b4192
      Jeff King authored
      In the v2 protocol, upload-pack's advertisement has been moved to the
      "ls-refs" command. That command does not respect hidden-ref config (like
      transfer.hiderefs) at all, and advertises everything.
      
      While there are some features that are not supported in v2 (e.g., v2
      always allows fetching any sha1 without respect to advertisements), the
      lack of this feature is not documented and is likely just a bug. Let's
      make it work, as otherwise upgrading a server to a v2-capable git will
      start exposing these refs that the repository admin has asked to remain
      hidden.
      
      Note that we assume we're operating on behalf of a fetch here, since
      that's the only thing implemented in v2 at this point. See the in-code
      comment. We'll have to figure out how this works when the v2 push
      protocol is designed (both here in ls-refs, but also rejecting updates
      to hidden refs).
      Signed-off-by: 's avatarJeff King <peff@peff.net>
      Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
      e20b4192
  3. 15 Mar, 2018 1 commit