Skip to content

Commit ab62858

Browse files
avargitster
authored andcommitted
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 8821e90 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c2a4b6d commit ab62858

File tree

5 files changed

+5
-20
lines changed

5 files changed

+5
-20
lines changed

advice.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
#include "help.h"
55
#include "string-list.h"
66

7-
int advice_graft_file_deprecated = 1;
8-
97
static int advice_use_color = -1;
108
static char advice_colors[][COLOR_MAXLEN] = {
119
GIT_COLOR_RESET,
@@ -33,13 +31,6 @@ static const char *advise_get_color(enum color_advice ix)
3331
return "";
3432
}
3533

36-
static struct {
37-
const char *name;
38-
int *preference;
39-
} advice_config[] = {
40-
{ "graftFileDeprecated", &advice_graft_file_deprecated },
41-
};
42-
4334
static struct {
4435
const char *key;
4536
int enabled;
@@ -162,13 +153,6 @@ int git_default_advice_config(const char *var, const char *value)
162153
if (!skip_prefix(var, "advice.", &k))
163154
return 0;
164155

165-
for (i = 0; i < ARRAY_SIZE(advice_config); i++) {
166-
if (strcasecmp(k, advice_config[i].name))
167-
continue;
168-
*advice_config[i].preference = git_config_bool(var, value);
169-
break;
170-
}
171-
172156
for (i = 0; i < ARRAY_SIZE(advice_setting); i++) {
173157
if (strcasecmp(k, advice_setting[i].key))
174158
continue;

advice.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
struct string_list;
77

8-
extern int advice_graft_file_deprecated;
9-
108
/*
119
* To add a new advice, you need to:
1210
* Define a new advice_type.

builtin/replace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ static int convert_graft_file(int force)
507507
if (!fp)
508508
return -1;
509509

510-
advice_graft_file_deprecated = 0;
510+
no_graft_file_deprecated_advice = 1;
511511
while (strbuf_getline(&buf, fp) != EOF) {
512512
if (*buf.buf == '#')
513513
continue;

commit.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
static struct commit_extra_header *read_commit_extra_header_lines(const char *buf, size_t len, const char **);
2626

2727
int save_commit_buffer = 1;
28+
int no_graft_file_deprecated_advice;
2829

2930
const char *commit_type = "commit";
3031

@@ -190,7 +191,8 @@ static int read_graft_file(struct repository *r, const char *graft_file)
190191
struct strbuf buf = STRBUF_INIT;
191192
if (!fp)
192193
return -1;
193-
if (advice_graft_file_deprecated)
194+
if (!no_graft_file_deprecated_advice &&
195+
advice_enabled(ADVICE_GRAFT_FILE_DEPRECATED))
194196
advise(_("Support for <GIT_DIR>/info/grafts is deprecated\n"
195197
"and will be removed in a future Git version.\n"
196198
"\n"

commit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ struct commit {
4141
};
4242

4343
extern int save_commit_buffer;
44+
extern int no_graft_file_deprecated_advice;
4445
extern const char *commit_type;
4546

4647
/* While we can decorate any object with a name, it's only used for commits.. */

0 commit comments

Comments
 (0)