]> git.ipfire.org Git - thirdparty/git.git/commit - unpack-trees.c
unpack-trees: allow Porcelain to give different error messages
authorJunio C Hamano <gitster@pobox.com>
Sat, 17 May 2008 19:03:49 +0000 (12:03 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 20 May 2008 02:30:13 +0000 (19:30 -0700)
commit8ccba008ee3e0b0582e64cb23ae4ebf734b9f75b
tree25b428e7427b42f3aa7cdb94d6f1f3638fe5d307
parent377d9c409ffe0f0d994b929aeb94716139207b9d
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>
builtin-checkout.c
unpack-trees.c
unpack-trees.h