Be more user-friendly when refusing to do something because of conflict.
[git/mingw.git] / advice.c
blob3309521f456b0218fa765ba7f3dd7d7a3e94dea2
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;
8 static struct {
9 const char *name;
10 int *preference;
11 } advice_config[] = {
12 { "pushnonfastforward", &advice_push_nonfastforward },
13 { "statushints", &advice_status_hints },
14 { "commitbeforemerge", &advice_commit_before_merge },
15 { "resolveconflict", &advice_resolve_conflict },
18 int git_default_advice_config(const char *var, const char *value)
20 const char *k = skip_prefix(var, "advice.");
21 int i;
23 for (i = 0; i < ARRAY_SIZE(advice_config); i++) {
24 if (strcmp(k, advice_config[i].name))
25 continue;
26 *advice_config[i].preference = git_config_bool(var, value);
27 return 0;
30 return 0;
33 void NORETURN die_resolve_conflict(const char *me)
35 if (advice_resolve_conflict)
37 * Message used both when 'git commit' fails and when
38 * other commands doing a merge do.
40 die("'%s' is not possible because you have unmerged files.\n"
41 "Please, fix them up in the work tree, and then use 'git add/rm <file>' as\n"
42 "appropriate to mark resolution and make a commit, or use 'git commit -a'.", me);
43 else
44 die("'%s' is not possible because you have unmerged files.", me);