]> git.ipfire.org Git - thirdparty/git.git/commit - merge-recursive.c
merge-recursive: handle return values indicating errors
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Tue, 26 Jul 2016 16:06:21 +0000 (18:06 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 26 Jul 2016 18:13:44 +0000 (11:13 -0700)
commit75456f96d4bd201f815484e9d2ff2ae429305ab5
tree4d3df45bdb277285c96077d7aa6b87d5d45170a7
parentfbc87eb54409b5c7b080f1c23b767daefc9d6ede
merge-recursive: handle return values indicating errors

We are about to libify the recursive merge machinery, where we only
die() in case of a bug or memory contention. To that end, we must heed
negative return values as indicating errors.

This requires our functions to be careful to pass through error
conditions in call chains, and for quite a few functions this means
that they have to return values to begin with.

The next step will be to convert the places where we currently die() to
return negative values (read: -1) instead.

Note that we ignore errors reported by make_room_for_path(), consistent
with the previous behavior (update_file_flags() used the return value of
make_room_for_path() only to indicate an early return, but not a fatal
error): if the error is really a fatal error, we will notice later; If
not, it was not that serious a problem to begin with. (Witnesses in
favor of this reasoning are t4151-am-abort and t7610-mergetool, which
would start failing if we stopped on errors reported by
make_room_for_path()).

Also note: while this patch makes the code slightly less readable in
update_file_flags() (we introduce a new "goto free_buf;" instead of
an explicit "free(buf); return;"), it is a preparatory change for
the next patch where we will convert all of the die() calls in the same
function to go through the free_buf return path instead.

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