]> git.ipfire.org Git - thirdparty/git.git/commit - sequencer.c
prepare the builtins for a libified merge_recursive()
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Tue, 26 Jul 2016 16:06:02 +0000 (18:06 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 26 Jul 2016 18:13:44 +0000 (11:13 -0700)
commitf241ff0d0a9ddb84b2f673a1b7a92fea0d6add3a
tree31a63632ae8070df7b557b0d6ec2e7ea416c825f
parentf8d83fb66c653fff0541067a0b5a0821d3f548f9
prepare the builtins for a libified merge_recursive()

Previously, callers of merge_trees() or merge_recursive() expected that
code to die() with an error message. This used to be okay because we
called those commands from scripts, and had a chance to print out a
message in case the command failed fatally (read: with exit code 128).

As scripting incurs its own set of problems (portability, speed,
idiosyncrasies of different shells, limited data structures leading to
inefficient code), we are converting more and more of these scripts into
builtins, using library functions directly.

We already tried to use merge_recursive() directly in the builtin
git-am, for example. Unfortunately, we had to roll it back temporarily
because some of the code in merge-recursive.c still deemed it okay to
call die(), when the builtin am code really wanted to print out a useful
advice after the merge failed fatally. In the next commits, we want to
fix that.

The code touched by this commit expected merge_trees() to die() with
some useful message when there is an error condition, but merge_trees()
is going to be improved by converting all die() calls to return error()
instead (i.e. return value -1 after printing out the message as before),
so that the caller can react more flexibly.

This is a step to prepare for the version of merge_trees() that no
longer dies,  even if we just imitate the previous behavior by calling
exit(128): this is what callers of e.g. `git merge` have come to expect.

Note that the callers of the sequencer (revert and cherry-pick) already
fail fast even for the return value -1; The only difference is that they
now get a chance to say "<command> failed".

A caller of merge_trees() might want handle error messages themselves
(or even suppress them). As this patch is already complex enough, we
leave that change for a later patch.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/checkout.c
builtin/merge.c
sequencer.c