config: add --comment option to add a comment
Introduce the ability to append comments to modifications
made using git-config. Example usage:
git config --comment "changed via script" \
--add safe.directory /home/alice/repo.git
based on the proposed patch, the output produced is:
[safe]
directory = /home/alice/repo.git #changed via script
Users need to be able to distinguish between config entries made
using automation and entries made by a human. Automation can add
comments containing a URL pointing to explanations for the change
made, avoiding questions from users as to why their config file
was changed by a third party.
The implementation ensures that a # character is unconditionally
prepended to the provided comment string, and that the comment
text is appended as a suffix to the changed key-value-pair in the
same line of text. Multi-line comments (i.e. comments containing
linefeed) are rejected as errors, causing Git to exit without
making changes.
Comments are aimed at humans who inspect or change their Git
config using a pager or editor. Comments are not meant to be
read or displayed by git-config at a later time.
Signed-off-by: Ralph Seichter <github@seichter.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
4f9b731bde
commit
42d5c03394
@ -1283,7 +1283,7 @@ static void sync_submodule(const char *path, const char *prefix,
|
||||
submodule_to_gitdir(&sb, path);
|
||||
strbuf_addstr(&sb, "/config");
|
||||
|
||||
if (git_config_set_in_file_gently(sb.buf, remote_key, sub_origin_url))
|
||||
if (git_config_set_in_file_gently(sb.buf, remote_key, NULL, sub_origin_url))
|
||||
die(_("failed to update remote for submodule '%s'"),
|
||||
path);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user