Re: [PATCH v2 4/5] Make sequencer abort safer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Dec 9, 2016 at 8:01 PM, Stephan Beyer <s-beyer@xxxxxxx> 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.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]