Re: [PATCH 1/2] sequencer: factor out rewrite_file()
From: Simon Ruderich <hidden>
Date: 2017-11-03 10:32:55
On Wed, Nov 01, 2017 at 06:16:18PM -0400, Jeff King wrote:
On Wed, Nov 01, 2017 at 10:46:14PM +0100, Johannes Schindelin wrote:quoted
I spent substantial time on making the sequencer code libified (it was far from it). That die() call may look okay now, but it is not at all okay if we want to make Git's source code cleaner and more reusable. And I want to. So my suggestion is to clean up write_file_buf() first, to stop behaving like a drunk lemming, and to return an error value already, and only then use it in sequencer.c.That would be fine with me, too.
I tried looking into this by adding a new write_file_buf_gently()
(or maybe renaming write_file_buf to write_file_buf_or_die) and
using it from write_file_buf() but I don't know the proper way to
handle the error-case in write_file_buf(). Just calling
die("write_file_buf") feels ugly, as the real error was already
printed on screen by error_errno() and I didn't find any function
to just exit without writing a message (which still respects
die_routine). Suggestions welcome.
Regards
Simon
--
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9