Merge branch 'rs/config-comment'
"git config" learned "--comment=<message>" 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 commentmaint
commit
3256584c36
|
@ -9,9 +9,9 @@ git-config - Get and set repository or global options
|
|||
SYNOPSIS
|
||||
--------
|
||||
[verse]
|
||||
'git config' [<file-option>] [--type=<type>] [--fixed-value] [--show-origin] [--show-scope] [-z|--null] <name> [<value> [<value-pattern>]]
|
||||
'git config' [<file-option>] [--type=<type>] --add <name> <value>
|
||||
'git config' [<file-option>] [--type=<type>] [--fixed-value] --replace-all <name> <value> [<value-pattern>]
|
||||
'git config' [<file-option>] [--type=<type>] [--comment=<message>] [--fixed-value] [--show-origin] [--show-scope] [-z|--null] <name> [<value> [<value-pattern>]]
|
||||
'git config' [<file-option>] [--type=<type>] [--comment=<message>] --add <name> <value>
|
||||
'git config' [<file-option>] [--type=<type>] [--comment=<message>] [--fixed-value] --replace-all <name> <value> [<value-pattern>]
|
||||
'git config' [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] [--fixed-value] --get <name> [<value-pattern>]
|
||||
'git config' [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] [--fixed-value] --get-all <name> [<value-pattern>]
|
||||
'git config' [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] [--fixed-value] [--name-only] --get-regexp <name-regex> [<value-pattern>]
|
||||
|
@ -87,6 +87,18 @@ OPTIONS
|
|||
values. This is the same as providing '^$' as the `value-pattern`
|
||||
in `--replace-all`.
|
||||
|
||||
--comment <message>::
|
||||
Append a comment at the end of new or modified lines.
|
||||
|
||||
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
|
||||
matching the value). Returns error code 1 if the key was not
|
||||
|
|
|
@ -44,6 +44,7 @@ static struct config_options config_options;
|
|||
static int show_origin;
|
||||
static int show_scope;
|
||||
static int fixed_value;
|
||||
static const char *comment;
|
||||
|
||||
#define ACTION_GET (1<<0)
|
||||
#define ACTION_GET_ALL (1<<1)
|
||||
|
@ -173,6 +174,7 @@ static struct option builtin_config_options[] = {
|
|||
OPT_BOOL(0, "show-origin", &show_origin, N_("show origin of config (file, standard input, blob, command line)")),
|
||||
OPT_BOOL(0, "show-scope", &show_scope, N_("show scope of config (worktree, local, global, system, command)")),
|
||||
OPT_STRING(0, "default", &default_value, N_("value"), N_("with --get, use default value when missing entry")),
|
||||
OPT_STRING(0, "comment", &comment, N_("value"), N_("human-readable comment string (# will be prepended as needed)")),
|
||||
OPT_END(),
|
||||
};
|
||||
|
||||
|
@ -797,6 +799,12 @@ int cmd_config(int argc, const char **argv, const char *prefix)
|
|||
usage_builtin_config();
|
||||
}
|
||||
|
||||
if (comment &&
|
||||
!(actions & (ACTION_ADD|ACTION_SET|ACTION_SET_ALL|ACTION_REPLACE_ALL))) {
|
||||
error(_("--comment is only applicable to add/set/replace operations"));
|
||||
usage_builtin_config();
|
||||
}
|
||||
|
||||
/* check usage of --fixed-value */
|
||||
if (fixed_value) {
|
||||
int allowed_usage = 0;
|
||||
|
@ -833,6 +841,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)
|
|||
flags |= CONFIG_FLAGS_FIXED_VALUE;
|
||||
}
|
||||
|
||||
comment = git_config_prepare_comment_string(comment);
|
||||
|
||||
if (actions & PAGING_ACTIONS)
|
||||
setup_auto_pager("config", 1);
|
||||
|
||||
|
@ -880,7 +890,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
|
|||
check_write();
|
||||
check_argc(argc, 2, 2);
|
||||
value = normalize_value(argv[0], argv[1], &default_kvi);
|
||||
ret = git_config_set_in_file_gently(given_config_source.file, argv[0], value);
|
||||
ret = git_config_set_in_file_gently(given_config_source.file, argv[0], comment, value);
|
||||
if (ret == CONFIG_NOTHING_SET)
|
||||
error(_("cannot overwrite multiple values with a single value\n"
|
||||
" Use a regexp, --add or --replace-all to change %s."), argv[0]);
|
||||
|
@ -891,7 +901,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
|
|||
value = normalize_value(argv[0], argv[1], &default_kvi);
|
||||
ret = git_config_set_multivar_in_file_gently(given_config_source.file,
|
||||
argv[0], value, argv[2],
|
||||
flags);
|
||||
comment, flags);
|
||||
}
|
||||
else if (actions == ACTION_ADD) {
|
||||
check_write();
|
||||
|
@ -900,7 +910,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
|
|||
ret = git_config_set_multivar_in_file_gently(given_config_source.file,
|
||||
argv[0], value,
|
||||
CONFIG_REGEX_NONE,
|
||||
flags);
|
||||
comment, flags);
|
||||
}
|
||||
else if (actions == ACTION_REPLACE_ALL) {
|
||||
check_write();
|
||||
|
@ -908,7 +918,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
|
|||
value = normalize_value(argv[0], argv[1], &default_kvi);
|
||||
ret = git_config_set_multivar_in_file_gently(given_config_source.file,
|
||||
argv[0], value, argv[2],
|
||||
flags | CONFIG_FLAGS_MULTI_REPLACE);
|
||||
comment, flags | CONFIG_FLAGS_MULTI_REPLACE);
|
||||
}
|
||||
else if (actions == ACTION_GET) {
|
||||
check_argc(argc, 1, 2);
|
||||
|
@ -936,17 +946,17 @@ int cmd_config(int argc, const char **argv, const char *prefix)
|
|||
if (argc == 2)
|
||||
return git_config_set_multivar_in_file_gently(given_config_source.file,
|
||||
argv[0], NULL, argv[1],
|
||||
flags);
|
||||
NULL, flags);
|
||||
else
|
||||
return git_config_set_in_file_gently(given_config_source.file,
|
||||
argv[0], NULL);
|
||||
argv[0], NULL, NULL);
|
||||
}
|
||||
else if (actions == ACTION_UNSET_ALL) {
|
||||
check_write();
|
||||
check_argc(argc, 1, 2);
|
||||
return git_config_set_multivar_in_file_gently(given_config_source.file,
|
||||
argv[0], NULL, argv[1],
|
||||
flags | CONFIG_FLAGS_MULTI_REPLACE);
|
||||
NULL, flags | CONFIG_FLAGS_MULTI_REPLACE);
|
||||
}
|
||||
else if (actions == ACTION_RENAME_SECTION) {
|
||||
check_write();
|
||||
|
|
|
@ -1553,7 +1553,7 @@ static int maintenance_register(int argc, const char **argv, const char *prefix)
|
|||
die(_("$HOME not set"));
|
||||
rc = git_config_set_multivar_in_file_gently(
|
||||
config_file, "maintenance.repo", maintpath,
|
||||
CONFIG_REGEX_NONE, 0);
|
||||
CONFIG_REGEX_NONE, NULL, 0);
|
||||
free(global_config_file);
|
||||
|
||||
if (rc)
|
||||
|
@ -1620,7 +1620,7 @@ static int maintenance_unregister(int argc, const char **argv, const char *prefi
|
|||
if (!config_file)
|
||||
die(_("$HOME not set"));
|
||||
rc = git_config_set_multivar_in_file_gently(
|
||||
config_file, key, NULL, maintpath,
|
||||
config_file, key, NULL, maintpath, NULL,
|
||||
CONFIG_FLAGS_MULTI_REPLACE | CONFIG_FLAGS_FIXED_VALUE);
|
||||
free(global_config_file);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -365,12 +365,12 @@ static void copy_filtered_worktree_config(const char *worktree_git_dir)
|
|||
if (!git_configset_get_bool(&cs, "core.bare", &bare) &&
|
||||
bare &&
|
||||
git_config_set_multivar_in_file_gently(
|
||||
to_file, "core.bare", NULL, "true", 0))
|
||||
to_file, "core.bare", NULL, "true", NULL, 0))
|
||||
error(_("failed to unset '%s' in '%s'"),
|
||||
"core.bare", to_file);
|
||||
if (!git_configset_get(&cs, "core.worktree") &&
|
||||
git_config_set_in_file_gently(to_file,
|
||||
"core.worktree", NULL))
|
||||
"core.worktree", NULL, NULL))
|
||||
error(_("failed to unset '%s' in '%s'"),
|
||||
"core.worktree", to_file);
|
||||
|
||||
|
|
80
config.c
80
config.c
|
@ -3006,6 +3006,7 @@ static ssize_t write_section(int fd, const char *key,
|
|||
}
|
||||
|
||||
static ssize_t write_pair(int fd, const char *key, const char *value,
|
||||
const char *comment,
|
||||
const struct config_store_data *store)
|
||||
{
|
||||
int i;
|
||||
|
@ -3046,7 +3047,11 @@ static ssize_t write_pair(int fd, const char *key, const char *value,
|
|||
strbuf_addch(&sb, value[i]);
|
||||
break;
|
||||
}
|
||||
strbuf_addf(&sb, "%s\n", quote);
|
||||
|
||||
if (comment)
|
||||
strbuf_addf(&sb, "%s%s\n", quote, comment);
|
||||
else
|
||||
strbuf_addf(&sb, "%s\n", quote);
|
||||
|
||||
ret = write_in_full(fd, sb.buf, sb.len);
|
||||
strbuf_release(&sb);
|
||||
|
@ -3135,9 +3140,9 @@ static void maybe_remove_section(struct config_store_data *store,
|
|||
}
|
||||
|
||||
int git_config_set_in_file_gently(const char *config_filename,
|
||||
const char *key, const char *value)
|
||||
const char *key, const char *comment, const char *value)
|
||||
{
|
||||
return git_config_set_multivar_in_file_gently(config_filename, key, value, NULL, 0);
|
||||
return git_config_set_multivar_in_file_gently(config_filename, key, value, NULL, comment, 0);
|
||||
}
|
||||
|
||||
void git_config_set_in_file(const char *config_filename,
|
||||
|
@ -3158,7 +3163,7 @@ int repo_config_set_worktree_gently(struct repository *r,
|
|||
if (r->repository_format_worktree_config) {
|
||||
char *file = repo_git_path(r, "config.worktree");
|
||||
int ret = git_config_set_multivar_in_file_gently(
|
||||
file, key, value, NULL, 0);
|
||||
file, key, value, NULL, NULL, 0);
|
||||
free(file);
|
||||
return ret;
|
||||
}
|
||||
|
@ -3172,6 +3177,62 @@ void git_config_set(const char *key, const char *value)
|
|||
trace2_cmd_set_config(key, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* The ownership rule is that the caller will own the string
|
||||
* if it receives a piece of memory different from what it passed
|
||||
* as the parameter.
|
||||
*/
|
||||
const char *git_config_prepare_comment_string(const char *comment)
|
||||
{
|
||||
size_t leading_blanks;
|
||||
|
||||
if (!comment)
|
||||
return NULL;
|
||||
|
||||
if (strchr(comment, '\n'))
|
||||
die(_("no multi-line comment allowed: '%s'"), comment);
|
||||
|
||||
/*
|
||||
* If it begins with one or more leading whitespace characters
|
||||
* followed by '#", the comment string is used as-is.
|
||||
*
|
||||
* If it begins with '#', a SP is inserted between the comment
|
||||
* and the value the comment is about.
|
||||
*
|
||||
* Otherwise, the value is followed by a SP followed by '#'
|
||||
* followed by SP and then the comment string comes.
|
||||
*/
|
||||
|
||||
leading_blanks = strspn(comment, " \t");
|
||||
if (leading_blanks && comment[leading_blanks] == '#')
|
||||
; /* use it as-is */
|
||||
else if (comment[0] == '#')
|
||||
comment = xstrfmt(" %s", comment);
|
||||
else
|
||||
comment = xstrfmt(" # %s", comment);
|
||||
|
||||
return comment;
|
||||
}
|
||||
|
||||
static void validate_comment_string(const char *comment)
|
||||
{
|
||||
size_t leading_blanks;
|
||||
|
||||
if (!comment)
|
||||
return;
|
||||
/*
|
||||
* The front-end must have massaged the comment string
|
||||
* properly before calling us.
|
||||
*/
|
||||
if (strchr(comment, '\n'))
|
||||
BUG("multi-line comments are not permitted: '%s'", comment);
|
||||
|
||||
leading_blanks = strspn(comment, " \t");
|
||||
if (!leading_blanks || comment[leading_blanks] != '#')
|
||||
BUG("comment must begin with one or more SP followed by '#': '%s'",
|
||||
comment);
|
||||
}
|
||||
|
||||
/*
|
||||
* If value==NULL, unset in (remove from) config,
|
||||
* if value_pattern!=NULL, disregard key/value pairs where value does not match.
|
||||
|
@ -3200,6 +3261,7 @@ void git_config_set(const char *key, const char *value)
|
|||
int git_config_set_multivar_in_file_gently(const char *config_filename,
|
||||
const char *key, const char *value,
|
||||
const char *value_pattern,
|
||||
const char *comment,
|
||||
unsigned flags)
|
||||
{
|
||||
int fd = -1, in_fd = -1;
|
||||
|
@ -3210,6 +3272,8 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
|
|||
size_t contents_sz;
|
||||
struct config_store_data store = CONFIG_STORE_INIT;
|
||||
|
||||
validate_comment_string(comment);
|
||||
|
||||
/* parse-key returns negative; flip the sign to feed exit(3) */
|
||||
ret = 0 - git_config_parse_key(key, &store.key, &store.baselen);
|
||||
if (ret)
|
||||
|
@ -3250,7 +3314,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
|
|||
free(store.key);
|
||||
store.key = xstrdup(key);
|
||||
if (write_section(fd, key, &store) < 0 ||
|
||||
write_pair(fd, key, value, &store) < 0)
|
||||
write_pair(fd, key, value, comment, &store) < 0)
|
||||
goto write_err_out;
|
||||
} else {
|
||||
struct stat st;
|
||||
|
@ -3404,7 +3468,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
|
|||
if (write_section(fd, key, &store) < 0)
|
||||
goto write_err_out;
|
||||
}
|
||||
if (write_pair(fd, key, value, &store) < 0)
|
||||
if (write_pair(fd, key, value, comment, &store) < 0)
|
||||
goto write_err_out;
|
||||
}
|
||||
|
||||
|
@ -3449,7 +3513,7 @@ void git_config_set_multivar_in_file(const char *config_filename,
|
|||
const char *value_pattern, unsigned flags)
|
||||
{
|
||||
if (!git_config_set_multivar_in_file_gently(config_filename, key, value,
|
||||
value_pattern, flags))
|
||||
value_pattern, NULL, flags))
|
||||
return;
|
||||
if (value)
|
||||
die(_("could not set '%s' to '%s'"), key, value);
|
||||
|
@ -3472,7 +3536,7 @@ int repo_config_set_multivar_gently(struct repository *r, const char *key,
|
|||
int res = git_config_set_multivar_in_file_gently(file,
|
||||
key, value,
|
||||
value_pattern,
|
||||
flags);
|
||||
NULL, flags);
|
||||
free(file);
|
||||
return res;
|
||||
}
|
||||
|
|
6
config.h
6
config.h
|
@ -290,7 +290,7 @@ int git_config_pathname(const char **, const char *, const char *);
|
|||
|
||||
int git_config_expiry_date(timestamp_t *, const char *, const char *);
|
||||
int git_config_color(char *, const char *, const char *);
|
||||
int git_config_set_in_file_gently(const char *, const char *, const char *);
|
||||
int git_config_set_in_file_gently(const char *, const char *, const char *, const char *);
|
||||
|
||||
/**
|
||||
* write config values to a specific config file, takes a key/value pair as
|
||||
|
@ -336,7 +336,9 @@ int git_config_parse_key(const char *, char **, size_t *);
|
|||
int git_config_set_multivar_gently(const char *, const char *, const char *, unsigned);
|
||||
void git_config_set_multivar(const char *, const char *, const char *, unsigned);
|
||||
int repo_config_set_multivar_gently(struct repository *, const char *, const char *, const char *, unsigned);
|
||||
int git_config_set_multivar_in_file_gently(const char *, const char *, const char *, const char *, unsigned);
|
||||
int git_config_set_multivar_in_file_gently(const char *, const char *, const char *, const char *, const char *, unsigned);
|
||||
|
||||
const char *git_config_prepare_comment_string(const char *);
|
||||
|
||||
/**
|
||||
* takes four parameters:
|
||||
|
|
30
sequencer.c
30
sequencer.c
|
@ -3484,57 +3484,57 @@ static int save_opts(struct replay_opts *opts)
|
|||
|
||||
if (opts->no_commit)
|
||||
res |= git_config_set_in_file_gently(opts_file,
|
||||
"options.no-commit", "true");
|
||||
"options.no-commit", NULL, "true");
|
||||
if (opts->edit >= 0)
|
||||
res |= git_config_set_in_file_gently(opts_file, "options.edit",
|
||||
res |= git_config_set_in_file_gently(opts_file, "options.edit", NULL,
|
||||
opts->edit ? "true" : "false");
|
||||
if (opts->allow_empty)
|
||||
res |= git_config_set_in_file_gently(opts_file,
|
||||
"options.allow-empty", "true");
|
||||
"options.allow-empty", NULL, "true");
|
||||
if (opts->allow_empty_message)
|
||||
res |= git_config_set_in_file_gently(opts_file,
|
||||
"options.allow-empty-message", "true");
|
||||
"options.allow-empty-message", NULL, "true");
|
||||
if (opts->drop_redundant_commits)
|
||||
res |= git_config_set_in_file_gently(opts_file,
|
||||
"options.drop-redundant-commits", "true");
|
||||
"options.drop-redundant-commits", NULL, "true");
|
||||
if (opts->keep_redundant_commits)
|
||||
res |= git_config_set_in_file_gently(opts_file,
|
||||
"options.keep-redundant-commits", "true");
|
||||
"options.keep-redundant-commits", NULL, "true");
|
||||
if (opts->signoff)
|
||||
res |= git_config_set_in_file_gently(opts_file,
|
||||
"options.signoff", "true");
|
||||
"options.signoff", NULL, "true");
|
||||
if (opts->record_origin)
|
||||
res |= git_config_set_in_file_gently(opts_file,
|
||||
"options.record-origin", "true");
|
||||
"options.record-origin", NULL, "true");
|
||||
if (opts->allow_ff)
|
||||
res |= git_config_set_in_file_gently(opts_file,
|
||||
"options.allow-ff", "true");
|
||||
"options.allow-ff", NULL, "true");
|
||||
if (opts->mainline) {
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
strbuf_addf(&buf, "%d", opts->mainline);
|
||||
res |= git_config_set_in_file_gently(opts_file,
|
||||
"options.mainline", buf.buf);
|
||||
"options.mainline", NULL, buf.buf);
|
||||
strbuf_release(&buf);
|
||||
}
|
||||
if (opts->strategy)
|
||||
res |= git_config_set_in_file_gently(opts_file,
|
||||
"options.strategy", opts->strategy);
|
||||
"options.strategy", NULL, opts->strategy);
|
||||
if (opts->gpg_sign)
|
||||
res |= git_config_set_in_file_gently(opts_file,
|
||||
"options.gpg-sign", opts->gpg_sign);
|
||||
"options.gpg-sign", NULL, opts->gpg_sign);
|
||||
for (size_t i = 0; i < opts->xopts.nr; i++)
|
||||
res |= git_config_set_multivar_in_file_gently(opts_file,
|
||||
"options.strategy-option",
|
||||
opts->xopts.v[i], "^$", 0);
|
||||
opts->xopts.v[i], "^$", NULL, 0);
|
||||
if (opts->allow_rerere_auto)
|
||||
res |= git_config_set_in_file_gently(opts_file,
|
||||
"options.allow-rerere-auto",
|
||||
"options.allow-rerere-auto", NULL,
|
||||
opts->allow_rerere_auto == RERERE_AUTOUPDATE ?
|
||||
"true" : "false");
|
||||
|
||||
if (opts->explicit_cleanup)
|
||||
res |= git_config_set_in_file_gently(opts_file,
|
||||
"options.default-msg-cleanup",
|
||||
"options.default-msg-cleanup", NULL,
|
||||
describe_cleanup_mode(opts->default_msg_cleanup));
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -978,7 +978,7 @@ int config_set_in_gitmodules_file_gently(const char *key, const char *value)
|
|||
{
|
||||
int ret;
|
||||
|
||||
ret = git_config_set_in_file_gently(GITMODULES_FILE, key, value);
|
||||
ret = git_config_set_in_file_gently(GITMODULES_FILE, key, NULL, value);
|
||||
if (ret < 0)
|
||||
/* Maybe the user already did that, don't error out here */
|
||||
warning(_("Could not update .gitmodules entry %s"), key);
|
||||
|
|
|
@ -2046,7 +2046,7 @@ void submodule_unset_core_worktree(const struct submodule *sub)
|
|||
submodule_name_to_gitdir(&config_path, the_repository, sub->name);
|
||||
strbuf_addstr(&config_path, "/config");
|
||||
|
||||
if (git_config_set_in_file_gently(config_path.buf, "core.worktree", NULL))
|
||||
if (git_config_set_in_file_gently(config_path.buf, "core.worktree", NULL, NULL))
|
||||
warning(_("Could not unset core.worktree setting in submodule '%s'"),
|
||||
sub->path);
|
||||
|
||||
|
|
|
@ -161,14 +161,32 @@ test_expect_success 'replace with non-match (actually matching)' '
|
|||
|
||||
cat > expect << EOF
|
||||
[section]
|
||||
penguin = very blue
|
||||
Movie = BadPhysics
|
||||
UPPERCASE = true
|
||||
penguin = kingpin
|
||||
penguin = gentoo # Pygoscelis papua
|
||||
disposition = peckish # find fish
|
||||
foo = bar #abc
|
||||
spsp = value # and comment
|
||||
htsp = value # and comment
|
||||
[Sections]
|
||||
WhatEver = Second
|
||||
EOF
|
||||
|
||||
test_expect_success 'append comments' '
|
||||
git config --replace-all --comment="Pygoscelis papua" section.penguin gentoo &&
|
||||
git config --comment="find fish" section.disposition peckish &&
|
||||
git config --comment="#abc" section.foo bar &&
|
||||
|
||||
git config --comment="and comment" section.spsp value &&
|
||||
git config --comment=" # and comment" section.htsp value &&
|
||||
|
||||
test_cmp expect .git/config
|
||||
'
|
||||
|
||||
test_expect_success 'Prohibited LF in comment' '
|
||||
test_must_fail git config --comment="a${LF}b" section.k v
|
||||
'
|
||||
|
||||
test_expect_success 'non-match result' 'test_cmp expect .git/config'
|
||||
|
||||
test_expect_success 'find mixed-case key by canonical name' '
|
||||
|
|
|
@ -807,9 +807,9 @@ int should_prune_worktree(const char *id, struct strbuf *reason, char **wtpath,
|
|||
static int move_config_setting(const char *key, const char *value,
|
||||
const char *from_file, const char *to_file)
|
||||
{
|
||||
if (git_config_set_in_file_gently(to_file, key, value))
|
||||
if (git_config_set_in_file_gently(to_file, key, NULL, value))
|
||||
return error(_("unable to set %s in '%s'"), key, to_file);
|
||||
if (git_config_set_in_file_gently(from_file, key, NULL))
|
||||
if (git_config_set_in_file_gently(from_file, key, NULL, NULL))
|
||||
return error(_("unable to unset %s in '%s'"), key, from_file);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue