repack_without_ref(): remove temporary
[git/mingw.git] / advice.c
blobe02e632df380a8e9772d9cd9b1282204c56a7d4e
1 #include "cache.h"
3 int advice_push_nonfastforward = 1;
4 int advice_status_hints = 1;
5 int advice_commit_before_merge = 1;
6 int advice_resolve_conflict = 1;
7 int advice_implicit_identity = 1;
8 int advice_detached_head = 1;
10 static struct {
11 const char *name;
12 int *preference;
13 } advice_config[] = {
14 { "pushnonfastforward", &advice_push_nonfastforward },
15 { "statushints", &advice_status_hints },
16 { "commitbeforemerge", &advice_commit_before_merge },
17 { "resolveconflict", &advice_resolve_conflict },
18 { "implicitidentity", &advice_implicit_identity },
19 { "detachedhead", &advice_detached_head },
22 void advise(const char *advice, ...)
24 va_list params;
26 va_start(params, advice);
27 vreportf("hint: ", advice, params);
28 va_end(params);
31 int git_default_advice_config(const char *var, const char *value)
33 const char *k = skip_prefix(var, "advice.");
34 int i;
36 for (i = 0; i < ARRAY_SIZE(advice_config); i++) {
37 if (strcmp(k, advice_config[i].name))
38 continue;
39 *advice_config[i].preference = git_config_bool(var, value);
40 return 0;
43 return 0;
46 int error_resolve_conflict(const char *me)
48 error("'%s' is not possible because you have unmerged files.", me);
49 if (advice_resolve_conflict) {
51 * Message used both when 'git commit' fails and when
52 * other commands doing a merge do.
54 advise("Fix them up in the work tree,");
55 advise("and then use 'git add/rm <file>' as");
56 advise("appropriate to mark resolution and make a commit,");
57 advise("or use 'git commit -a'.");
59 return -1;
62 void NORETURN die_resolve_conflict(const char *me)
64 error_resolve_conflict(me);
65 die("Exiting because of an unresolved conflict.");