<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/config.c, branch v2.45.0</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.45.0</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.45.0'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2024-04-15T21:11:44Z</updated>
<entry>
<title>Merge branch 'jc/unleak-core-excludesfile'</title>
<updated>2024-04-15T21:11:44Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-04-15T21:11:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b415f15b491e66da7eccbf896193808d5746988e'/>
<id>urn:sha1:b415f15b491e66da7eccbf896193808d5746988e</id>
<content type='text'>
The variable that holds the value read from the core.excludefile
configuration variable used to leak, which has been corrected.

* jc/unleak-core-excludesfile:
  config: do not leak excludes_file
</content>
</entry>
<entry>
<title>config: do not leak excludes_file</title>
<updated>2024-04-08T20:20:24Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-04-06T18:11:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0e0fefb29fde59b6703d3b45987823fe85c00706'/>
<id>urn:sha1:0e0fefb29fde59b6703d3b45987823fe85c00706</id>
<content type='text'>
The excludes_file variable is marked "const char *", but all the
assignments to it are made with a piece of memory allocated just
for it, and the variable is responsible for owning it.

When "core.excludesfile" is read, the code just lost the previous
value, leaking memory.  Plug it.

The real problem is that the variable is mistyped; our convention
is to never make a variable that owns the piece of memory pointed
by it as "const".  Fixing that would reduce the chance of this kind
of bug happening, and also would make it unnecessary to cast the
constness away while free()ing it, but that would be a much larger
follow-up effort.

Reported-by: Rubén Justo &lt;rjusto@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jk/core-comment-string'</title>
<updated>2024-04-05T17:49:49Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-04-05T17:49:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=dce1e0b6daaa872a3b88724d9aa1b087c95e8754'/>
<id>urn:sha1:dce1e0b6daaa872a3b88724d9aa1b087c95e8754</id>
<content type='text'>
core.commentChar used to be limited to a single byte, but has been
updated to allow an arbitrary multi-byte sequence.

* jk/core-comment-string:
  config: add core.commentString
  config: allow multi-byte core.commentChar
  environment: drop comment_line_char compatibility macro
  wt-status: drop custom comment-char stringification
  sequencer: handle multi-byte comment characters when writing todo list
  find multi-byte comment chars in unterminated buffers
  find multi-byte comment chars in NUL-terminated strings
  prefer comment_line_str to comment_line_char for printing
  strbuf: accept a comment string for strbuf_add_commented_lines()
  strbuf: accept a comment string for strbuf_commented_addf()
  strbuf: accept a comment string for strbuf_stripspace()
  environment: store comment_line_char as a string
  strbuf: avoid shadowing global comment_line_char name
  commit: refactor base-case of adjust_comment_line_char()
  strbuf: avoid static variables in strbuf_add_commented_lines()
  strbuf: simplify comment-handling in add_lines() helper
  config: forbid newline as core.commentChar
</content>
</entry>
<entry>
<title>Merge branch 'rs/config-comment'</title>
<updated>2024-04-05T17:49:49Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-04-05T17:49:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3256584c36f649abb2af58e7b190d3cf674ba56e'/>
<id>urn:sha1:3256584c36f649abb2af58e7b190d3cf674ba56e</id>
<content type='text'>
"git config" learned "--comment=&lt;message&gt;" option to leave a
comment immediately after the "variable = value" on the same line
in the configuration file.

* rs/config-comment:
  config: allow tweaking whitespace between value and comment
  config: fix --comment formatting
  config: add --comment option to add a comment
</content>
</entry>
<entry>
<title>Merge branch 'ds/config-internal-whitespace-fix'</title>
<updated>2024-04-01T20:21:34Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-04-01T20:21:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=521df686e5a5d445e03280f48df966b77e23f160'/>
<id>urn:sha1:521df686e5a5d445e03280f48df966b77e23f160</id>
<content type='text'>
"git config" corrupted literal HT characters written in the
configuration file as part of a value, which has been corrected.

* ds/config-internal-whitespace-fix:
  config.txt: describe handling of whitespace further
  t1300: add more tests for whitespace and inline comments
  config: really keep value-internal whitespace verbatim
  config: minor addition of whitespace
</content>
</entry>
<entry>
<title>config: add core.commentString</title>
<updated>2024-03-27T15:48:54Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2024-03-27T08:19:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9ccf3e9b22b6843892319b189fd7aed37c451420'/>
<id>urn:sha1:9ccf3e9b22b6843892319b189fd7aed37c451420</id>
<content type='text'>
The core.commentChar code recently learned to accept more than a
single ASCII character. But using it is annoying with multiple versions
of Git, since older ones will reject it outright:

    $ git.v2.44.0 -c core.commentchar=foo stripspace -s
    error: core.commentChar should only be one ASCII character
    fatal: unable to parse 'core.commentchar' from command-line config

Let's add an alias core.commentString. That's arguably a better name
anyway, since we now can handle strings, and it makes it possible to
have a config that works reasonably with both old and new versions of
Git (see the example in the documentation).

This is strictly an alias, so there's not much point in adding duplicate
tests; I added a single one to t0030 that exercises the alias code.

Note also that the error messages for invalid values will now show the
variable the config parser handed us, and thus will be normalized to
lowercase (rather than camelcase). A few tests in t0030 are adjusted to
match.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>config: really keep value-internal whitespace verbatim</title>
<updated>2024-03-21T22:57:09Z</updated>
<author>
<name>Dragan Simic</name>
<email>dsimic@manjaro.org</email>
</author>
<published>2024-03-21T06:06:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f0b894443040cb222fbd80d9661cfa7583a9164f'/>
<id>urn:sha1:f0b894443040cb222fbd80d9661cfa7583a9164f</id>
<content type='text'>
Fix a bug in function parse_value() that prevented whitespace characters
(i.e. spaces and horizontal tabs) found inside configuration option values
from being parsed and returned in their original form.  The bug caused any
number of consecutive whitespace characters to be wrongly "squashed" into
the same number of space characters.

This bug was introduced back in July 2009, in commit ebdaae372b46 ("config:
Keep inner whitespace verbatim").

Further investigation showed that setting a configuration value, by invoking
git-config(1), converts value-internal horizontal tabs into "\t" escape
sequences, which the buggy value-parsing logic in function parse_value()
didn't "squash" into spaces.  That's why the test included in the ebdaae37
commit passed, which presumably made the bug remain undetected for this long.
On the other hand, value-internal literal horizontal tab characters, found in
a configuration file edited by hand, do get "squashed" by the value-parsing
logic, so the right choice was to fix this bug by making the value-internal
whitespace characters preserved verbatim.

Signed-off-by: Dragan Simic &lt;dsimic@manjaro.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>config: minor addition of whitespace</title>
<updated>2024-03-21T22:57:09Z</updated>
<author>
<name>Dragan Simic</name>
<email>dsimic@manjaro.org</email>
</author>
<published>2024-03-21T06:06:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0d49b1e5a8c789dd3f1029f382bd76a464b72da0'/>
<id>urn:sha1:0d49b1e5a8c789dd3f1029f382bd76a464b72da0</id>
<content type='text'>
In general, binary operators should be enclosed in a pair of leading and
trailing space (SP) characters.  Thus, clean up one spotted expression that
for some reason had a "bunched up" operator.

Signed-off-by: Dragan Simic &lt;dsimic@manjaro.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>config: allow tweaking whitespace between value and comment</title>
<updated>2024-03-15T23:07:39Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-03-15T22:26:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=31399a6b6166cf76cc533bc9915878211607ed80'/>
<id>urn:sha1:31399a6b6166cf76cc533bc9915878211607ed80</id>
<content type='text'>
Extending the previous step, this allows the whitespace placed after
the value before the "# comment message" to be tweaked by tweaking
the preprocessing rule to:

 * If the given comment string begins with one or more whitespace
   characters followed by '#', it is passed intact.

 * If the given comment string begins with '#', a Space is
   prepended.

 * Otherwise, " # " (Space, '#', Space) is prefixed.

 * A string with LF in it cannot be used as a comment string.

Unlike the previous step, which unconditionally added a space after
the value before writing the "# comment string", because the above
preprocessing already gives a whitespace before the '#', the
resulting string is written immediately after copying the value.

And the sanity checking rule becomes

 * comment string after the above massaging that comes into
   git_config_set_multivar_in_file_gently() must

   - begin with zero or more whitespace characters followed by '#'.
   - not have a LF in it.

I personally think this is over-engineered, but since I thought
things through anyway, here it is in the patch form.  The logic to
tweak end-user supplied comment string is encapsulated in a new
helper function, git_config_prepare_comment_string(), so if new
front-end callers would want to use the same massaging rules, it is
easily reused.

Unfortunately I do not think of a way to tweak the preprocessing
rules further to optionally allow having no blank after the value,
i.e. to produce

	[section]
		variable = value#comment

(which is a valid way to say section.variable=value, by the way)
without sacrificing the ergonomics for the more usual case, so this
time I really stop here.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>config: fix --comment formatting</title>
<updated>2024-03-15T23:07:37Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-03-15T19:43:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=fbad334db9cff30cdf1fe3d498dec737bfae38df'/>
<id>urn:sha1:fbad334db9cff30cdf1fe3d498dec737bfae38df</id>
<content type='text'>
When git adds comments itself (like "rebase -i" todo list and
"commit -e" log message editor), it always gives a comment
introducer "#" followed by a Space before the message, except for
the recently introduced "git config --comment", where the users are
forced to say " this is my comment" if they want to add their
comment in this usual format; otherwise their comment string will
end up without a space after the "#".

Make it more ergonomic, while keeping it possible to also use this
unusual style, by massaging the comment string at the UI layer with
a set of simple rules:

 * If the given comment string begins with '#', it is passed intact.
 * Otherwise, "# " is prefixed.
 * A string with LF in it cannot be used as a comment string.

Right now there is only one "front-end" that accepts end-user
comment string and calls the underlying machinery to add or modify
configuration file with comments, but to make sure that the future
callers perform similar massaging as they see fit, add a sanity
check logic in git_config_set_multivar_in_file_gently(), which is
the single choke point in the codepaths that consumes the comment
string.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
