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:08 UTC
Message-ID
<20120211190856.GB4903@tgrennan-laptop>
In-Reply-To
<7vaa4qnk4u.fsf@alter.siamese.dyndns.org>
On Fri, Feb 10, 2012 at 07:06:57PM -0800, Junio C Hamano wrote:
Show 64 quoted lines
>Tom Grennan <tmgrennan@gmail.com> writes:
>
>>>If we pursue this, it may be best to first add match_patterns() to ./refs.[ch]
>>>then incrementally modify these builtin commands to use it.
>>
>> The following series implements !<pattern> with: git-tag, git-branch, and
>> git-for-each-ref.
>>
>> This still requires Documentation and unit test updates but I think these are
>> close to functionally complete.
>>
>>>>About the '!' for exclusion, maybe it's better to move from fnmatch()
>>>>as matching machinery to pathspec. Then when git learns negative
>>>>pathspec [1], we have this feature for free.
>>>>
>>>>[1] http://thread.gmane.org/gmane.comp.version-control.git/189645/focus=190072
>>
>> After looking at this some more, I don't understand the value of replacing
>> libc:fnmatch().  Or are you just referring to '--exclude' instead of
>> [!]<pattern> argument parsing?
>
>I have not formed a firm opinion on Nguyen's idea to reuse pathspec
>matching infrastructure for this purpose, so I wouldn't comment on that
>part. It certainly looks attractive, as it allows users to learn one and
>only one extended matching syntax, but at the same time, it has a risk to
>mislead people to think that the namespace for refs is similar to that of
>the filesystem paths, which I see as a mild downside.
>
>In any case, I do not like the structure of this series. If it followed
>our usual pattern, it would consist of patches in this order:
>
> - Patch 1 would extract match_pattern() from builtin/tag.c and introduce
>   the new helper function refname_match_patterns() to refs.c.  It updates
>   the call sites of match_pattern() in builtin/tag.c, match_patterns() in
>   builtin/branch.c, and the implementation of grab_single_ref() in
>   builtin/for-each-ref.c with a call to the new helper function.
>
>   This step can and probably should be done as three sub-steps.  1a would
>   move builtin/tag.c::match_pattern() to refs.::refname_match_patterns(),
>   1b would use the new helper in builtin/branch.c and 1c would do the
>   same for builtin/for-each-ref.c.
>
>   It is important that this patch does so without introducing any new
>   functionality to the new function over the old one. When done this way,
>   there is no risk of introducing new bugs at 1a because it is purely a
>   code movement and renaming; 1b could introduce a bug that changes
>   semantics for bulitin/branch.c if its match_patterns() does things
>   differently from match_pattern() lifted from builtin/tag.c, and if it
>   is found out to be buggy, we can discard 1b without discarding 1a. Same
>   for 1c, which I highly suspect will introduce regression without
>   looking at the code (for-each-ref is prefix-match only), that can
>   safely be discarded.
>
>   This is to make it easier to ensure that the update does not introduce
>   new bugs.
>
> - Patch 2 would then add the new functionality to the new helper. It
>   would also adjust the documentation of the three end user facing
>   commands to describe the fallout coming from this change, and adds new
>   tests to make sure future changes will not break this new
>   functionality.
>
>That is, first refactor and clean-up without adding anything new, and then
>build new stuff on solidified ground.

Nuts! I have the cart before the horse. I'll try to rearrange the series as suggested by tomorrow. Thanks.

Show 6 quoted lines
>Do we allow a refname whose pathname component begins with '!', by the
>way?  If we do, how does a user look for a tag whose name is "!xyzzy"?
>"Naming your tag !xyzzy used to be allowed but it is now forbidden after
>this patch" is not an acceptable answer---it is called a regression.  If
>the negation operator were "^" or something that we explicitly forbid from
>a refname, we wouldn't have such a problem.
Cool, as I recall, v7 or earlier /bin/sh also used "^" to preface
exclusion patterns. Another option is the bash extglob syntax of
!(pattern) although I'd prefer "^" b/c one wouldn't have to quote it
with bash:
  $ git branch --list ^pu
-- 
TomG
Previous: Junio C HamanoNext: Tom Grennan
Message 33 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.