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

Re: [PATCHv3 5/5] branch: allow pattern arguments

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Sep 6, 2011, 14:21 UTC
Message-ID
<4E662C6F.7000205@drmicha.warpmail.net>
In-Reply-To
<4E661BDE.1080204@elegosoft.com>
Michael Schubert venit, vidit, dixit 06.09.2011 15:10:
Show 14 quoted lines
> On 08/28/2011 04:54 PM, Michael J Gruber wrote:
>> +static int match_patterns(const char **pattern, const char *refname)
>> +{
>> +	if (!*pattern)
>> +		return 1; /* no pattern always matches */
>> +	while (*pattern) {
>> +		if (!fnmatch(*pattern, refname, 0))
>> +			return 1;
>> +		pattern++;
>> +	}
>> +	return 0;
>> +}
> 
> Nitpick: maybe builtin/branch.c and builtin/tag.c could share match_pattern().?

I think all commands which list refs should share code - for-each-ref, branch, tag, replace. I suggest to unify log and for-each-ref-formats first, the unify ref listers.

Show 23 quoted lines
> A second thought: the printed "remotes/" prefix could be confusing for users,
> since it seems to be part of the refname. For example:
> 
> $ git branch -a
> * master
>   maint
>   man
>   remotes/origin/master
>   remotes/origin/maint
>   remotes/origin/man
> 
> $ git branch -a --list remotes/origin*
> [no output]
> 
> but
> 
> $ git branch -a --list origin*
>   remotes/origin/master
>   remotes/origin/maint
>   remotes/origin/man
> 
> (Sorry in case I missed that) What's the reason you decided --list to show local
> branches only? Maybe --list could show all refnames without any extra prefix.?

I didn't decide anything here. "git branch" lists all local branches and has been doing that forever, and "--list" is and should be a noop without a pattern. That was the idea: -r/-a select refnames, --list/-v/-vv activate the list mode(s), and the pattern is matched against the selected refs.

(This is one reason why I didn't want it to be named --glob - the pattern is a filter, not a selector.)

That being said, I find the fact that "-a --list remotes/origin/*" does not match anything somewhat disconcerting, although it fits in with the general idea of "git branch": it deals with branch names, not ref names. Have you ever tried to delete a remote branch?

git branch -r -d origin/maint # workee git branch -r -d remotes/origin/maint # no workee

Without -r, it doesn't work either.

So, the way it is it fits in with how "git branch" works, and is different from for-each-ref (and rev-list --glob). I don't like it, because you may have a local branch origin/maint (i.e. refs/heads/origin/maint) which you can't distinguish from the remote branch by a pattern, only by using or not using -r. But it's the same as with "git branch -d", really.

Michael
Previous: Michael SchubertNext: Sverre Rabbelier
Message 30 of 77 in “[RFC] branch: list branches by single remote”
  1. Michael SchubertAug 2, 2011
  2. Jeff KingAug 4, 2011
  3. Michael J GruberAug 16, 2011
  4. Michael SchubertAug 16, 2011
  5. Jeff KingAug 16, 2011
  6. Michael SchubertAug 24, 2011
  7. Michael J GruberAug 24, 2011
  8. Michael SchubertAug 24, 2011
  9. Junio C HamanoAug 24, 2011
  10. Thiago FarinaAug 25, 2011
  11. Junio C HamanoAug 25, 2011
  12. Michael J GruberAug 25, 2011
  13. 0/5 RFC: patterns for branch listMichael J Gruber, Aug 25, 2011
  14. Jeff KingAug 25, 2011
  15. Michael J GruberAug 26, 2011
  16. Junio C HamanoAug 26, 2011
  17. Jeff KingSep 7, 2011
  18. Michael J GruberSep 8, 2011
  19. 0/5 patterns for branch listMichael J Gruber, Aug 26, 2011
  20. 0/5 patterns for branch listMichael J Gruber, Aug 28, 2011
  21. 1/5 t6040: test branch -vvMichael J Gruber, Aug 28, 2011
  22. 2/5 git-tag: introduce long forms for the optionsMichael J Gruber, Aug 28, 2011
  23. 3/5 git-branch: introduce missing long forms for the optionsMichael J Gruber, Aug 28, 2011
  24. 4/5 branch: introduce --list optionMichael J Gruber, Aug 28, 2011
  25. Junio C HamanoAug 29, 2011
  26. Michael J GruberAug 29, 2011
  27. Junio C HamanoAug 29, 2011
  28. 5/5 branch: allow pattern argumentsMichael J Gruber, Aug 28, 2011
  29. Michael SchubertSep 6, 2011
  30. Michael J GruberSep 6, 2011
  31. Sverre RabbelierSep 6, 2011
  32. Michael J GruberSep 6, 2011
  33. 1/5 t6040: test branch -vvMichael J Gruber, Aug 26, 2011
  34. 2/5 git-tag: introduce long forms for the optionsMichael J Gruber, Aug 26, 2011
  35. Junio C HamanoAug 26, 2011
  36. Michael J GruberAug 28, 2011
  37. 3/5 git-branch: introduce missing long forms for the optionsMichael J Gruber, Aug 26, 2011
  38. Junio C HamanoAug 26, 2011
  39. Michael J GruberAug 28, 2011
  40. 4/5 branch: introduce --list optionMichael J Gruber, Aug 26, 2011
  41. Junio C HamanoAug 26, 2011
  42. Michael J GruberAug 28, 2011
  43. Jeff KingSep 7, 2011
  44. Michael J GruberSep 8, 2011
  45. 0/5 mg/branch-list amendmentMichael J Gruber, Sep 8, 2011
  46. 4/5 branch: introduce --list optionMichael J Gruber, Sep 8, 2011
  47. 5/5 branch: allow pattern argumentsMichael J Gruber, Sep 8, 2011
  48. Junio C HamanoSep 8, 2011
  49. Jeff KingSep 8, 2011
  50. Junio C HamanoSep 8, 2011
  51. Jeff KingSep 9, 2011
  52. Michael J GruberSep 9, 2011
  53. Junio C HamanoSep 9, 2011
  54. Michael J GruberSep 9, 2011
  55. Jeff KingSep 9, 2011
  56. t3200: test branch creation with -vMichael J Gruber, Sep 9, 2011
  57. Jeff KingSep 9, 2011
  58. Jeff KingSep 9, 2011
  59. Michael J GruberSep 10, 2011
  60. Jeff KingSep 13, 2011
  61. Michael J GruberSep 13, 2011
  62. t3200: clean up checks for file existenceJeff King, Sep 13, 2011
  63. Junio C HamanoSep 13, 2011
  64. Jeff KingSep 13, 2011
  65. 5/5 branch: allow pattern argumentsMichael J Gruber, Aug 26, 2011
  66. Junio C HamanoAug 26, 2011
  67. 1/5 branch: allow pattern argumentsMichael J Gruber, Aug 25, 2011
  68. Jeff KingAug 25, 2011
  69. Junio C HamanoAug 25, 2011
  70. Junio C HamanoAug 25, 2011
  71. 2/5 branch: introduce --list argumentMichael J Gruber, Aug 25, 2011
  72. Junio C HamanoAug 25, 2011
  73. Junio C HamanoAug 25, 2011
  74. 3/5 t6040; test branch -vvMichael J Gruber, Aug 25, 2011
  75. 4/5 branch: restructure -v vs. -vvMichael J Gruber, Aug 25, 2011
  76. Junio C HamanoAug 25, 2011
  77. 5/5 branch: give patchsame count with -vvvMichael J Gruber, Aug 25, 2011

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.