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

Re: Implementing branch attributes in git config

From
Junio C Hamano <junkio@cox.net>
Date
May 9, 2006, 05:31 UTC
Message-ID
<7vslnj933a.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.64.0605081828250.3718@g5.osdl.org>
Linus Torvalds <torvalds@osdl.org> writes:
Show 9 quoted lines
>> 	[branch]
>>         	name = linus
>>         	url = git://git.kernel.org/../torvalds/linux-2.6
>> 
>> 	[branch]
>>         	url = git://git.kernel.org/../jgarzik/libata-dev
>>         	name = libata
>
> Yes, that would be a silent and confusing error.

Although I haved raised objections, I actually started to like the idea of using multiple [branch] (or wasn't it [remote] given the example variables we have been using?) sections.

We should first depart from the Windoze .INI mindset. While I do not think users expect case insensisitivity, only because the section headers are marked with [brackets], if that syntax somehow makes people expect such, maybe we should stop using [bracket] as section markers.

Whatever marker we end up using, I'd suggest somewhat different approach.

 - Treat each part that are grouped under [bracketted-string]
   marker as a bag of variable=value pairs.  Loosely speaking,
   the bracketted-string defines a schema -- what kind of
   variables are expected to be there in that seciton.  For
   example, a section for things we traditionally had in remotes
   file would contain fields (variables) such as url, fetch, and
   push (we might add proxy to this list).  And we call this
   "bag of variable=value" a section.
 - There can be multiple sections in a config file that uses the
   same schema.  The example at the beginning of this message
   is perfectly valid.  It defines two sections of type
   [branch], each of which has two variables (name and url) in
   it.

Unlike your earlier suggestion, the second [branch] is not just for readability; it is mandatory, because we are talking about two different [branch]es (eh, that's [remote]s, really), it needs to be there to separate two instances.

The above would break the existing repo-config command, but let's forget about it for now. I think we are breaking forward/backward compatibility in any proposals brought up so far anyway.

We would need user interface level commands to
	add a new section
        delete a section

We would need a way to identify a secion, perhaps using a value of arbitrary key (e.g. "where name=blah"). Creating a section could be implicit, just like the current repo-config.

        add a variable=value to a section
        delete a variable=value from a section
	retrieve variables' values from a section
	list value of a variable from all sections of a kind.

Probably need to support the same variable name appearing more than once, just like the current multi-value support.

The current multi-value stuff assumes that multi-values are exceptions, and rare. While I do not necessarily agree with that, for now let's assume that is true.

Creating a new section with given variables:
	$ cfg --set section var value var value ...
   (eg) $ cfg --set branch name master merge origin pull linus
    Here, 'var' and 'value' are case sensitive; if they have
    syntactical metacharacters (WS, =, quotes, etc), they need
    to be quoted when cfg command writes to the file (i.e. the
    user do not have to quote more than necessary to protect
    them from the shell).
Updating an existing section's variables, or create a new one:
	$ cfg --replace section.var value where var0 = val0
   (eg) $ cfg --replace remote.url git://... where name = linus
    Look for a "remote" section that has a variable "name" with
    value "linus" in it, and replace its "url" variable with
    "git://...".  If there is no "remote" section with such a
    name, create it.  For the key matching syntax, I do not
    insist on using "where" (I merely used it for continuity
    from the previous discussion).  For the comparison operator,
    in addition to the '=' shown above, we would probably want
    to have regexp match (perhaps ':' to emulate "expr") as well.
Retrieving a variable:
	$ cfg --get section.var [where var0 = val0]
   (eg) $ cfg --get remote.url where name = linus
List sections:
	$ cfg --list section.var
   (eg) $ cfg --list remote.name
So, an equivalent of "grep -H URL: .git/remotes/*" becomes something like:
	for name in `cfg --list remote.name`
        do
             	url=`cfg --get remote.url where name = "$name"`
                echo "$name: URL: $url"
	done
Previous: Linus TorvaldsNext: Linus Torvalds
Message 37 of 75 in “Implementing branch attributes in git config”
  1. Pavel RoskinMay 7, 2006
  2. Junio C HamanoMay 7, 2006
  3. Johannes SchindelinMay 8, 2006
  4. Linus TorvaldsMay 8, 2006
  5. Linus TorvaldsMay 8, 2006
  6. Linus TorvaldsMay 8, 2006
  7. Johannes SchindelinMay 8, 2006
  8. Pavel RoskinMay 8, 2006
  9. Johannes SchindelinMay 8, 2006
  10. Pavel RoskinMay 8, 2006
  11. Junio C HamanoMay 8, 2006
  12. Johannes SchindelinMay 8, 2006
  13. Pavel RoskinMay 8, 2006
  14. seanMay 8, 2006
  15. Linus TorvaldsMay 8, 2006
  16. Pavel RoskinMay 8, 2006
  17. seanMay 8, 2006
  18. Pavel RoskinMay 8, 2006
  19. Linus TorvaldsMay 8, 2006
  20. Junio C HamanoMay 8, 2006
  21. seanMay 8, 2006
  22. Johannes SchindelinMay 8, 2006
  23. seanMay 8, 2006
  24. Junio C HamanoMay 8, 2006
  25. seanMay 8, 2006
  26. Daniel BarkalowMay 8, 2006
  27. seanMay 8, 2006
  28. Johannes SchindelinMay 8, 2006
  29. seanMay 9, 2006
  30. Johannes SchindelinMay 9, 2006
  31. Linus TorvaldsMay 9, 2006
  32. seanMay 9, 2006
  33. Junio C HamanoMay 9, 2006
  34. Linus TorvaldsMay 9, 2006
  35. Junio C HamanoMay 9, 2006
  36. Linus TorvaldsMay 9, 2006
  37. Junio C HamanoMay 9, 2006
  38. Linus TorvaldsMay 9, 2006
  39. seanMay 9, 2006
  40. Linus TorvaldsMay 9, 2006
  41. seanMay 9, 2006
  42. Linus TorvaldsMay 9, 2006
  43. Jakub NarebskiMay 9, 2006
  44. Johannes SchindelinMay 9, 2006
  45. Linus TorvaldsMay 9, 2006
  46. Junio C HamanoMay 9, 2006
  47. Linus TorvaldsMay 9, 2006
  48. seanMay 9, 2006
  49. seanMay 9, 2006
  50. Junio C HamanoMay 9, 2006
  51. seanMay 9, 2006
  52. Linus TorvaldsMay 10, 2006
  53. seanMay 10, 2006
  54. Linus TorvaldsMay 10, 2006
  55. Martin LanghoffMay 10, 2006
  56. Johannes SchindelinMay 10, 2006
  57. Linus TorvaldsMay 10, 2006
  58. Jakub NarebskiMay 10, 2006
  59. Martin LanghoffMay 10, 2006
  60. Linus TorvaldsMay 10, 2006
  61. Linus TorvaldsMay 11, 2006
  62. Jeff KingMay 11, 2006
  63. Jeff KingMay 11, 2006
  64. Martin LanghoffMay 11, 2006
  65. Johannes SchindelinMay 11, 2006
  66. Nicolas PitreMay 11, 2006
  67. Jakub NarebskiMay 11, 2006
  68. seanMay 10, 2006
  69. Junio C HamanoMay 11, 2006
  70. Martin WaitzMay 9, 2006
  71. Johannes SchindelinMay 9, 2006
  72. Johannes SchindelinMay 8, 2006
  73. Pavel RoskinMay 9, 2006
  74. seanMay 9, 2006
  75. Pavel RoskinMay 9, 2006

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.