path: root/unpack-trees.h
diff options
authorJunio C Hamano <>2008-05-17 19:03:49 (GMT)
committerJunio C Hamano <>2008-05-20 02:30:13 (GMT)
commit8ccba008ee3e0b0582e64cb23ae4ebf734b9f75b (patch)
tree25b428e7427b42f3aa7cdb94d6f1f3638fe5d307 /unpack-trees.h
parent377d9c409ffe0f0d994b929aeb94716139207b9d (diff)
unpack-trees: allow Porcelain to give different error messages
The plumbing output is sacred as it is an API. We _could_ change it if it is broken in such a way that it cannot convey necessary information fully, but we just do not _reword_ for the sake of rewording. If somebody does not like it, s/he is complaining too late. S/he should have been here in early May 2005 and make the language used by the API closer to what humans read. S/he wasn't here. Too bad, and it is too late. And people who complain should look at a bigger picture. Look at what was suggested by one of them and think for five seconds: $ git checkout mytopic -fatal: Entry 'frotz' not uptodate. Cannot merge. +fatal: Entry 'frotz' has local changes. Cannot merge. If you do not see something wrong with this output, your brain has already been rotten with use of git for too long a time. Nobody asked us to "merge" but why are we talking about "Cannot merge"? This patch introduces a mechanism to allow Porcelains to specify messages that are different from the ones that is given by the underlying plumbing implementation of read-tree, so that we can reword the message Porcelains give without disrupting the output from the plumbing. $ git-checkout pu error: You have local changes to 'Makefile'; cannot switch branches. There are other places that ask unpack_trees() to n-way merge, detect issues and let it issue error message on its own, but I did this as a demonstration and replaced only one message. Yes I know about C99 structure initializers. I'd love to use them but we try to be nice to compilers without it. Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'unpack-trees.h')
1 files changed, 9 insertions, 0 deletions
diff --git a/unpack-trees.h b/unpack-trees.h
index d436d6c..94e5672 100644
--- a/unpack-trees.h
+++ b/unpack-trees.h
@@ -8,6 +8,14 @@ struct unpack_trees_options;
typedef int (*merge_fn_t)(struct cache_entry **src,
struct unpack_trees_options *options);
+struct unpack_trees_error_msgs {
+ const char *would_overwrite;
+ const char *not_uptodate_file;
+ const char *not_uptodate_dir;
+ const char *would_lose_untracked;
+ const char *bind_overlap;
struct unpack_trees_options {
unsigned int reset:1,
@@ -23,6 +31,7 @@ struct unpack_trees_options {
int pos;
struct dir_struct *dir;
merge_fn_t fn;
+ struct unpack_trees_error_msgs msgs;
int head_idx;
int merge_size;