[RFC/PATCH 01/18] advice: add error_resolve_conflict() function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



in case we don't want to die, but still want the right
error message to be printed.

Signed-off-by: Christian Couder <chriscool@xxxxxxxxxxxxx>
---
 advice.c |   25 +++++++++++++++++++++----
 advice.h |    1 +
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/advice.c b/advice.c
index 0be4b5f..d4ba29f 100644
--- a/advice.c
+++ b/advice.c
@@ -34,6 +34,13 @@ int git_default_advice_config(const char *var, const char *value)
 	return 0;
 }
 
+const char unmerged_file_advice[] =
+	"'%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'.";
+const char unmerged_file_no_advice[] =
+	"'%s' is not possible because you have unmerged files.";
+
 void NORETURN die_resolve_conflict(const char *me)
 {
 	if (advice_resolve_conflict)
@@ -41,9 +48,19 @@ void NORETURN die_resolve_conflict(const char *me)
 		 * 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);
+		die(unmerged_file_advice, me);
+	else
+		die(unmerged_file_no_advice, me);
+}
+
+int error_resolve_conflict(const char *me)
+{
+	if (advice_resolve_conflict)
+		/*
+		 * Message used both when 'git commit' fails and when
+		 * other commands doing a merge do.
+		 */
+		return error(unmerged_file_advice, me);
 	else
-		die("'%s' is not possible because you have unmerged files.", me);
+		return error(unmerged_file_no_advice, me);
 }
diff --git a/advice.h b/advice.h
index 3244ebb..7b7cea5 100644
--- a/advice.h
+++ b/advice.h
@@ -13,5 +13,6 @@ extern int advice_detached_head;
 int git_default_advice_config(const char *var, const char *value);
 
 extern void NORETURN die_resolve_conflict(const char *me);
+extern int error_resolve_conflict(const char *me);
 
 #endif /* ADVICE_H */
-- 
1.7.3.2.504.g59d466


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]