package git {
	description = "distributed version control system"
	website = "https://www.git-scm.com"
	anitya = 5350

	version := "2.54.0"
	source = remoteTar {
		url = "https://www.kernel.org/pub/software/scm/git/git-${version}.tar.gz"
		checksum = "7vGKtFOJGqY8DO4e8UMRax7dLgImXKQz5MMalec6MlgYrsarffSJjgOughwRFpSH"
		compress = gzip
	}

	early = `ln -s ../../system/bin/perl /usr/bin/ || true
	         # test suite assumes apache
	         rm -f /system/bin/httpd`

	// uses source tree as scratch space
	enterSource

	exec = make {
		inPlace
		generate = "make configure"

		preMake = r`function disable_test {
		               local test=$1 pattern=${2:-''}
		               if [ $# -eq 1 ]; then
		                   rm "t/${test}.sh"
		               else
		                    sed -i "t/${test}.sh" \
		                    -e "/^\s*test_expect_.*$pattern/,/^\s*' *\$/{s/^/: #/}"
		               fi
		           }
		           disable_test t1800-hook
		           disable_test t5319-multi-pack-index
		           disable_test t1305-config-include
		           disable_test t3900-i18n-commit
		           disable_test t3507-cherry-pick-conflict
		           disable_test t4201-shortlog
		           disable_test t5303-pack-corruption-resilience
		           disable_test t4301-merge-tree-write-tree
		           disable_test t8005-blame-i18n
		           disable_test t9350-fast-export
		           disable_test t9300-fast-import
		           disable_test t0211-trace2-perf
		           disable_test t1517-outside-repo
		           disable_test t2200-add-update
		           disable_test t0027-auto-crlf
		           disable_test t7513-interpret-trailers
		           disable_test t7703-repack-geometric
		           disable_test t3705-add-sparse-checkout
		           disable_test t7002-mv-sparse-checkout
		           disable_test t1451-fsck-buffer
		           disable_test t4104-apply-boundary
		           disable_test t4200-rerere
		           disable_test t5515-fetch-merge-logic`

		check = [
			"-C t"
			`GIT_PROVE_OPTS="--jobs 32 --failures"`
			"prove"
		]

		install = r`make \
	               ${jobsFlagE} \
	               DESTDIR=/work \
	               NO_INSTALL_HARDLINKS=1 \
	               install`
	}

	inputs = [
		// test suite hangs on mksh
		bash

		diffutils
		autoconf
		gettext

		zlib
		curl
		libexpat
	]

	runtime = [
		zlib
		curl
		libexpat
	]
}
