summaryrefslogtreecommitdiff
path: root/builtin-checkout.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-05-17 19:03:49 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-05-20 02:30:13 (GMT)
commit8ccba008ee3e0b0582e64cb23ae4ebf734b9f75b (patch)
tree25b428e7427b42f3aa7cdb94d6f1f3638fe5d307 /builtin-checkout.c
parent377d9c409ffe0f0d994b929aeb94716139207b9d (diff)
downloadgit-8ccba008ee3e0b0582e64cb23ae4ebf734b9f75b.zip
git-8ccba008ee3e0b0582e64cb23ae4ebf734b9f75b.tar.gz
git-8ccba008ee3e0b0582e64cb23ae4ebf734b9f75b.tar.bz2
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 <gitster@pobox.com>
Diffstat (limited to 'builtin-checkout.c')
-rw-r--r--builtin-checkout.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/builtin-checkout.c b/builtin-checkout.c
index 10ec137..83da7ca 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -236,6 +236,8 @@ static int merge_working_tree(struct checkout_opts *opts,
topts.src_index = &the_index;
topts.dst_index = &the_index;
+ topts.msgs.not_uptodate_file = "You have local changes to '%s'; cannot switch branches.";
+
refresh_cache(REFRESH_QUIET);
if (unmerged_cache()) {