git/list[1] front-page[2] threads[3] people[4] search[5] about
wed 2026-10-07 17:33 UTC

Re: [GSoC PATCH] backfill: error out when HEAD cannot be parsed

From
Tian Yuchen <cat@malon.dev>
Date
Mar 30, 2026, 17:41 UTC
Message-ID
<0af26f29-5643-4ff2-b659-ae0fa234161a@malon.dev>
In-Reply-To
<20260329183603.538241-1-vikingtc4@gmail.com>
On 3/30/26 02:36, Trieu Huynh wrote:
Show 12 quoted lines
> handle_revision_arg() returns non-zero on failure, but do_backfill()
> ignored the return value. On an empty repo with no commits, HEAD is
> unborn and handle_revision_arg() fails, but backfill silently
> continues with an empty revision walk and exits zero, looks like
> success but did nothing.
> 
> Check the return value and propagate the error, consistent with
> how builtin/pack-objects.c handles handle_revision_arg() failures.
> 
> Add a test to verify that backfill on an empty repository fails
> with a clear error message.
> 

Aside from the minor flaws Karthik mentioned, I think this commit message is spot on.

Show 18 quoted lines
> Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
> ---
>   builtin/backfill.c  | 3 ++-
>   t/t5620-backfill.sh | 6 ++++++
>   2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/builtin/backfill.c b/builtin/backfill.c
> index 27a301f9b2..4b2db94173 100644
> --- a/builtin/backfill.c
> +++ b/builtin/backfill.c
> @@ -96,7 +96,8 @@ static int do_backfill(struct backfill_context *ctx)
>   	}
>   
>   	repo_init_revisions(ctx->repo, &revs, "");
> -	handle_revision_arg("HEAD", &revs, 0, 0);
> +	if (handle_revision_arg("HEAD", &revs, 0, 0))
> +		return error(_("unable to parse HEAD revision"));
>  
Looks good to me.
Show 14 quoted lines
>   	info.blobs = 1;
>   	info.tags = info.commits = info.trees = 0;
> diff --git a/t/t5620-backfill.sh b/t/t5620-backfill.sh
> index ff67e8ecea..91b5115732 100755
> --- a/t/t5620-backfill.sh
> +++ b/t/t5620-backfill.sh
> @@ -101,6 +101,12 @@ test_expect_success 'backfill no flag on non-TTY is silent' '
>   	test_grep ! "Downloading batches" err
>   '
>   
> +test_expect_success 'backfill on empty repo fails gracefully' '
> +	git init empty-repo &&
> +	test_must_fail git -C empty-repo backfill 2>err &&
> +	grep "unable to parse HEAD" err

Remember your last patch? Wouldn't it be better to use 'test_grep' here? It's easy to see that the original code uses 'test_grep' (a few lines above):

	>   	test_grep ! "Downloading batches" err
Wouldn't it be better to maintain consistency? ;)
Show 5 quoted lines
> +'
> +
>   test_expect_success 'backfill --sparse without sparse-checkout fails' '
>   	git init not-sparse &&
>   	test_must_fail git -C not-sparse backfill --sparse 2>err &&
Regards,
Yuchen
Previous: Karthik NayakNext: Trieu Huynh
Message 3 of 4 in “backfill: error out when HEAD cannot be parsed”
  1. backfill: error out when HEAD cannot be parsedTrieu Huynh, Mar 29, 2026
  2. Karthik NayakMar 30, 2026
  3. Tian YuchenMar 30, 2026
  4. Trieu HuynhMar 30, 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.