{"thread":{"id":"56160","subject":"ref-in-want does not consider namespace","startedAt":"2021-07-26T08:36:52Z","lastAt":"2021-07-27T09:12:31Z","messageCount":4,"participants":["Kim Altintop","Jonathan Tan"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"431166","messageId":"CD2XNXHACAXS.13J6JTWZPO1JA@schmidt","threadId":"56160","inReplyTo":null,"subject":"ref-in-want does not consider namespace","fromName":"Kim Altintop","fromEmail":"kim@eagain.st","sentAt":"2021-07-26T08:36:39Z","receivedAt":"2021-07-26T08:36:52Z","isPatch":false,"sender":{"key":"kim@eagain.st","avatar":"https://avatars.githubusercontent.com/u/6163?v=4"},"body":"Hello,\n\nI am experimenting with the ref-in-want feature using a custom client and plain\n`git-upload-pack` on the server end. To my suprise, it turned out that fetching\nfrom a namespaced repository requires the `want-ref` lines to specify the refs\nin namespaced form. That is:\n\nSay I have the ref `refs/namespaces/foo/refs/heads/main`. I launch upload-pack\nwith `--namespace=foo`. Running `ls-refs` with a namespace-relative\n\n  `ref-prefix refs/heads/*`\n\nwill work as expected, but sendingr\n\n  `want-ref refs/heads/main`\n\nwill result in\n\n  `ERR unknown ref refs/heads/main`\n\nSending\n\n  `want-ref refs/namespaces/foo/refs/heads/main`\n\nworks, and the corresponding `wanted-refs` section will contain the ref as given\n(ie. including the namespace path).\n\nSince my understanding of git namespaces is that they should be transparent to\nthe client, I find this surprising.\n\nI dug up an early version of a patch introducing the feature, which did handle\nnamespaces [0], but what eventually landed (authored by Brandon Williams)\ndidn't.\n\n\nWas this an oversight, or is there a specific reason for the behaviour?\n\n\nThanks,\nKim\n\n\n\n[0]: https://lore.kernel.org/git/d0d42b3bb4cf755f122591e191354c53848f197d.1485381677.git.jonathantanmy@google.com/\n"},{"id":"431176","messageId":"pMV5dJabxOBTD8kJBaPuWK0aS6OJhRQ7YFGwfhPCeSJEbPDrIFBza36nXBCgUCeUJWGmpjPI1rlOGvZJEh71Ruz4SqljndUwOCoBUDRHRDU=@eagain.st","threadId":"56160","inReplyTo":"CD2XNXHACAXS.13J6JTWZPO1JA@schmidt","subject":"Re: ref-in-want does not consider namespace","fromName":"Kim Altintop","fromEmail":"kim@eagain.st","sentAt":"2021-07-26T11:55:55Z","receivedAt":"2021-07-26T11:56:02Z","isPatch":false,"sender":{"key":"kim@eagain.st","avatar":"https://avatars.githubusercontent.com/u/6163?v=4"},"body":"\n\n> Running `ls-refs` with a namespace-relative\n>\n> `ref-prefix refs/heads/*`\n>\n> will work as expected\n\nThat turned out to not be entirely true: it does work as expected with a 2.31.1 install, but fails to select any refs with 2.20.1.\n"},{"id":"431201","messageId":"20210726164414.2208736-1-jonathantanmy@google.com","threadId":"56160","inReplyTo":"pMV5dJabxOBTD8kJBaPuWK0aS6OJhRQ7YFGwfhPCeSJEbPDrIFBza36nXBCgUCeUJWGmpjPI1rlOGvZJEh71Ruz4SqljndUwOCoBUDRHRDU=@eagain.st","subject":"Re: ref-in-want does not consider namespace","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2021-07-26T16:44:14Z","receivedAt":"2021-07-26T16:47:16Z","isPatch":false,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"> > Running `ls-refs` with a namespace-relative\n> >\n> > `ref-prefix refs/heads/*`\n> >\n> > will work as expected\n> \n> That turned out to not be entirely true: it does work as expected with a\n> 2.31.1 install, but fails to select any refs with 2.20.1.\n\nYour expectation that \"want-ref refs/heads/main\" should match\n\"refs/namespaces/foo/refs/heads/main\" when you run upload-pack with\n\"--namespace=foo\" makes sense to me. Just to clarify - does this mean\ntha 2.31.1 works like you expect?\n\nIn any case, t5703 should contain a namespace test, but it doesn't seem\nto. We could just use the one in my original patch [1] (thanks for\nlooking it up, by the way). Would you be able to contribute a patch? I\nsee that in [1], I had my own helpers to construct the input, but\n\"test-tool pkt-line\" now exists (as you can see in t5703) so you can do\nthat instead.\n\n[1] https://lore.kernel.org/git/d0d42b3bb4cf755f122591e191354c53848f197d.1485381677.git.jonathantanmy@google.com/\n"},{"id":"431294","messageId":"CD3T1FV0ICZK.1QYV25UTSU768@schmidt","threadId":"56160","inReplyTo":"20210726164414.2208736-1-jonathantanmy@google.com","subject":"Re: ref-in-want does not consider namespace","fromName":"Kim Altintop","fromEmail":"kim@eagain.st","sentAt":"2021-07-27T09:11:52Z","receivedAt":"2021-07-27T09:12:31Z","isPatch":false,"sender":{"key":"kim@eagain.st","avatar":"https://avatars.githubusercontent.com/u/6163?v=4"},"body":"Thanks Jonathan\n\n> Your expectation that \"want-ref refs/heads/main\" should match\n> \"refs/namespaces/foo/refs/heads/main\" when you run upload-pack with\n> \"--namespace=foo\" makes sense to me. Just to clarify - does this mean\n> tha 2.31.1 works like you expect?\n\n\"ref-prefix\" works as expected in the newer version, but not \"want-ref\". I\nhaven't properly bisected, but the fix seems to coincide with b3970c7, although\nI'm not sure if that was intentional.\n\n> In any case, t5703 should contain a namespace test, but it doesn't seem\n> to.\n\nYes I noticed that your original patch did contain a test for this.\n\n> Would you be able to contribute a patch?\n\nWith some handholding, I'd be at least up for giving it a spin :)\n\nOne thing that is unclear to me is how \"hideRefs\" is supposed to interact with\n\"want-ref\". At the moment, it seems like a client can \"want-ref\" _any_ ref, even\nif it is hidden by \"hideRefs\". It might seem sensible to ignore hidden refs, but\nthen the situation could occur that the effective list of \"want-ref\"s is empty.\n\nIf that happens, and the client did not send any \"want\"s either, \"upload-pack\"\nignores the fetch command altogether and just waits for the next command. In\nthis case, the client can only recover by timing out the connection.\n\nSo should this be special-cased somehow and result in an error response?\n\n"}]}