summaryrefslogtreecommitdiff
path: root/builtin/add.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-09-10 18:46:29 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-09-10 18:46:29 (GMT)
commitfd0d7036e0da248f354e91fb8be8771fb20adfac (patch)
tree2fe4ef0cec6a9724df9fa5e15860bb0867fc817c /builtin/add.c
parent6d09fc54f60cfd8d91f471c3bcdc935c8e301458 (diff)
parentab628588f80e8dd889b700515c41548c1a356dcc (diff)
downloadgit-fd0d7036e0da248f354e91fb8be8771fb20adfac.zip
git-fd0d7036e0da248f354e91fb8be8771fb20adfac.tar.gz
git-fd0d7036e0da248f354e91fb8be8771fb20adfac.tar.bz2
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 8ec5ad9..2244311 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\""));