summaryrefslogtreecommitdiff
path: root/builtin/add.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2021-09-10 11:46:29 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-09-10 11:46:29 -0700
commitfd0d7036e0da248f354e91fb8be8771fb20adfac (patch)
tree2fe4ef0cec6a9724df9fa5e15860bb0867fc817c /builtin/add.c
parentMerge branch 'mk/clone-recurse-submodules' (diff)
parentadvice: move advice.graftFileDeprecated squashing to commit.[ch] (diff)
downloadtgif-fd0d7036e0da248f354e91fb8be8771fb20adfac.tar.xz
Merge branch 'ab/retire-advice-config'
Code clean up to migrate callers from older advice_config[] based API to newer advice_if_enabled() and advice_enabled() API. * ab/retire-advice-config: advice: move advice.graftFileDeprecated squashing to commit.[ch] advice: remove use of global advice_add_embedded_repo advice: remove read uses of most global `advice_` variables advice: add enum variants for missing advice variables
Diffstat (limited to 'builtin/add.c')
-rw-r--r--builtin/add.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/builtin/add.c b/builtin/add.c
index 8ec5ad9f26..2244311d48 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -423,6 +423,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;
@@ -434,10 +435,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);
@@ -451,7 +452,7 @@ static int add_files(struct dir_struct *dir, int flags)
fprintf(stderr, _(ignore_error));
for (i = 0; i < dir->ignored_nr; i++)
fprintf(stderr, "%s\n", dir->ignored[i]->name);
- if (advice_add_ignored_file)
+ if (advice_enabled(ADVICE_ADD_IGNORED_FILE))
advise(_("Use -f if you really want to add them.\n"
"Turn this message off by running\n"
"\"git config advice.addIgnoredFile false\""));
@@ -560,7 +561,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
if (require_pathspec && pathspec.nr == 0) {
fprintf(stderr, _("Nothing specified, nothing added.\n"));
- if (advice_add_empty_pathspec)
+ if (advice_enabled(ADVICE_ADD_EMPTY_PATHSPEC))
advise( _("Maybe you wanted to say 'git add .'?\n"
"Turn this message off by running\n"
"\"git config advice.addEmptyPathspec false\""));