# git configuration file for the TNF hg<->git cinnabar bridge.
#
# To use this, you must include it and configure the git repository
# with remotes `origin' and, optionally, `draft', like so:
#
#	[include]
#		path = /path/to/this/config
#	[remote "origin"]
#		url = hg::/path/to/hg/repo
#		cinnabar-refs = tips
#	[remote "draft"]
#		url = hg::/path/to/hg/repo@draft
#		cinnabar-refs = topics,tips
#

[core]
	hooksPath = /usr/pkg/share/tnfrepo/githooks

[netbsd]
	cinnabridge = true

[fetch]
	# When fetching from the hg primary, we are acting as a cache,
	# so we should respect whatever has been pruned.
	prune = true
	pruneTags = true

[receive]
	# Atomic pushes can't currently be implemented in the bridge
	# back to hg.
	#
	# (Although git-cinnabar itself can issue atomic pushes to hg
	# (https://github.com/glandium/git-cinnabar/issues/334), we
	# _process_ pushes from git clients ref-by-ref with separate
	# update hook calls.  And while the pre-receive hook could
	# handle multiple refs in a batch, it's not clear there's a
	# straightforward way to use it for this purpose the way we use
	# the update hook, because of tricky issues in git guts; see
	# https://lore.kernel.org/git/20241105013433.4E52260A64@jupiter.mumble.net/T/
	# for discussion.)
	advertiseAtomic = false
	advertisePushOptions = true

	# Non-fast-forwards (forced updates) are allowed for drafts,
	# and while they're forbidden for public commits, they will be
	# rejected by the hg primary anyway so we need not reject them
	# here.
	denyNonFastforwards = false

[maintenance]
	# We will run maintenance ourselves via cron job, so don't do
	# it automatically after various git operations.
	auto = false

        # Use the built-in `incremental' strategy to tune what
	# maintenance tasks are run when rather than customize it
	# ourselves.  At time of writing (git 2.50.1) the tasks are:
	#
	#	- gc: disabled
	#	- commit-graph: hourly
	#	- prefetch: hourly
	#	- loose-objects: daily
	#	- incremental-repack: hourly
	#
	strategy = incremental

# Upload filter configuration.  See
# https://git-scm.com/docs/partial-clone/2.49.0 and
# https://web.archive.org/web/20260207065253/https://github.blog/open-source/git/get-up-to-speed-with-partial-clone-and-shallow-clone/
# for details and background information.
[uploadpack]
	# Allow clients to do partial clone/fetch with blobless or
	# treeless filters at all.  This may incur some overhead on the
	# server side, however, so we restrict the allowed filters.
	#
	# Note that because using a partial clone (e.g., to check out a
	# working tree) may fetch objects that are not directly pointed
	# to by refs, we have to enable that on the server side.
	#
	# We could restrict clients to objects that are _indirectly_
	# reachable by refs with uploadpack.allowReachableSHA1InWant,
	# but reachability is expensive to compute, so we will use
	# uploadpack.allowAnySHA1InWant.  This means that we can't keep
	# some objects secret in an otherwise public repository, but
	# that's not really a big deal.
	allowFilter = true
	allowAnySHA1InWant = true
[uploadpackfilter "blob:none"]
	# Allow `git clone --filter=blob:none', blobless clones: these
	# start with the full history, and the list of file hashes for
	# each commit, but no file content.
	allow = true
[uploadpackfilter "tree"]
	# Allow `git clone --filter=tree:0', treeless clones: these
	# start with the full history, but no lists of file hashes for
	# each commit, and no file content.
	maxDepth = 0
[uploadpackfilter]
	# Forbid arbitrary upload filters.  Only those that are
	# explicitly allowed above will be allowed, in case other ones
	# impose costs we haven't thought of in advance.
	allow = false
