From: Christian Couder Date: Sat, 10 Dec 2016 19:56:26 GMT Subject: Re: [PATCH v2 4/5] Make sequencer abort safer Message-ID: In-Reply-To: <20161209190111.9571-4-s-beyer@gmx.net> On Fri, Dec 9, 2016 at 8:01 PM, Stephan Beyer wrote: [...] > +static int rollback_is_safe(void) > +{ > + struct strbuf sb = STRBUF_INIT; > + struct object_id expected_head, actual_head; > + > + if (strbuf_read_file(&sb, git_path_abort_safety_file(), 0) >= 0) { > + strbuf_trim(&sb); > + if (get_oid_hex(sb.buf, &expected_head)) { > + strbuf_release(&sb); > + die(_("could not parse %s"), git_path_abort_safety_file()); > + } > + strbuf_release(&sb); > + } Maybe the following is a bit simpler: if (strbuf_read_file(&sb, git_path_abort_safety_file(), 0) >= 0) { int res; strbuf_trim(&sb); res = get_oid_hex(sb.buf, &expected_head); strbuf_release(&sb); if (res) die(_("could not parse %s"), git_path_abort_safety_file()); } Thanks, Christian.