Revision 2057d75038541cd16debb1c55f3f897fd244965c authored by Derrick Stolee on 17 September 2020, 18:11:42 UTC, committed by Junio C Hamano on 17 September 2020, 18:30:04 UTC
The 'gc' builtin is our current entrypoint for automatically maintaining
a repository. This one tool does many operations, such as repacking the
repository, packing refs, and rewriting the commit-graph file. The name
implies it performs "garbage collection" which means several different
things, and some users may not want to use this operation that rewrites
the entire object database.

Create a new 'maintenance' builtin that will become a more general-
purpose command. To start, it will only support the 'run' subcommand,
but will later expand to add subcommands for scheduling maintenance in
the background.

For now, the 'maintenance' builtin is a thin shim over the 'gc' builtin.
In fact, the only option is the '--auto' toggle, which is handed
directly to the 'gc' builtin. The current change is isolated to this
simple operation to prevent more interesting logic from being lost in
all of the boilerplate of adding a new builtin.

Use existing builtin/gc.c file because we want to share code between the
two builtins. It is possible that we will have 'maintenance' replace the
'gc' builtin entirely at some point, leaving 'git gc' as an alias for
some specific arguments to 'git maintenance run'.

Create a new test_subcommand helper that allows us to test if a certain
subcommand was run. It requires storing the GIT_TRACE2_EVENT logs in a
file. A negation mode is available that will be used in later tests.

Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 887952b
Raw File
extract-trash-dirs.sh
#!/bin/sh

error () {
	echo >&2 "error: $@"
	exit 1
}

find_embedded_trash () {
	while read -r line
	do
		case "$line" in
		*Start\ of\ trash\ directory\ of\ \'t[0-9][0-9][0-9][0-9]-*\':*)
			test_name="${line#*\'}"
			test_name="${test_name%\'*}"

			return 0
		esac
	done

	return 1
}

extract_embedded_trash () {
	while read -r line
	do
		case "$line" in
		*End\ of\ trash\ directory\ of\ \'$test_name\'*)
			return
			;;
		*)
			printf '%s\n' "$line"
			;;
		esac
	done

	error "unexpected end of input"
}

# Raw logs from Linux build jobs have CRLF line endings, while OSX
# build jobs mostly have CRCRLF, except an odd line every now and
# then that has CRCRCRLF.  'base64 -d' from 'coreutils' doesn't like
# CRs and complains about "invalid input", so remove all CRs at the
# end of lines.
sed -e 's/\r*$//' | \
while find_embedded_trash
do
	echo "Extracting trash directory of '$test_name'"

	extract_embedded_trash |base64 -d |tar xzp
done
back to top