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

Re: [PATCH] prune: mark rebase autostash and orig-head as reachable

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Feb 8, 2024, 17:25 UTC
Message-ID
<CAPig+cRASFkTD6=YumZJKv7XJjr1asxKB-mAyBFox8tuwmNnFw@mail.gmail.com>
In-Reply-To
<pull.1656.git.1707411636382.gitgitgadget@gmail.com>

On Thu, Feb 8, 2024 at 12:00 PM Phillip Wood via GitGitGadget <gitgitgadget@gmail.com> wrote:

Show 32 quoted lines
> Rebase records the oid of HEAD before rebasing and the commit created by
> "--autostash" in files in the rebase state directory. This means that
> the autostash commit is never reachable from any ref or reflog and when
> rebasing a detached HEAD the original HEAD can become unreachable if the
> user expires HEAD's the reflog while the rebase is running. Fix this by
> reading the relevant files when marking reachable commits.
>
> Note that it is possible for the commit recorded in
> .git/rebase-merge/amend to be unreachable but pruning that object does
> not affect the operation of "git rebase --continue" as we're only
> interested in the object id, not in the object itself.
>
> Reported-by: Orgad Shaneh <orgads@gmail.com>
> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
> ---
> diff --git a/reachable.c b/reachable.c
> @@ -30,6 +31,53 @@ static void update_progress(struct connectivity_progress *cp)
> +static int add_one_file(const char *path, struct rev_info *revs)
> +{
> +       struct strbuf buf = STRBUF_INIT;
> +
> +       if (!read_oneliner(&buf, path, READ_ONELINER_SKIP_IF_EMPTY)) {
> +               strbuf_release(&buf);
> +               return 0;
> +       }
> +       strbuf_trim(&buf);
> +       if (!get_oid_hex(buf.buf, &oid)) {
> +               object = parse_object_or_die(&oid, buf.buf);
> +               add_pending_object(revs, object, "");
> +       }
> +       return 0;
> +}
Is this leaking the strbuf? Should the function instead end with:
    strbuf_release(&buf);
    return 0;

Also, what is the significance of the return value of this function? All code paths seem to be returning 0 unconditionally, and the caller ignores the return value.

> +/* Mark objects recored in rebase state files as reachable. */
s/recored/recorded/
Previous: Phillip Wood via GitGitGadgetNext: Phillip Wood
Message 2 of 8 in “prune: mark rebase autostash and orig-head as reachable”
  1. prune: mark rebase autostash and orig-head as reachablePhillip Wood via GitGitGadget, Feb 8, 2024
  2. Eric SunshineFeb 8, 2024
  3. Phillip WoodFeb 9, 2024
  4. Junio C HamanoFeb 8, 2024
  5. Phillip WoodFeb 9, 2024
  6. Phil HordMay 14, 2024
  7. prune: mark rebase autostash and orig-head as reachablePhillip Wood via GitGitGadget, Feb 9, 2024
  8. Junio C HamanoFeb 9, 2024

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.