]> git.ipfire.org Git - thirdparty/git.git/blobdiff - advice.c
Git 1.7.8-rc2
[thirdparty/git.git] / advice.c
index 0be4b5f008e1646946ba12fa5e51aa0830911ece..e02e632df380a8e9772d9cd9b1282204c56a7d4e 100644 (file)
--- a/advice.c
+++ b/advice.c
@@ -19,6 +19,15 @@ static struct {
        { "detachedhead", &advice_detached_head },
 };
 
+void advise(const char *advice, ...)
+{
+       va_list params;
+
+       va_start(params, advice);
+       vreportf("hint: ", advice, params);
+       va_end(params);
+}
+
 int git_default_advice_config(const char *var, const char *value)
 {
        const char *k = skip_prefix(var, "advice.");
@@ -34,16 +43,24 @@ int git_default_advice_config(const char *var, const char *value)
        return 0;
 }
 
-void NORETURN die_resolve_conflict(const char *me)
+int error_resolve_conflict(const char *me)
 {
-       if (advice_resolve_conflict)
+       error("'%s' is not possible because you have unmerged files.", me);
+       if (advice_resolve_conflict) {
                /*
                 * Message used both when 'git commit' fails and when
                 * other commands doing a merge do.
                 */
-               die("'%s' is not possible because you have unmerged files.\n"
-                   "Please, fix them up in the work tree, and then use 'git add/rm <file>' as\n"
-                   "appropriate to mark resolution and make a commit, or use 'git commit -a'.", me);
-       else
-               die("'%s' is not possible because you have unmerged files.", me);
+               advise("Fix them up in the work tree,");
+               advise("and then use 'git add/rm <file>' as");
+               advise("appropriate to mark resolution and make a commit,");
+               advise("or use 'git commit -a'.");
+       }
+       return -1;
+}
+
+void NORETURN die_resolve_conflict(const char *me)
+{
+       error_resolve_conflict(me);
+       die("Exiting because of an unresolved conflict.");
 }