blob: 0be4b5f008e1646946ba12fa5e51aa0830911ece [file] [log] [blame]
Jeff King75194432009-09-09 07:38:58 -04001#include "cache.h"
2
3int advice_push_nonfastforward = 1;
Jeff Kingedf563f2009-09-09 07:43:03 -04004int advice_status_hints = 1;
Matthieu Moy4c371f92009-11-22 23:26:17 +01005int advice_commit_before_merge = 1;
Matthieu Moyd38a30d2010-01-12 10:54:44 +01006int advice_resolve_conflict = 1;
Jeff Kingb706fcf2010-01-13 15:17:08 -05007int advice_implicit_identity = 1;
Junio C Hamano13be3e32010-01-29 22:03:24 -08008int advice_detached_head = 1;
Jeff King75194432009-09-09 07:38:58 -04009
10static struct {
11 const char *name;
12 int *preference;
13} advice_config[] = {
14 { "pushnonfastforward", &advice_push_nonfastforward },
Jeff Kingedf563f2009-09-09 07:43:03 -040015 { "statushints", &advice_status_hints },
Matthieu Moy4c371f92009-11-22 23:26:17 +010016 { "commitbeforemerge", &advice_commit_before_merge },
Matthieu Moyd38a30d2010-01-12 10:54:44 +010017 { "resolveconflict", &advice_resolve_conflict },
Jeff Kingb706fcf2010-01-13 15:17:08 -050018 { "implicitidentity", &advice_implicit_identity },
Junio C Hamano13be3e32010-01-29 22:03:24 -080019 { "detachedhead", &advice_detached_head },
Jeff King75194432009-09-09 07:38:58 -040020};
21
22int git_default_advice_config(const char *var, const char *value)
23{
24 const char *k = skip_prefix(var, "advice.");
25 int i;
26
27 for (i = 0; i < ARRAY_SIZE(advice_config); i++) {
28 if (strcmp(k, advice_config[i].name))
29 continue;
30 *advice_config[i].preference = git_config_bool(var, value);
31 return 0;
32 }
33
34 return 0;
35}
Matthieu Moyd38a30d2010-01-12 10:54:44 +010036
37void NORETURN die_resolve_conflict(const char *me)
38{
39 if (advice_resolve_conflict)
40 /*
41 * Message used both when 'git commit' fails and when
42 * other commands doing a merge do.
43 */
44 die("'%s' is not possible because you have unmerged files.\n"
45 "Please, fix them up in the work tree, and then use 'git add/rm <file>' as\n"
46 "appropriate to mark resolution and make a commit, or use 'git commit -a'.", me);
47 else
48 die("'%s' is not possible because you have unmerged files.", me);
49}