Web lists-archives.com

Re: [PATCH] gc: introduce an --auto-exit-code option for undoing 3029970275

Junio C Hamano wrote:
> Jonathan Nieder <jrnieder@xxxxxxxxx> writes:

>> Perhaps this reporting could also print the message from a previous
>> run, so you could write:
>> 	git gc --detached-status || exit
>> 	git gc --auto; # perhaps also passing --detach
>> (Names still open for bikeshedding.)
> When the command is given --detached-exit-code/status option, what
> does it do?  Does it perform the "did an earlier run left gc.log?"
> and report the result and nothing else?  In other words, is it a
> pure replacement for "test -e .git/gc.log"?

My intent was the latter.  In other words, in the idiom

	do_something_async &
	... a lot of time passes ...

it is something like the replacement for "wait".

More precisely,

	git gc --detached-status || exit

would mean something like

	if test -e .git/gc.log	# Error from previous gc --detach?
		cat >&2 .git/gc.log	# Report the error.
		exit 1

>                                              Or does it do some of
> the "auto-gc" prep logic like guestimating loose object count and
> have that also in its exit status (e.g. "from the gc.log left
> behind, we know that we failed to reduce loose object count down
> sufficiently after finding there are more than 6700 earlier, but now
> we do not have that many loose object, so there is nothing to
> complain about the presence of gc.log")?

Depending on the use case, a user might want to avoid losing
information about the results of a previous "git gc --detach" run,
even if they no longer apply.  For example, a user might want to
collect the error message for monitoring or later log analysis, to
track down intermittent gc errors that go away on their own.

A separate possible use case might be a

	git gc --needs-auto-gc

command that detects whether an auto gc is needed.  With that, a
caller that only wants to learn about errors if auto gc is needed
could run

	if git gc --needs-auto-gc
		git gc --detached-status || exit

> I am bad at naming myself, but worse at guessing what others meant
> with a new thing that was given a new name whose name is fuzzy,
> so... ;-)

No problem.  I'm mostly trying to tease out more details about the use