advice: remove use of global advice_add_embedded_repo

The external use of this variable was added in 532139940c9 (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 <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Aug 23, 2021 at 12:44 UTC c2a4b6d4ee4f7f52521c1c36d63744f1a3c08d50
3 files changed +4 -6
advice.c
-2
@@ -4,7 +4,6 @@
4 #include "help.h"
5 #include "string-list.h"
6
7 -int advice_add_embedded_repo = 1;
7 int advice_graft_file_deprecated = 1;
8
9 static int advice_use_color = -1;
@@ -38,7 +37,6 @@ static struct {
37 const char *name;
38 int *preference;
39 } advice_config[] = {
41 - { "addEmbeddedRepo", &advice_add_embedded_repo },
40 { "graftFileDeprecated", &advice_graft_file_deprecated },
41 };
42
advice.h
-1
@@ -5,7 +5,6 @@
5
6 struct string_list;
7
8 -extern int advice_add_embedded_repo;
8 extern int advice_graft_file_deprecated;
9
10 /*
builtin/add.c
+4 -3
@@ -419,6 +419,7 @@ static const char embedded_advice[] = N_(
419 static void check_embedded_repo(const char *path)
420 {
421 struct strbuf name = STRBUF_INIT;
422 + static int adviced_on_embedded_repo = 0;
423
424 if (!warn_on_embedded_repo)
425 return;
@@ -430,10 +431,10 @@ static void check_embedded_repo(const char *path)
431 strbuf_strip_suffix(&name, "/");
432
433 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)) {
436 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;
438 }
439
440 strbuf_release(&name);