diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2021-08-23 12:44:01 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-08-25 12:07:52 -0700 |
commit | c2a4b6d4ee4f7f52521c1c36d63744f1a3c08d50 (patch) | |
tree | 2bb6a306b5340c88fc0909a2fba31f8c044a425e /builtin/add.c | |
parent | advice: remove read uses of most global `advice_` variables (diff) | |
download | tgif-c2a4b6d4ee4f7f52521c1c36d63744f1a3c08d50.tar.xz |
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>
Diffstat (limited to 'builtin/add.c')
-rw-r--r-- | builtin/add.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/builtin/add.c b/builtin/add.c index cf29b302d4..8a5dd29f3f 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -419,6 +419,7 @@ static const char embedded_advice[] = N_( static void check_embedded_repo(const char *path) { struct strbuf name = STRBUF_INIT; + static int adviced_on_embedded_repo = 0; if (!warn_on_embedded_repo) return; @@ -430,10 +431,10 @@ static void check_embedded_repo(const char *path) strbuf_strip_suffix(&name, "/"); warning(_("adding embedded git repository: %s"), name.buf); - if (advice_add_embedded_repo) { + if (!adviced_on_embedded_repo && + advice_enabled(ADVICE_ADD_EMBEDDED_REPO)) { advise(embedded_advice, name.buf, name.buf); - /* there may be multiple entries; advise only once */ - advice_add_embedded_repo = 0; + adviced_on_embedded_repo = 1; } strbuf_release(&name); |