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

Re: [PATCH] prune: quiet ENOENT on missing directories

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 21, 2022, 06:02 UTC
Message-ID
<xmqq5yf8yhe0.fsf@gitster.g>
In-Reply-To
<20221119201213.2398081-1-e@80x24.org>
Eric Wong <e@80x24.org> writes:
> $GIT_DIR/objects/pack may be removed to save inodes in shared
> repositories.  Quiet down prune in cases where either
> $GIT_DIR/objects or $GIT_DIR/objects/pack is non-existent,

Wouldn't setup.c::is_git_directory() say "nope, you do not have a repository there" if you are missing $GIT_DIR/objects? So I suspect that the only case this matters in practice is a missing pack/ subdirectory.

I agree that silently ignoring missing objects/pack/ is perfectly fine, whether we auto-vivify it when we actually create a pack.

> but emit the system error in other cases to help users diagnose
> permissions problems or resource constraints.
OK.
Show 10 quoted lines
> @@ -127,7 +127,9 @@ static void remove_temporary_files(const char *path)
>  
>  	dir = opendir(path);
>  	if (!dir) {
> -		fprintf(stderr, "Unable to open directory %s\n", path);
> +		if (errno != ENOENT)
> +			fprintf(stderr, "Unable to open directory %s: %s\n",
> +				path, strerror(errno));
>  		return;
>  	}

This is called twice, with $GIT_OBJECT_DIRECTORY and its pack subdirectory, as it does not recurse.

This is a tangent, I have to wonder how effective the first call would be, though. When writing a loose object file, we compute its object name first in-core and determine the final filename, create a temporary file in the same directory as the final file, write into it and then finally rename the temporary to the final name. The fan-out $GIT_OBJECT_DIRECTORY/??/ directories may have temporary files left when such a process crashed, but do we create cruft "git prune" should remove in $GIT_OBJECT_DIRECTORY/ itself?

Show 19 quoted lines
> diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh
> index 8ae314af58..d65a5f94b4 100755
> --- a/t/t5304-prune.sh
> +++ b/t/t5304-prune.sh
> @@ -29,6 +29,14 @@ test_expect_success setup '
>  	git gc
>  '
>  
> +test_expect_success 'bare repo prune is quiet without $GIT_DIR/objects/pack' '
> +	git clone -q --shared --template= --bare . bare.git &&
> +	rmdir bare.git/objects/pack &&
> +	git --git-dir=bare.git prune --no-progress 2>prune.err &&
> +	test_must_be_empty prune.err &&
> +	rm -r bare.git prune.err
> +'
> +
>  test_expect_success 'prune stale packs' '
>  	orig_pack=$(echo .git/objects/pack/*.pack) &&
>  	>.git/objects/tmp_1.pack &&
Previous: Eric WongNext: Eric Wong
Message 2 of 10 in “prune: quiet ENOENT on missing directories”
  1. prune: quiet ENOENT on missing directoriesEric Wong, Nov 19, 2022
  2. Junio C HamanoNov 21, 2022
  3. Eric WongNov 21, 2022
  4. Junio C HamanoNov 21, 2022
  5. Junio C HamanoNov 21, 2022
  6. prune: recursively prune objects directoryEric Wong, Nov 22, 2022
  7. Junio C HamanoNov 22, 2022
  8. Eric WongNov 22, 2022
  9. Junio C HamanoNov 22, 2022
  10. Ævar Arnfjörð BjarmasonNov 21, 2022

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.