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

Re: Unresolved issues #2

From
Junio C Hamano <junkio@cox.net>
Date
May 7, 2006, 09:39 UTC
Message-ID
<7vy7xekwbs.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.63.0605062332420.6423@wbgn013.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> It was done because the very syntax of the config suggests it be a 
> user-editable file. I do not want to mess with the comments more than 
> necessary.

I personally feel that is a lost cause _unless_ you come up with a reasonable convention for where to put comments, stress that rule to the user in the documentation, _and_ make repo-config to follow that rule as well.

We _do_ want to treat config file as hand editable and cat reviewable file, not an unreadable gunk like xml, so trying to preserve user comments is important and I am not opposed to that you did (at least some of) it. But as the code currently stands, what it does is at best half baked, at worst somewhat confusing.

A demonstration.  What is wrong with this picture?
        $ cat .git/config
        [core]
                repositoryformatversion = 0
                ; are the mode bits trustworthy?
                filemode = true ; yes, on ext3 
                ; We want symlinked HEAD because we will bisect
                ; recent kernel history.
                prefersymlinkrefs = true
        $ git repo-config core.prefersymlinkrefs false
        $ git repo-config core.filemode false
        $ cat .git/config
        [core]
                repositoryformatversion = 0
                ; are the mode bits trustworthy?
                filemode = false
                ; We want symlinked HEAD because we will bisect
                ; recent kernel history.
                prefersymlinkrefs = false
	$ exit

The comment given to "filemode" is "reasonable" in that it describes what the value that is set to the variable does, and losing the original comment given to its "true" when we set it to false is better than keeping it, so that part happens to be doing the right thing -- only because I knew what repo-config would do to the comments and arranged original comments in the file that way.

But what about prefersymlinkrefs one? When setting the variable to such a non-standard value, it is unreasonable for people to want to justify why with a comment like the above. But after resetting the value the comment becomes stale.

It gets worse:
        $ git repo-config --unset core.filemode
        $ cat .git/config
        [core]
                repositoryformatversion = 0
                ; please please use symlinks please
                prefersymlinkrefs = false
                ; are the mode bits trustworthy?
	$ exit

There now is a confusing trailing comment left that does not comment anything. Removing core.filemode is not so common, but this can happen whenever you remove any variable, so we can use any other variable as an example.

Now, enough being negative and pointing out problems. Time to become constructive. Probably a reasonable convention would be to define the config file format to be something like this:

        <comment that applies to the section>
        [section]
                <comment that applies to the variable stands on
		 its own before the variable>
                variable [= value] <comment that applies to the
        			    fact the variable is set to
                                    this particular value starts
				    on the same line as the
                                    "variable = value" thing>
 - when a variable is reset to another value, remove the
   "value comment";
 - when a variable disappears, remove "variable comment";
 - when a section disappears, remove "section comment";
 - otherwise leave the comment intact.

Then we could tell the user the rule is like above, and tell them to structure the file with comments that way, if they ever want to edit the file by hand.

Now if we wanted to do something like the above, I suspect that it would be easier and less error prone to first scan the config file, note what appears where, and do the processing in-core, and then write the results out, perhaps using data structures like these:

        struct config_section {
            char *pre_comment;
            char *name; /* e.g. "core" */
            struct config_section *next; /* next section */
            struct config_var *vars; /* pointer to the first one */
        };
        struct config_var {
            char *pre_comment;
            char *name;
            char *value; /* "existence" bool may have NULL,
                          * otherwise probably a string "= value"
                          */
            char *value_comment;
            struct config_var *next; /* pointer to the next one
                                      * in the section
                                      */
        };

Obviously, data structures like these would make it even easier if we decide we do _not_ care about comments (we would just lose x_comment fields, parse the thing and write the resulting list out).

Previous: Linus TorvaldsNext: Junio C Hamano
Message 73 of 81 in “Recent unresolved issues”
  1. Junio C HamanoApr 14, 2006
  2. Petr BaudisApr 14, 2006
  3. seanApr 14, 2006
  4. Petr BaudisApr 14, 2006
  5. Carl WorthApr 14, 2006
  6. Johannes SchindelinApr 15, 2006
  7. Junio C HamanoApr 15, 2006
  8. Junio C HamanoApr 15, 2006
  9. Linus TorvaldsApr 14, 2006
  10. Linus TorvaldsApr 15, 2006
  11. Linus TorvaldsApr 15, 2006
  12. Junio C HamanoApr 15, 2006
  13. Linus TorvaldsApr 15, 2006
  14. Linus TorvaldsApr 15, 2006
  15. Linus TorvaldsApr 15, 2006
  16. Junio C HamanoApr 15, 2006
  17. Junio C HamanoApr 15, 2006
  18. Junio C HamanoApr 15, 2006
  19. Johannes SchindelinApr 15, 2006
  20. Linus TorvaldsApr 15, 2006
  21. Linus TorvaldsApr 15, 2006
  22. Junio C HamanoApr 16, 2006
  23. Junio C HamanoApr 15, 2006
  24. Linus TorvaldsApr 15, 2006
  25. Junio C HamanoApr 15, 2006
  26. Unresolved issues #2Junio C Hamano, May 4, 2006
  27. Jakub NarebskiMay 4, 2006
  28. Junio C HamanoMay 4, 2006
  29. Jakub NarebskiMay 4, 2006
  30. Petr BaudisMay 4, 2006
  31. Pavel RoskinMay 4, 2006
  32. Carl WorthMay 4, 2006
  33. Junio C HamanoMay 5, 2006
  34. Martin LanghoffMay 5, 2006
  35. Carl WorthMay 5, 2006
  36. Jakub NarebskiMay 5, 2006
  37. Linus TorvaldsMay 5, 2006
  38. Jakub NarebskiMay 5, 2006
  39. Linus TorvaldsMay 5, 2006
  40. Martin LanghoffMay 6, 2006
  41. Junio C HamanoMay 6, 2006
  42. Martin LanghoffMay 7, 2006
  43. Jeff KingMay 7, 2006
  44. Linus TorvaldsMay 7, 2006
  45. Theodore TsoMay 8, 2006
  46. Linus TorvaldsMay 8, 2006
  47. Theodore TsoMay 8, 2006
  48. Linus TorvaldsMay 8, 2006
  49. Theodore TsoMay 8, 2006
  50. Linus TorvaldsMay 8, 2006
  51. Jeff KingMay 8, 2006
  52. Linus TorvaldsMay 8, 2006
  53. Sergey VlasovMay 7, 2006
  54. Martin LanghoffMay 7, 2006
  55. Junio C HamanoMay 7, 2006
  56. Martin LanghoffMay 7, 2006
  57. Carl WorthMay 5, 2006
  58. Jakub NarebskiMay 7, 2006
  59. Junio C HamanoMay 8, 2006
  60. Jakub NarebskiMay 8, 2006
  61. Jakub NarebskiMay 8, 2006
  62. Daniel BarkalowMay 4, 2006
  63. Linus TorvaldsMay 4, 2006
  64. Junio C HamanoMay 6, 2006
  65. Linus TorvaldsMay 6, 2006
  66. seanMay 6, 2006
  67. Linus TorvaldsMay 6, 2006
  68. seanMay 6, 2006
  69. Linus TorvaldsMay 6, 2006
  70. Junio C HamanoMay 6, 2006
  71. Johannes SchindelinMay 6, 2006
  72. Linus TorvaldsMay 6, 2006
  73. Junio C HamanoMay 7, 2006
  74. Junio C HamanoMay 7, 2006
  75. Johannes SchindelinMay 7, 2006
  76. Jakub NarebskiMay 7, 2006
  77. Junio C HamanoMay 8, 2006
  78. Jakub NarebskiMay 7, 2006
  79. David WoodhouseMay 9, 2006
  80. Bertrand JacquinMay 9, 2006
  81. Nicolas PitreMay 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.