aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/git-config.txt
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-03-15 15:26:40 -0700
committerJunio C Hamano <gitster@pobox.com>2024-03-15 16:07:39 -0700
commit31399a6b6166cf76cc533bc9915878211607ed80 (patch)
tree25d8d683a1ccb0957f27f80889f0ffc8b8c65d82 /Documentation/git-config.txt
parentfbad334db9cff30cdf1fe3d498dec737bfae38df (diff)
downloadgit-31399a6b6166cf76cc533bc9915878211607ed80.tar.gz
config: allow tweaking whitespace between value and comment
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 <gitster@pobox.com>
Diffstat (limited to 'Documentation/git-config.txt')
-rw-r--r--Documentation/git-config.txt12
1 files changed, 9 insertions, 3 deletions
diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt
index af374ee2e0..e4f2e07926 100644
--- a/Documentation/git-config.txt
+++ b/Documentation/git-config.txt
@@ -89,9 +89,15 @@ OPTIONS
--comment <message>::
Append a comment at the end of new or modified lines.
- Unless _<message>_ begins with "#", a string "# " (hash
- followed by a space) is prepended to it. The _<message>_ must not
- contain linefeed characters (no multi-line comments are permitted).
+
+ If _<message>_ begins with one or more whitespaces followed
+ by "#", it is used as-is. If it begins with "#", a space is
+ prepended before it is used. Otherwise, a string " # " (a
+ space followed by a hash followed by a space) is prepended
+ to it. And the resulting string is placed immediately after
+ the value defined for the variable. The _<message>_ must
+ not contain linefeed characters (no multi-line comments are
+ permitted).
--get::
Get the value for a given key (optionally filtered by a regex