aboutsummaryrefslogtreecommitdiff
path: root/unpack-trees.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-09-03 22:23:49 -0700
committerJunio C Hamano <gitster@pobox.com>2010-09-03 22:23:49 -0700
commitc208e05bd9880028c980fafbc5dda3d17a603ac1 (patch)
tree25d587aacf885345b2b001bc006ac3871b5c7a4b /unpack-trees.c
parentf92d62ec4ead67109418483b65aaf158b7462121 (diff)
parentc5978a507ca20b12008724f78237784193fb9489 (diff)
downloadgit-c208e05bd9880028c980fafbc5dda3d17a603ac1.tar.gz
git-c208e05bd9880028c980fafbc5dda3d17a603ac1.tar.xz
Merge branch 'dg/local-mod-error-messages'
* dg/local-mod-error-messages: t7609-merge-co-error-msgs: test non-fast forward case too. Move "show_all_errors = 1" to setup_unpack_trees_porcelain() setup_unpack_trees_porcelain: take the whole options struct as parameter Move set_porcelain_error_msgs to unpack-trees.c and rename it Conflicts: merge-recursive.c
Diffstat (limited to 'unpack-trees.c')
-rw-r--r--unpack-trees.c56
1 files changed, 49 insertions, 7 deletions
diff --git a/unpack-trees.c b/unpack-trees.c
index 3c7a7c9cd..803445aa7 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -14,7 +14,7 @@
* read-tree. Non-scripted Porcelain is not required to use these messages
* and in fact are encouraged to reword them to better suit their particular
* situation better. See how "git checkout" and "git merge" replaces
- * them using set_porcelain_error_msgs(), for example.
+ * them using setup_unpack_trees_porcelain(), for example.
*/
const char *unpack_plumbing_errors[NB_UNPACK_TREES_ERROR_TYPES] = {
/* ERROR_WOULD_OVERWRITE */
@@ -50,6 +50,54 @@ const char *unpack_plumbing_errors[NB_UNPACK_TREES_ERROR_TYPES] = {
? ((o)->msgs[(type)]) \
: (unpack_plumbing_errors[(type)]) )
+void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
+ const char *cmd)
+{
+ const char **msgs = opts->msgs;
+ const char *msg;
+ char *tmp;
+ const char *cmd2 = strcmp(cmd, "checkout") ? cmd : "switch branches";
+ if (advice_commit_before_merge)
+ msg = "Your local changes to the following files would be overwritten by %s:\n%%s"
+ "Please, commit your changes or stash them before you can %s.";
+ else
+ msg = "Your local changes to the following files would be overwritten by %s:\n%%s";
+ tmp = xmalloc(strlen(msg) + strlen(cmd) + strlen(cmd2) - 2);
+ sprintf(tmp, msg, cmd, cmd2);
+ msgs[ERROR_WOULD_OVERWRITE] = tmp;
+ msgs[ERROR_NOT_UPTODATE_FILE] = tmp;
+
+ msgs[ERROR_NOT_UPTODATE_DIR] =
+ "Updating the following directories would lose untracked files in it:\n%s";
+
+ if (advice_commit_before_merge)
+ msg = "The following untracked working tree files would be %s by %s:\n%%s"
+ "Please move or remove them before you can %s.";
+ else
+ msg = "The following untracked working tree files would be %s by %s:\n%%s";
+ tmp = xmalloc(strlen(msg) + strlen(cmd) + strlen("removed") + strlen(cmd2) - 4);
+ sprintf(tmp, msg, "removed", cmd, cmd2);
+ msgs[ERROR_WOULD_LOSE_UNTRACKED_REMOVED] = tmp;
+ tmp = xmalloc(strlen(msg) + strlen(cmd) + strlen("overwritten") + strlen(cmd2) - 4);
+ sprintf(tmp, msg, "overwritten", cmd, cmd2);
+ msgs[ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN] = tmp;
+
+ /*
+ * Special case: ERROR_BIND_OVERLAP refers to a pair of paths, we
+ * cannot easily display it as a list.
+ */
+ msgs[ERROR_BIND_OVERLAP] = "Entry '%s' overlaps with '%s'. Cannot bind.";
+
+ msgs[ERROR_SPARSE_NOT_UPTODATE_FILE] =
+ "Cannot update sparse checkout: the following entries are not up-to-date:\n%s";
+ msgs[ERROR_WOULD_LOSE_ORPHANED_OVERWRITTEN] =
+ "The following Working tree files would be overwritten by sparse checkout update:\n%s";
+ msgs[ERROR_WOULD_LOSE_ORPHANED_REMOVED] =
+ "The following Working tree files would be removed by sparse checkout update:\n%s";
+
+ opts->show_all_errors = 1;
+}
+
static void add_entry(struct unpack_trees_options *o, struct cache_entry *ce,
unsigned int set, unsigned int clear)
{
@@ -77,12 +125,6 @@ static int add_rejected_path(struct unpack_trees_options *o,
const char *path)
{
struct rejected_paths_list *newentry;
- int porcelain = o && (o)->msgs[e];
- /*
- * simply display the given error message if in plumbing mode
- */
- if (!porcelain)
- o->show_all_errors = 0;
if (!o->show_all_errors)
return error(ERRORMSG(o, e), path);