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

Re: [PATCH v2 1/6] refs: properly apply exclude patterns to namespaced refs

From
Taylor Blau <me@ttaylorr.com>
Date
Sep 17, 2024, 09:12 UTC
Message-ID
<ZulIB7k18+4CzwZb@nand.local>
In-Reply-To
<7497166422ea702aabdf4159b0d7780f1422ba13.1726476401.git.ps@pks.im>
On Mon, Sep 16, 2024 at 10:50:03AM +0200, Patrick Steinhardt wrote:
Show 16 quoted lines
> This only surfaces when:
>
>   - A repository uses reference namespaces.
>
>   - "transfer.hideRefs" is active.
>
>   - The namespaced references are packed into the "packed-refs" file.
>
> None of our tests exercise this scenario, and thus we haven't ever hit
> it. While t5509 exercises both (1) and (2), it does not happen to hit
> (3). It is trivial to demonstrate the bug though by explicitly packing
> refs in the tests, and then we indeed surface the breakage.
>
> Fix this bug by prefixing exclude patterns with the namespace in the
> generic layer. The newly introduced function will be used outside of
> "refs.c" in the next patch, so we add a declaration to "refs.h".
Thanks for finding and fixing this bug!
Show 21 quoted lines
> diff --git a/refs.c b/refs.c
> index ceb72d4bd74..b3a367ea12c 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -1517,6 +1517,19 @@ const char **hidden_refs_to_excludes(const struct strvec *hide_refs)
>  	return hide_refs->v;
>  }
>
> +const char **get_namespaced_exclude_patterns(const char **exclude_patterns,
> +					     const char *namespace,
> +					     struct strvec *out)
> +{
> +	if (!namespace || !*namespace || !exclude_patterns || !*exclude_patterns)
> +		return exclude_patterns;
> +
> +	for (size_t i = 0; exclude_patterns[i]; i++)
> +		strvec_pushf(out, "%s%s", namespace, exclude_patterns[i]);
> +
> +	return out->v;
> +}
> +

Is it safe to concatenate each exclude pattern with the specified namespace? If I'm reading this correctly, I think we silently do the wrong thing for exclude patterns that start with '^'.

I guess we reject such patterns in the hidden_refs_to_excludes() function, but perhaps we wouldn't have to if this function stripped those prefixes for us when the caller does or doesn't specify exclude patterns with a '^'?

Thanks, Taylor

Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 21 of 36 in “refs/reftable: wire up exclude patterns”
  1. 0/6 refs/reftable: wire up exclude patternsPatrick Steinhardt, Sep 9, 2024
  2. 1/6 refs: properly apply exclude patterns to namespaced refsPatrick Steinhardt, Sep 9, 2024
  3. karthik nayakSep 13, 2024
  4. Patrick SteinhardtSep 16, 2024
  5. 2/6 builtin/receive-pack: fix exclude patterns when announcing refsPatrick Steinhardt, Sep 9, 2024
  6. karthik nayakSep 13, 2024
  7. 3/6 Makefile: stop listing test library objects twicePatrick Steinhardt, Sep 9, 2024
  8. 4/6 t/unit-tests: introduce reftable libraryPatrick Steinhardt, Sep 9, 2024
  9. 5/6 reftable/reader: make table iterator reseekablePatrick Steinhardt, Sep 9, 2024
  10. karthik nayakSep 13, 2024
  11. Patrick SteinhardtSep 16, 2024
  12. karthik nayakSep 17, 2024
  13. 6/6 refs/reftable: wire up support for exclude patternsPatrick Steinhardt, Sep 9, 2024
  14. karthik nayakSep 13, 2024
  15. Patrick SteinhardtSep 16, 2024
  16. karthik nayakSep 17, 2024
  17. karthik nayakSep 13, 2024
  18. Patrick SteinhardtSep 16, 2024
  19. 0/6 refs/reftable: wire up exclude patternsPatrick Steinhardt, Sep 16, 2024
  20. 1/6 refs: properly apply exclude patterns to namespaced refsPatrick Steinhardt, Sep 16, 2024
  21. Taylor BlauSep 17, 2024
  22. Patrick SteinhardtSep 17, 2024
  23. Taylor BlauSep 17, 2024
  24. Patrick SteinhardtSep 17, 2024
  25. Taylor BlauSep 17, 2024
  26. Patrick SteinhardtSep 17, 2024
  27. 2/6 builtin/receive-pack: fix exclude patterns when announcing refsPatrick Steinhardt, Sep 16, 2024
  28. Taylor BlauSep 17, 2024
  29. 3/6 Makefile: stop listing test library objects twicePatrick Steinhardt, Sep 16, 2024
  30. 4/6 t/unit-tests: introduce reftable libraryPatrick Steinhardt, Sep 16, 2024
  31. 5/6 reftable/reader: make table iterator reseekablePatrick Steinhardt, Sep 16, 2024
  32. 6/6 refs/reftable: wire up support for exclude patternsPatrick Steinhardt, Sep 16, 2024
  33. Taylor BlauSep 17, 2024
  34. Patrick SteinhardtSep 17, 2024
  35. Taylor BlauSep 17, 2024
  36. karthik nayakSep 17, 2024

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.