tag: use new advice API to check visibility
[git] / advice.h
1 #ifndef ADVICE_H
2 #define ADVICE_H
3
4 #include "git-compat-util.h"
5
6 extern int advice_fetch_show_forced_updates;
7 extern int advice_push_update_rejected;
8 extern int advice_push_non_ff_current;
9 extern int advice_push_non_ff_matching;
10 extern int advice_push_already_exists;
11 extern int advice_push_fetch_first;
12 extern int advice_push_needs_force;
13 extern int advice_push_unqualified_ref_name;
14 extern int advice_status_hints;
15 extern int advice_status_u_option;
16 extern int advice_status_ahead_behind_warning;
17 extern int advice_commit_before_merge;
18 extern int advice_reset_quiet_warning;
19 extern int advice_resolve_conflict;
20 extern int advice_sequencer_in_use;
21 extern int advice_implicit_identity;
22 extern int advice_detached_head;
23 extern int advice_set_upstream_failure;
24 extern int advice_object_name_warning;
25 extern int advice_amworkdir;
26 extern int advice_rm_hints;
27 extern int advice_add_embedded_repo;
28 extern int advice_ignored_hook;
29 extern int advice_waiting_for_editor;
30 extern int advice_graft_file_deprecated;
31 extern int advice_checkout_ambiguous_remote_branch_name;
32 extern int advice_submodule_alternate_error_strategy_die;
33
34 /*
35  * To add a new advice, you need to:
36  * Define a new advice_type.
37  * Add a new entry to advice_setting array.
38  * Add the new config variable to Documentation/config/advice.txt.
39  * Call advise_if_enabled to print your advice.
40  */
41  enum advice_type {
42         ADVICE_ADD_EMBEDDED_REPO,
43         ADVICE_AM_WORK_DIR,
44         ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME,
45         ADVICE_COMMIT_BEFORE_MERGE,
46         ADVICE_DETACHED_HEAD,
47         ADVICE_FETCH_SHOW_FORCED_UPDATES,
48         ADVICE_GRAFT_FILE_DEPRECATED,
49         ADVICE_IGNORED_HOOK,
50         ADVICE_IMPLICIT_IDENTITY,
51         ADVICE_NESTED_TAG,
52         ADVICE_OBJECT_NAME_WARNING,
53         ADVICE_PUSH_ALREADY_EXISTS,
54         ADVICE_PUSH_FETCH_FIRST,
55         ADVICE_PUSH_NEEDS_FORCE,
56         ADVICE_PUSH_NON_FF_CURRENT,
57         ADVICE_PUSH_NON_FF_MATCHING,
58         ADVICE_PUSH_UNQUALIFIED_REF_NAME,
59         ADVICE_PUSH_UPDATE_REJECTED_ALIAS,
60         ADVICE_PUSH_UPDATE_REJECTED,
61         ADVICE_RESET_QUIET_WARNING,
62         ADVICE_RESOLVE_CONFLICT,
63         ADVICE_RM_HINTS,
64         ADVICE_SEQUENCER_IN_USE,
65         ADVICE_SET_UPSTREAM_FAILURE,
66         ADVICE_STATUS_AHEAD_BEHIND_WARNING,
67         ADVICE_STATUS_HINTS,
68         ADVICE_STATUS_U_OPTION,
69         ADVICE_SUBMODULE_ALTERNATE_ERROR_STRATEGY_DIE,
70         ADVICE_WAITING_FOR_EDITOR,
71 };
72
73 int git_default_advice_config(const char *var, const char *value);
74 __attribute__((format (printf, 1, 2)))
75 void advise(const char *advice, ...);
76
77 /**
78  * Checks if advice type is enabled (can be printed to the user).
79  * Should be called before advise().
80  */
81 int advice_enabled(enum advice_type type);
82
83 /**
84  * Checks the visibility of the advice before printing.
85  */
86 void advise_if_enabled(enum advice_type type, const char *advice, ...);
87
88 int error_resolve_conflict(const char *me);
89 void NORETURN die_resolve_conflict(const char *me);
90 void NORETURN die_conclude_merge(void);
91 void detach_advice(const char *new_name);
92
93 #endif /* ADVICE_H */