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

Re: [RFC/PATCH] tag: make list exclude !<pattern>

From
Tom Grennan <tmgrennan@gmail.com>
Date
Feb 11, 2012, 19:47 UTC
Message-ID
<20120211194719.GE4903@tgrennan-laptop>
In-Reply-To
<7vy5s9n70x.fsf@alter.siamese.dyndns.org>
On Fri, Feb 10, 2012 at 11:50:06PM -0800, Junio C Hamano wrote:
Show 5 quoted lines
>Junio C Hamano <gitster@pobox.com> writes:
>
>>    ... Same
>>    for 1c, which I highly suspect will introduce regression without
>>    looking at the code (for-each-ref is prefix-match only), ...

OK I'll study this further and run through t6300-for-each-ref.sh I see it has a bunch of errors. I think there are similar issues using match_pattern() with show-branch and ls-remote.

Thanks,
Show 55 quoted lines
>This part needs correction.  for-each-ref matches the command line
>arguments differently from branch --list and tag --list in two important
>ways.
>
> (1) It allows (not "only" which was a mistake in my earlier message)
>     prefix matching, e.g. "for-each-ref refs/heads/", in addition to
>     fnmatch(); and
>
> (2) The fnmatch() call is made with FNM_PATHMAME, which "branch --list"
>     and "tag --list" does not use.
>
>Strictly speaking, therefore, if you make all three commands to use the
>same matching logic, there is no way to avoid regression.  If you choose
>to use fnmatch() without FNM_PATHNAME, then for-each-ref suddenly starts
>matching wildcards across name hierarchy boundary '/' for a pattern that
>does not match today, e.g. "git for-each-ref 'refs/heads/*'" was a good
>way to grab only the integration branches while excluding individual topic
>branches such as refs/heads/tg/tag-points-at, but this technique can no
>longer be used for such a purpose, which is an unpleasant regression.
>
>I personally think that it was an annoying UI mistake that we let branch
>and tag call fnmatch without FNM_PATHNAME, but we cannot fix it lightly,
>either.  People who use hierchical branch names (e.g. maint-1.0/$topic,
>maint-2.0/$topic, and feature-2.0/$topic) may already be used to list all
>the topics on the maintenance tracks with "branch --list 'maint*'", and we
>need to keep "branch --list" and "tag --list" working as they expect.
>
>One possible way forward (now I am talking about a longer term solution)
>would be to introduce
>
>	refname_match_pattern(const char *refname,
>        		      const char **pattern,
>                              unsigned flags);
>
>where flags can tell the implementation if FNM_PATHNAME should be used,
>and if prefix matching should be attempted, so that the three commands
>share the single same matching function while still retaining their
>current behaviour in the initial round.  Inside the implementation, we
>would use good old fnmatch(), with or without FNM_PATHNAME, depending on
>the flags the caller passes.
>
>In a future versions, we may want to have "branch/tag --list" also ask for
>FNM_PATHNAME (this *is* a backward incompatible change, so it needs to be
>performed across major version boundary, with backward compatibility
>configurations, deprecation warnings and whole nine yards). Under the new
>match function, today's "branch --list 'maint*'" needs to be spelled as
>"branch --list 'maint*/*'" or something.  The prefix matching is probably
>safer to enable by default without causing big regression hassle if we
>limit the prefix match to only patterns that end with an explicit slash,
>as users already *know* today's "branch --list tg/" would not match
>anything (because the pattern does not even match a brahch 'tg', so it is
>unlikely they are using it and expecting only 'tg' to match), which means
>that is an unlikely input we can safely give new meaning to match anything
>under tg/ hierarchy.
>
Previous: Junio C HamanoNext: Michael Haggerty
Message 24 of 83 in “tag: make list exclude !<pattern>”
  1. tag: make list exclude !<pattern>Tom Grennan, Feb 9, 2012
  2. tag: make list exclude !<pattern>Tom Grennan, Feb 9, 2012
  3. Tom GrennanFeb 10, 2012
  4. Nguyen Thai Ngoc DuyFeb 10, 2012
  5. Tom GrennanFeb 10, 2012
  6. Tom GrennanFeb 11, 2012
  7. 1/4 refs: add common refname_match_patterns()Tom Grennan, Feb 11, 2012
  8. Michael HaggertyFeb 11, 2012
  9. Tom GrennanFeb 11, 2012
  10. Michael HaggertyFeb 13, 2012
  11. Tom GrennanFeb 13, 2012
  12. Junio C HamanoFeb 11, 2012
  13. Tom GrennanFeb 11, 2012
  14. Junio C HamanoFeb 11, 2012
  15. Tom GrennanFeb 13, 2012
  16. 2/4 tag: use refs.c:refname_match_patterns()Tom Grennan, Feb 11, 2012
  17. 3/4 branch: use refs.c:refname_match_patterns()Tom Grennan, Feb 11, 2012
  18. 4/4 for-each-ref: use refs.c:refname_match_patterns()Tom Grennan, Feb 11, 2012
  19. Junio C HamanoFeb 11, 2012
  20. Junio C HamanoFeb 11, 2012
  21. Jakub NarebskiFeb 11, 2012
  22. Nguyen Thai Ngoc DuyFeb 11, 2012
  23. Junio C HamanoFeb 11, 2012
  24. Tom GrennanFeb 11, 2012
  25. Michael HaggertyFeb 11, 2012
  26. Junio C HamanoFeb 11, 2012
  27. Michael HaggertyFeb 13, 2012
  28. Junio C HamanoFeb 13, 2012
  29. Michael HaggertyFeb 13, 2012
  30. Junio C HamanoFeb 13, 2012
  31. Michael HaggertyFeb 13, 2012
  32. Junio C HamanoFeb 13, 2012
  33. Tom GrennanFeb 11, 2012
  34. 0/5 Re: tag: make list exclude !<pattern>Tom Grennan, Feb 22, 2012
  35. 1/5 refs: add match_pattern()Tom Grennan, Feb 22, 2012
  36. Junio C HamanoFeb 22, 2012
  37. Tom GrennanFeb 22, 2012
  38. Junio C HamanoFeb 23, 2012
  39. Tom GrennanFeb 23, 2012
  40. 2/5 tag --points-at option wrapperTom Grennan, Feb 22, 2012
  41. 3/5 tag --exclude optionTom Grennan, Feb 22, 2012
  42. Junio C HamanoFeb 22, 2012
  43. Tom GrennanFeb 23, 2012
  44. Junio C HamanoFeb 23, 2012
  45. 0/5 modernize test styleTom Grennan, Mar 1, 2012
  46. 1/5 t6300 (for-each-ref): modernize styleTom Grennan, Mar 1, 2012
  47. Johannes SixtMar 1, 2012
  48. Tom GrennanMar 1, 2012
  49. 2/5 t5512 (ls-remote): modernize styleTom Grennan, Mar 1, 2012
  50. Thomas RastMar 1, 2012
  51. 3/5 t3200 (branch): modernize styleTom Grennan, Mar 1, 2012
  52. 4/5 t0040 (parse-options): modernize styleTom Grennan, Mar 1, 2012
  53. 5/5 t7004 (tag): modernize styleTom Grennan, Mar 1, 2012
  54. 101/105 t6300 (for-each-ref): modernize styleTom Grennan, Mar 1, 2012
  55. Junio C HamanoMar 1, 2012
  56. Tom GrennanMar 1, 2012
  57. Junio C HamanoMar 1, 2012
  58. Tom GrennanMar 1, 2012
  59. Tom GrennanMar 1, 2012
  60. Thomas RastMar 1, 2012
  61. Tom GrennanMar 1, 2012
  62. 102/105 t5512 (ls-remote): modernize styleTom Grennan, Mar 1, 2012
  63. 103/105 t3200 (branch): modernize styleTom Grennan, Mar 1, 2012
  64. 104/105 t0040 (parse-options): modernize styleTom Grennan, Mar 1, 2012
  65. 105/105 t7004 (tag): modernize styleTom Grennan, Mar 1, 2012
  66. 0/5 modernize test styleTom Grennan, Mar 3, 2012
  67. 1/5 t7004 (tag): modernize styleTom Grennan, Mar 3, 2012
  68. Johannes SixtMar 3, 2012
  69. 2/5 t5512 (ls-remote): modernize styleTom Grennan, Mar 3, 2012
  70. Junio C HamanoMar 3, 2012
  71. Tom GrennanMar 3, 2012
  72. 3/5 t3200 (branch): modernize styleTom Grennan, Mar 3, 2012
  73. 4/5 t0040 (parse-options): modernize styleTom Grennan, Mar 3, 2012
  74. 5/5 t6300 (for-each-ref): modernize styleTom Grennan, Mar 3, 2012
  75. 101/105 t7004 (tag): modernize styleTom Grennan, Mar 3, 2012
  76. 102/105 t5512 (ls-remote): modernize styleTom Grennan, Mar 3, 2012
  77. 103/105 t3200 (branch): modernize styleTom Grennan, Mar 3, 2012
  78. 104/105 t0040 (parse-options): modernize styleTom Grennan, Mar 3, 2012
  79. 105/105 t6300 (for-each-ref): modernize styleTom Grennan, Mar 3, 2012
  80. Junio C HamanoMar 3, 2012
  81. Tom GrennanMar 3, 2012
  82. 4/5 branch --exclude optionTom Grennan, Feb 22, 2012
  83. 5/5 for-each-ref --exclude optionTom Grennan, Feb 22, 2012

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.