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

Re: [PATCH 1/2] object-file: warn on failed unlink

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 4, 2026, 23:00 UTC
Message-ID
<xmqqfqxgyzfo.fsf@gitster.g>
In-Reply-To
<20261103212410.1389988-2-jltobler@gmail.com>
Justin Tobler <jltobler@gmail.com> writes:
Show 40 quoted lines
> When the "files" ODB transaction cleans up a temporary packfile or
> ".keep" lockfile on an error path, any failure to unlink the file is
> silently ignored. A ".keep" file left behind this way prevents its
> packfile from ever being removed by housekeeping.
>
> Use `unlink_or_warn()` instead so that such failures are reported.
>
> Signed-off-by: Justin Tobler <jltobler@gmail.com>
> ---
>  object-file.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/object-file.c b/object-file.c
> index 132aaab6f8..a9800143bd 100644
> --- a/object-file.c
> +++ b/object-file.c
> @@ -823,7 +823,7 @@ static void flush_packfile_transaction(struct odb_transaction_files *transaction
>  	if (state->nr_written == 0) {
>  		close(state->f->fd);
>  		free_hashfile(state->f);
> -		unlink(state->pack_tmp_name);
> +		unlink_or_warn(state->pack_tmp_name);
>  		goto clear_exit;
>  	} else if (state->nr_written == 1) {
>  		finalize_hashfile(state->f, hash, FSYNC_COMPONENT_PACK,
> @@ -1276,13 +1276,13 @@ static int write_pack_lockfile(struct odb_source *source, const char *pack_name,
>  	if (write_in_full(fd, contents.buf, contents.len) < 0) {
>  		ret = error_errno(_("unable to write '%s'"), lock_path.buf);
>  		close(fd);
> -		unlink(lock_path.buf);
> +		unlink_or_warn(lock_path.buf);
>  		goto out;
>  	}
>  
>  	if (close(fd) < 0) {
>  		ret = error_errno(_("unable to close '%s'"), lock_path.buf);
> -		unlink(lock_path.buf);
> +		unlink_or_warn(lock_path.buf);
>  		goto out;
>  	}
Trivially correct.
Previous: Justin ToblerNext: Justin Tobler
Message 3 of 6 in “object-file: small error handling follow-ups”
  1. 0/2 object-file: small error handling follow-upsJustin Tobler, Nov 3, 2026
  2. 1/2 object-file: warn on failed unlinkJustin Tobler, Nov 3, 2026
  3. Junio C HamanoNov 4, 2026
  4. 2/2 object-file: return error on index-pack abnormal exitJustin Tobler, Nov 3, 2026
  5. Junio C HamanoNov 4, 2026
  6. Karthik NayakNov 4, 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.