Skip to content

Commit c2a4b6d

Browse files
avargitster
authored andcommitted
advice: remove use of global advice_add_embedded_repo
The external use of this variable was added in 5321399 (add: warn when adding an embedded repository, 2017-06-14). For the use-case it's more straightforward to track whether we've shown advice in check_embedded_repo() than setting the global variable. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ed9bff0 commit c2a4b6d

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

advice.c

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

7-
int advice_add_embedded_repo = 1;
87
int advice_graft_file_deprecated = 1;
98

109
static int advice_use_color = -1;
@@ -38,7 +37,6 @@ static struct {
3837
const char *name;
3938
int *preference;
4039
} advice_config[] = {
41-
{ "addEmbeddedRepo", &advice_add_embedded_repo },
4240
{ "graftFileDeprecated", &advice_graft_file_deprecated },
4341
};
4442

advice.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
struct string_list;
77

8-
extern int advice_add_embedded_repo;
98
extern int advice_graft_file_deprecated;
109

1110
/*

builtin/add.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ static const char embedded_advice[] = N_(
419419
static void check_embedded_repo(const char *path)
420420
{
421421
struct strbuf name = STRBUF_INIT;
422+
static int adviced_on_embedded_repo = 0;
422423

423424
if (!warn_on_embedded_repo)
424425
return;
@@ -430,10 +431,10 @@ static void check_embedded_repo(const char *path)
430431
strbuf_strip_suffix(&name, "/");
431432

432433
warning(_("adding embedded git repository: %s"), name.buf);
433-
if (advice_add_embedded_repo) {
434+
if (!adviced_on_embedded_repo &&
435+
advice_enabled(ADVICE_ADD_EMBEDDED_REPO)) {
434436
advise(embedded_advice, name.buf, name.buf);
435-
/* there may be multiple entries; advise only once */
436-
advice_add_embedded_repo = 0;
437+
adviced_on_embedded_repo = 1;
437438
}
438439

439440
strbuf_release(&name);

0 commit comments

Comments
 (0)