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

[PATCH 0/5] RFC: patterns for branch list

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Aug 25, 2011, 08:30 UTC
Message-ID
<cover.1314259226.git.git@drmicha.warpmail.net>
In-Reply-To
<4E5607E0.1050300@drmicha.warpmail.net>

This mini series is about introducing patterns to the list mode of 'git branch' much like the pattern for 'git tag -l'. There are several related things which are to be considered for the ui design:

git log =======

For "log" and friends, "--glob" is a means to specify revision arguments by matching refs. Note that we have

--branches[=<pattern>] matching in refs/heads --tags[=<pattern>] matching in refs/tags --glob=<glob-pattern> matching in refs/

git tag =======

For "tag", we have a pattern matching in refs/tags, but only in the list mode of "tag", which is invoked by "-l", or automatically when there are no arguments. There is no pattern related option, it's "always on" in list mode. I.e., in list mode it behaves much like

git log --no-walk --oneline --tags=

with a different format string, and an optional argument stuck at the end of the line. (git for-each-ref is another related interface, but plumbing, so I'll skip it here.)

git branch ==========

Analogous to "git tag", "branch" has several modes, one of which is list mode. It is currently activated (and possibly modified) by "-v" and "-vv", and when there are no arguments. So, at the least,

git branch -v[v] <pattern>

should match just like "git tag -l <pattern>" does. And that is what the first patch in my series does.

Then we need an option to invoke list mode. The natural candidate "-l" is taken by the badly named reflog option, which is why I suggested "--list" and moving the reflog option to "-g" over time.

I'm open to other suggestions as long as they keep and improve the consistency between "git tag" and "git branch". I never liked their different implicit modes/subcommands but have been around long enough to know that they are there to stay.

"git tag" should probably learn the same long option and others. And why not verify tags given by a pattern?

Both "tag" and "branch" could activate list mode automatically on an invalid tag name rather than dieing:

git tag v1.7.6\*
Warning: tag 'v1.7.6*' not found.
v1.7.6
v1.7.6-rc0
v1.7.6-rc1
v1.7.6-rc2
v1.7.6-rc3
v1.7.6.1

On the other hand, one might think about implementing both list modes (tag and branch) using the revision machinery and custom format strings, or for-each-ref; rather than both differently as it is now.

'-l' is the natural short option name for '--list'. This is taken for the rarely used or needed 'create reflog' option. I'd change the latter to '-g,--create-reflog' (cmp. log) and take '-l,--list' but know the reaction already.

-v[v] sanity ============

'-v' and '-vv' both take considerable time (because they need to walk). It makes more sense to have '-v' display cheap output (upstream name) and '-vv' add expensive output (ahead/behind info). '-vvv' could add super expensive info (ahead/equivalent/behind a la cherry-mark).

These are changes to current porcelain ui behaviour, so I deem this to be OK (too late for 1.7.7, of course). The option renaming needs a transition (not done in this series).

Michael J Gruber (5):
  branch: allow pattern arguments
  branch: introduce --list argument
  t6040; test branch -vv [independent, can go in as is testing current behaviour]
  branch: restructure -v vs. -vv
  branch: give patchsame count with -vvv
 Documentation/git-branch.txt |   20 +++++++++---
 builtin/branch.c             |   65 +++++++++++++++++++++++++----------------
 remote.c                     |   12 ++++++--
 remote.h                     |    2 +-
 t/t3203-branch-output.sh     |   24 +++++++++++++++
 t/t6040-tracking-info.sh     |   41 ++++++++++++++++++++++++--
 wt-status.c                  |    2 +-
 7 files changed, 127 insertions(+), 39 deletions(-)
-- 
1.7.6.845.gc3c05
Previous: Michael J GruberNext: Jeff King
Message 13 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.