Merge branch 'tj/maint-imap-send-remove-unused'
[gitweb.git] / builtin / revert.c
index 9b9b2e57475ad201719d5d590c9e1be2d4d43401..1ea525c10e4c00b66006bf46465ebd490823f25f 100644 (file)
@@ -931,8 +931,10 @@ static int sequencer_rollback(struct replay_opts *opts)
        if (strbuf_getline(&buf, f, '\n')) {
                error(_("cannot read %s: %s"), filename, ferror(f) ?
                        strerror(errno) : _("unexpected end of file"));
+               fclose(f);
                goto fail;
        }
+       fclose(f);
        if (get_sha1_hex(buf.buf, sha1) || buf.buf[40] != '\0') {
                error(_("stored pre-cherry-pick HEAD file '%s' is corrupt"),
                        filename);
@@ -940,12 +942,11 @@ static int sequencer_rollback(struct replay_opts *opts)
        }
        if (reset_for_rollback(sha1))
                goto fail;
+       remove_sequencer_state(1);
        strbuf_release(&buf);
-       fclose(f);
        return 0;
 fail:
        strbuf_release(&buf);
-       fclose(f);
        return -1;
 }