git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ramkumar Ramachandra <artagnon@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git List <git@vger.kernel.org>,
	Jonathan Nieder <jrnieder@gmail.com>,
	Christian Couder <chriscool@tuxfamily.org>,
	Daniel Barkalow <barkalow@iabervon.org>,
	Jeff King <peff@peff.net>
Subject: [PATCH 01/18] advice: Introduce error_resolve_conflict
Date: Mon,  1 Aug 2011 23:36:48 +0530	[thread overview]
Message-ID: <1312222025-28453-2-git-send-email-artagnon@gmail.com> (raw)
In-Reply-To: <1312222025-28453-1-git-send-email-artagnon@gmail.com>

Enable future callers to report a conflict and not die immediately by
introducing a new function called error_resolve_conflict.
Re-implement die_resolve_conflict as a call to error_resolve_conflict
followed by a call to die.  Consequently, the message printed by
die_resolve_conflict changes from

  fatal: 'commit' is not possible because you have unmerged files.
         Please, fix them up in the work tree ...
         ...

to

  error: 'commit' is not possible because you have unmerged files.
  hint: Fix them up in the work tree ...
  hint: ...
  fatal: Exiting because of an unresolved conflict.

Hints are printed using the same advise function introduced in
v1.7.3-rc0~26^2~3 (Introduce advise() to print hints, 2010-08-11).

Inspired-by: Christian Couder <chistian.couder@gmail.com>
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 advice.c         |   31 ++++++++++++++++++++++++-------
 advice.h         |    3 ++-
 builtin/revert.c |    9 ---------
 3 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/advice.c b/advice.c
index 0be4b5f..e02e632 100644
--- 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.");
 }
diff --git a/advice.h b/advice.h
index 3244ebb..e5d0af7 100644
--- a/advice.h
+++ b/advice.h
@@ -11,7 +11,8 @@ extern int advice_implicit_identity;
 extern int advice_detached_head;
 
 int git_default_advice_config(const char *var, const char *value);
-
+void advise(const char *advice, ...);
+int error_resolve_conflict(const char *me);
 extern void NORETURN die_resolve_conflict(const char *me);
 
 #endif /* ADVICE_H */
diff --git a/builtin/revert.c b/builtin/revert.c
index 1f27c63..2df3f3b 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -214,15 +214,6 @@ static void write_cherry_pick_head(void)
 	strbuf_release(&buf);
 }
 
-static void advise(const char *advice, ...)
-{
-	va_list params;
-
-	va_start(params, advice);
-	vreportf("hint: ", advice, params);
-	va_end(params);
-}
-
 static void print_advice(void)
 {
 	char *msg = getenv("GIT_CHERRY_PICK_HELP");
-- 
1.7.4.rc1.7.g2cf08.dirty

  reply	other threads:[~2011-08-01 18:11 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-01 18:06 [PATCH v5 00/18] Sequencer for inclusion Ramkumar Ramachandra
2011-08-01 18:06 ` Ramkumar Ramachandra [this message]
2011-08-01 18:06 ` [PATCH 02/18] config: Introduce functions to write non-standard file Ramkumar Ramachandra
2011-08-01 18:06 ` [PATCH 03/18] revert: Simplify and inline add_message_to_msg Ramkumar Ramachandra
2011-08-01 18:06 ` [PATCH 04/18] revert: Don't check lone argument in get_encoding Ramkumar Ramachandra
2011-08-01 18:06 ` [PATCH 05/18] revert: Rename no_replay to record_origin Ramkumar Ramachandra
2011-08-01 18:06 ` [PATCH 06/18] revert: Eliminate global "commit" variable Ramkumar Ramachandra
2011-08-01 18:06 ` [PATCH 07/18] revert: Introduce struct to keep command-line options Ramkumar Ramachandra
2011-08-01 18:06 ` [PATCH 08/18] revert: Separate cmdline parsing from functional code Ramkumar Ramachandra
2011-08-01 18:06 ` [PATCH 09/18] revert: Don't create invalid replay_opts in parse_args Ramkumar Ramachandra
2011-08-02  6:28   ` Christian Couder
2011-08-02  6:41     ` Christian Couder
2011-08-04  9:34       ` Ramkumar Ramachandra
2011-08-01 18:06 ` [PATCH 10/18] revert: Save data for continuing after conflict resolution Ramkumar Ramachandra
2011-08-01 18:06 ` [PATCH 11/18] revert: Save command-line options for continuing operation Ramkumar Ramachandra
2011-08-04  4:05   ` Christian Couder
2011-08-04  9:25     ` Ramkumar Ramachandra
2011-08-01 18:06 ` [PATCH 12/18] revert: Make pick_commits functionally act on a commit list Ramkumar Ramachandra
2011-08-01 18:07 ` [PATCH 13/18] revert: Introduce --reset to remove sequencer state Ramkumar Ramachandra
2011-08-01 18:07 ` [PATCH 14/18] reset: Make reset remove the " Ramkumar Ramachandra
2011-08-01 18:07 ` [PATCH 15/18] revert: Remove sequencer state when no commits are pending Ramkumar Ramachandra
2011-08-01 18:07 ` [PATCH 16/18] revert: Don't implicitly stomp pending sequencer operation Ramkumar Ramachandra
2011-08-01 18:07 ` [PATCH 17/18] revert: Introduce --continue to continue the operation Ramkumar Ramachandra
2011-08-01 18:31   ` Ramkumar Ramachandra
2011-08-02  2:36   ` Christian Couder
2011-08-02  2:47     ` Christian Couder
2011-08-02  2:51       ` Christian Couder
2011-08-02  4:41         ` Ramkumar Ramachandra
2011-08-04 10:02         ` Ramkumar Ramachandra
2011-08-02  6:24   ` Christian Couder
2011-08-04  4:57   ` Christian Couder
2011-08-04  9:22     ` Ramkumar Ramachandra
2011-08-01 18:07 ` [PATCH 18/18] revert: Propagate errors upwards from do_pick_commit Ramkumar Ramachandra
  -- strict thread matches above, loose matches on Subject: below --
2011-08-04 10:38 [PATCH 00/18] Sequencer for inclusion v6 Ramkumar Ramachandra
2011-08-04 10:38 ` [PATCH 01/18] advice: Introduce error_resolve_conflict Ramkumar Ramachandra
2011-07-28 16:52 [PATCH 00/18] Sequencer for inclusion v4 Ramkumar Ramachandra
2011-07-28 16:52 ` [PATCH 01/18] advice: Introduce error_resolve_conflict Ramkumar Ramachandra
2011-07-27  3:18 [PATCH 00/18] GSoC update: Sequencer for inclusion v3 Ramkumar Ramachandra
2011-07-27  3:18 ` [PATCH 01/18] advice: Introduce error_resolve_conflict Ramkumar Ramachandra
2011-07-19 17:17 [GSoC update] Sequencer for inclusion v2 Ramkumar Ramachandra
2011-07-19 17:17 ` [PATCH 01/18] advice: Introduce error_resolve_conflict Ramkumar Ramachandra
2011-07-21 15:35   ` Phil Hord
2011-07-22 22:35     ` Jeff King
2011-07-24 10:23       ` Ramkumar Ramachandra
2011-07-24 18:15       ` Junio C Hamano
2011-07-25 21:17         ` Phil Hord

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1312222025-28453-2-git-send-email-artagnon@gmail.com \
    --to=artagnon@gmail.com \
    --cc=barkalow@iabervon.org \
    --cc=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).