advice: move advice.graftFileDeprecated squashing to commit.[ch]
Move the squashing of the advice.graftFileDeprecated advice over to an external variable in commit.[ch], allowing advice() to purely use the new-style API of invoking advice() with an enum. See 8821e90a09a (advice: don't pointlessly suggest --convert-graft-file, 2018-11-27) for why quieting this advice was needed. It's more straightforward to move this code to commit.[ch] and use it builtin/replace.c, than to go through the indirection of advice.[ch]. Because this was the last advice_config variable we can remove that old facility from advice.c. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
c2a4b6d4ee
commit
ab628588f8
16
advice.c
16
advice.c
@ -4,8 +4,6 @@
|
|||||||
#include "help.h"
|
#include "help.h"
|
||||||
#include "string-list.h"
|
#include "string-list.h"
|
||||||
|
|
||||||
int advice_graft_file_deprecated = 1;
|
|
||||||
|
|
||||||
static int advice_use_color = -1;
|
static int advice_use_color = -1;
|
||||||
static char advice_colors[][COLOR_MAXLEN] = {
|
static char advice_colors[][COLOR_MAXLEN] = {
|
||||||
GIT_COLOR_RESET,
|
GIT_COLOR_RESET,
|
||||||
@ -33,13 +31,6 @@ static const char *advise_get_color(enum color_advice ix)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct {
|
|
||||||
const char *name;
|
|
||||||
int *preference;
|
|
||||||
} advice_config[] = {
|
|
||||||
{ "graftFileDeprecated", &advice_graft_file_deprecated },
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
const char *key;
|
const char *key;
|
||||||
int enabled;
|
int enabled;
|
||||||
@ -162,13 +153,6 @@ int git_default_advice_config(const char *var, const char *value)
|
|||||||
if (!skip_prefix(var, "advice.", &k))
|
if (!skip_prefix(var, "advice.", &k))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(advice_config); i++) {
|
|
||||||
if (strcasecmp(k, advice_config[i].name))
|
|
||||||
continue;
|
|
||||||
*advice_config[i].preference = git_config_bool(var, value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(advice_setting); i++) {
|
for (i = 0; i < ARRAY_SIZE(advice_setting); i++) {
|
||||||
if (strcasecmp(k, advice_setting[i].key))
|
if (strcasecmp(k, advice_setting[i].key))
|
||||||
continue;
|
continue;
|
||||||
|
2
advice.h
2
advice.h
@ -5,8 +5,6 @@
|
|||||||
|
|
||||||
struct string_list;
|
struct string_list;
|
||||||
|
|
||||||
extern int advice_graft_file_deprecated;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* To add a new advice, you need to:
|
* To add a new advice, you need to:
|
||||||
* Define a new advice_type.
|
* Define a new advice_type.
|
||||||
|
@ -507,7 +507,7 @@ static int convert_graft_file(int force)
|
|||||||
if (!fp)
|
if (!fp)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
advice_graft_file_deprecated = 0;
|
no_graft_file_deprecated_advice = 1;
|
||||||
while (strbuf_getline(&buf, fp) != EOF) {
|
while (strbuf_getline(&buf, fp) != EOF) {
|
||||||
if (*buf.buf == '#')
|
if (*buf.buf == '#')
|
||||||
continue;
|
continue;
|
||||||
|
4
commit.c
4
commit.c
@ -25,6 +25,7 @@
|
|||||||
static struct commit_extra_header *read_commit_extra_header_lines(const char *buf, size_t len, const char **);
|
static struct commit_extra_header *read_commit_extra_header_lines(const char *buf, size_t len, const char **);
|
||||||
|
|
||||||
int save_commit_buffer = 1;
|
int save_commit_buffer = 1;
|
||||||
|
int no_graft_file_deprecated_advice;
|
||||||
|
|
||||||
const char *commit_type = "commit";
|
const char *commit_type = "commit";
|
||||||
|
|
||||||
@ -190,7 +191,8 @@ static int read_graft_file(struct repository *r, const char *graft_file)
|
|||||||
struct strbuf buf = STRBUF_INIT;
|
struct strbuf buf = STRBUF_INIT;
|
||||||
if (!fp)
|
if (!fp)
|
||||||
return -1;
|
return -1;
|
||||||
if (advice_graft_file_deprecated)
|
if (!no_graft_file_deprecated_advice &&
|
||||||
|
advice_enabled(ADVICE_GRAFT_FILE_DEPRECATED))
|
||||||
advise(_("Support for <GIT_DIR>/info/grafts is deprecated\n"
|
advise(_("Support for <GIT_DIR>/info/grafts is deprecated\n"
|
||||||
"and will be removed in a future Git version.\n"
|
"and will be removed in a future Git version.\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
1
commit.h
1
commit.h
@ -41,6 +41,7 @@ struct commit {
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern int save_commit_buffer;
|
extern int save_commit_buffer;
|
||||||
|
extern int no_graft_file_deprecated_advice;
|
||||||
extern const char *commit_type;
|
extern const char *commit_type;
|
||||||
|
|
||||||
/* While we can decorate any object with a name, it's only used for commits.. */
|
/* While we can decorate any object with a name, it's only used for commits.. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user