Merge branch 'rj/use-adv-if-enabled'
Use advice_if_enabled() API to rewrite a simple pattern to call advise() after checking advice_enabled(). * rj/use-adv-if-enabled: add: use advise_if_enabled for ADVICE_ADD_EMBEDDED_REPO add: use advise_if_enabled for ADVICE_ADD_EMPTY_PATHSPEC add: use advise_if_enabled for ADVICE_ADD_IGNORED_FILE
This commit is contained in:
@ -310,9 +310,9 @@ static void check_embedded_repo(const char *path)
|
||||
strbuf_strip_suffix(&name, "/");
|
||||
|
||||
warning(_("adding embedded git repository: %s"), name.buf);
|
||||
if (!adviced_on_embedded_repo &&
|
||||
advice_enabled(ADVICE_ADD_EMBEDDED_REPO)) {
|
||||
advise(embedded_advice, name.buf, name.buf);
|
||||
if (!adviced_on_embedded_repo) {
|
||||
advise_if_enabled(ADVICE_ADD_EMBEDDED_REPO,
|
||||
embedded_advice, name.buf, name.buf);
|
||||
adviced_on_embedded_repo = 1;
|
||||
}
|
||||
|
||||
@ -328,10 +328,8 @@ 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_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\""));
|
||||
advise_if_enabled(ADVICE_ADD_IGNORED_FILE,
|
||||
_("Use -f if you really want to add them."));
|
||||
exit_status = 1;
|
||||
}
|
||||
|
||||
@ -440,10 +438,8 @@ 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_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\""));
|
||||
advise_if_enabled(ADVICE_ADD_EMPTY_PATHSPEC,
|
||||
_("Maybe you wanted to say 'git add .'?"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user