git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jeff King <peff@peff.net>
Date
Dec 10, 2016, 20:04 UTC
Message-ID
<20161210200437.ijmahia6e6xifhk6@sigill.intra.peff.net>
In-Reply-To
<CAP8UFD0hCke_W6C=gOHinpj+G3WCFKf7Cji6zREDer4RUBxKxg@mail.gmail.com>
On Sat, Dec 10, 2016 at 08:56:26PM +0100, Christian Couder wrote:
Show 24 quoted lines
> > +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());
>        }

Is there any point in calling strbuf_release() if we're about to die anyway? I could see it if it were "return error()", but it's normal in our code base for die() to be abrupt.

-Peff
Previous: Christian CouderNext: Stephan Beyer
Message 12 of 18 in “am: Fix filename in safe_to_abort() error message”
  1. 1/5 am: Fix filename in safe_to_abort() error messageStephan Beyer, Dec 7, 2016
  2. 4/5 Make sequencer abort saferStephan Beyer, Dec 7, 2016
  3. Johannes SchindelinDec 8, 2016
  4. Junio C HamanoDec 8, 2016
  5. Stephan BeyerDec 8, 2016
  6. Junio C HamanoDec 9, 2016
  7. 1/5 am: Fix filename in safe_to_abort() error messageStephan Beyer, Dec 9, 2016
  8. 3/5 Add test that cherry-pick --abort does not unsafely change HEADStephan Beyer, Dec 9, 2016
  9. 2/5 am: Change safe_to_abort()'s not rewinding error into a warningStephan Beyer, Dec 9, 2016
  10. 4/5 Make sequencer abort saferStephan Beyer, Dec 9, 2016
  11. Christian CouderDec 10, 2016
  12. Jeff KingDec 10, 2016
  13. Stephan BeyerDec 10, 2016
  14. 5/5 sequencer: Remove useless get_dir() functionStephan Beyer, Dec 9, 2016
  15. 2/5 am: Change safe_to_abort()'s not rewinding error into a warningStephan Beyer, Dec 7, 2016
  16. 3/5 Add test that cherry-pick --abort does not unsafely change HEADStephan Beyer, Dec 7, 2016
  17. 5/5 sequencer: Remove useless get_dir() functionStephan Beyer, Dec 7, 2016
  18. Paul TanDec 8, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.