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

Re: [PATCH v8 1/7] builtin/replay: extract core logic to replay revisions

From
D. Ben Knoble <ben.knoble@gmail.com>
Date
Jan 7, 2026, 17:53 UTC
Message-ID
<CALnO6CAMX8K6oNzTmcg_stqkU2FCUepdvNfPTGaA-jSaTMzj0g@mail.gmail.com>
In-Reply-To
<20260107-b4-pks-history-builtin-v8-1-18e9779e3a26@pks.im>
On Wed, Jan 7, 2026 at 5:10 AM Patrick Steinhardt <ps@pks.im> wrote:
> diff --git a/builtin/replay.c b/builtin/replay.c
> index 1960bbbee8..d7523fdbc2 100644
> --- a/builtin/replay.c
> +++ b/builtin/replay.c
Show 27 quoted lines
> @@ -517,24 +568,13 @@ int cmd_replay(int argc,
>                 }
>         }
>
> -       merge_finalize(&merge_opt, &result);
> -       kh_destroy_oid_map(replayed_commits);
> -       if (update_refs) {
> -               strset_clear(update_refs);
> -               free(update_refs);
> -       }
> -       ret = result.clean;
> -
>  cleanup:
>         if (transaction)
>                 ref_transaction_free(transaction);
> +       replay_ref_updates_release(&updates);
>         strbuf_release(&transaction_err);
>         strbuf_release(&reflog_msg);
>         release_revisions(&revs);
> -       free(advance_name);
>
> -       /* Return */
> -       if (ret < 0)
> -               exit(128);
> -       return ret ? 0 : 1;
> +       return ret ? 1 : 0;
>  }

I tried checking the tree after applying this patch, too, and it looks to me like the return code flipped here? In particular, some callsites that assign ret = error(…) are untouched, so I don't think the meaning of ret has changed. Now, error() returns -1, which is truthy, so returning 1 instead of 0 makes sense here… was this a bug in the original? I can't quite tell, but that seems unlikely.

The original blames to 81613be31e (replay: make it a minimal server side command, 2023-11-24), but there it seems like ret is "result.clean" (except for some error cases? which are handled by the negative conditional), and "result.clean == 0" is the success indicator (in other words, _falsey_ means success here).

So overall this flip _seems_ correct, but it was hard for me to follow at a glance. Hm.

-- 
D. Ben Knoble
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 3 of 18 in “Introduce git-history(1) command for easy history editing”
  1. 0/7 Introduce git-history(1) command for easy history editingPatrick Steinhardt, Jan 7, 2026
  2. 1/7 builtin/replay: extract core logic to replay revisionsPatrick Steinhardt, Jan 7, 2026
  3. D. Ben KnobleJan 7, 2026
  4. Patrick SteinhardtJan 9, 2026
  5. 2/7 builtin/replay: move core logic into "libgit.a"Patrick Steinhardt, Jan 7, 2026
  6. 3/7 replay: small set of cleanupsPatrick Steinhardt, Jan 7, 2026
  7. 4/7 replay: yield the object ID of the final rewritten commitPatrick Steinhardt, Jan 7, 2026
  8. 5/7 wt-status: provide function to expose status for treesPatrick Steinhardt, Jan 7, 2026
  9. 6/7 builtin: add new "history" commandPatrick Steinhardt, Jan 7, 2026
  10. 7/7 builtin/history: implement "reword" subcommandPatrick Steinhardt, Jan 7, 2026
  11. D. Ben KnobleJan 7, 2026
  12. Patrick SteinhardtJan 9, 2026
  13. D. Ben KnobleJan 9, 2026
  14. Elijah NewrenJan 10, 2026
  15. Patrick SteinhardtJan 12, 2026
  16. D. Ben KnobleJan 7, 2026
  17. Patrick SteinhardtJan 9, 2026
  18. D. Ben KnobleJan 9, 2026

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.