git: upgrade to 2.31.0

Cherry-picked from crrev/c/2779911

BUG=b/183757372
TEST=presubmit
RELEASE_NOTE=Upgraded dev-vcs/git to version 2.31.0. Resolves CVE-2021-21300

Change-Id: I20a0422016e268e6a974516176ef04e3aac55eb5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/portage-stable/+/2779911
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Allen Webb <allenwebb@google.com>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Reviewed-on: https://cos-review.googlesource.com/c/third_party/overlays/portage-stable/+/15710
Tested-by: Cusky Presubmit Bot <presubmit@cos-infra-prod.iam.gserviceaccount.com>
Reviewed-by: Robert Kolchmeyer <rkolchmeyer@google.com>
diff --git a/dev-vcs/git/Manifest b/dev-vcs/git/Manifest
index a1bb8ee..d9dc1dd 100644
--- a/dev-vcs/git/Manifest
+++ b/dev-vcs/git/Manifest
@@ -1,3 +1,18 @@
-DIST git-2.29.2.tar.xz 6187988 BLAKE2B 15c2446a266d7cc3032e4b3bd32f57a2c2ff3d377848f307225ea585883c993ed835c8ffe02202386360b94f5a1f4bd3124322f0034c0d65ed15aa28b7e45ffa SHA512 34117628c6d43ac0940c43bffaa1bda7f12af863728f391492725a3e57d1bbda523cf7734e90f463fe9a9ae4e70fc1cc2523643dbb3c27377d98dc4736b0ea62
-DIST git-htmldocs-2.29.2.tar.xz 1364856 BLAKE2B 76498ef5bfdc058ad1e7c3b2c0c5ba715fa2682c7429db837cfeb7abe64ae3561e8b3f2dc032dd193514778271a040b1b120071d12ae5082a415db5084c7b6aa SHA512 d7223160af9bc97201bff59b94c8c09d331cdb9f979c878698230bb579b3f4751b6a455d8413ce09a507799744d7e3c77a2ad4d265386de7ef3ba9e11fb20445
-DIST git-manpages-2.29.2.tar.xz 478516 BLAKE2B d9a9840a8c869e2f7f9dade12c780032a7eeff59314b4d45c8c65e3f076e0335f0674c484fe7cebbc70d13b51a17b5fcf69b1bd51dca7ff226d76b1fed33d8bf SHA512 f2af31f8b2242961a0633258dd4668dbf21b26eff440e302608bc5bee2ed45a3e573528cdd0f11503d0ac4745e03cb457d99f5529fc96c105ce441ece07e4fe8
+DIST git-2.26.2.tar.xz 6007864 BLAKE2B efce003a95e24dbb6e14feebd35874c9ed1a5c06d7f0722d4dfefae830613b64b81faa41d5952400fa382b385d15d48829f8ee3b4d065e134bd38fa0e10bf570 SHA512 5d92d07b171c5cd6e89a29c1211c73c1c900cd51c74d690aebfb4a3d0e93b541b09b42b6d6a1a82f5c3d953096771f9a8605c63be139f559f58698c1a0eabcfc
+DIST git-2.26.3.tar.xz 6009184 BLAKE2B 12c0b8fb460024e7767919cac3e36ecb215e25566eb907e11495c086e1d43d790c2aa8edd178d53abc3f7eaee968a6c89e92a6575d4d11f9740567b357056aee SHA512 a88f8ab156f12770590110b30da83631f19a349f3b7af25fd0a5e8f03c78daec0a4935e9a1a5637f100c147cc57fca4aa3386e18756a6382983e7baa7456e398
+DIST git-2.28.1.tar.xz 6119248 BLAKE2B 69999a39d1c5c1dc69b8c7721a594104b51d2af691e1f2ef6a2f2bee99bd5b319c856cfccc4166cfd3426cf8eb58b3b4aea5ed2ae15061fba0f0f3e44c7d24e4 SHA512 6acd7f42eeaf4fcb085fe2ab3d65f53a264fd38ef84321b77eb7c21bbb146e42ec9f27cc36cd9f3569f6d1758742119efd0af9bf6414fe7c577c434ed154fb8f
+DIST git-2.29.3.tar.xz 6189996 BLAKE2B 9e30b7c4eab0d74a7d3d1387774958fc1ce7fde6239bd8daaa277304cde1f3249484fd703a1827c703ec9400ac2c1e7c288bd2956a3854521bf561437de58617 SHA512 3a21be5005675e5406964519f3c8441826b311274de8c5bacdc3ede564efef3d87f085682f31c89166a5022738a3cbd8e767d2bca3bd57d6f55b2451e36681dd
+DIST git-2.30.2.tar.xz 6329820 BLAKE2B 1c553c183d5426c524852bfba38b39196d9f0fb83854fec3291959474374db41a68a4118785412037ba16230662d94f03b05bb7ea577f0272552e63b68086f95 SHA512 4f7e1c30f8eee849d1febeda872d56c60c5d051a31726505a4c7bab11b274d3a2ab5588f910b7b49c5c0ec5228a18457f705c7b66e8bbdf809d3c75c59032b7e
+DIST git-2.31.0.tar.xz 6414252 BLAKE2B c9186c0e212767956cbabc685989408860600a19ff56637453f9cd45e143b6fb5b7104b188726506481782fcdfe3e7b28d5c9cf374172b81e5bfedf249292793 SHA512 b8f7608d4349c983c426494227b0ec9d032e67c775382a32675418f629f365817ac99a61c24e3a380bc5eb65351058dbf55d526890055acf58ad4f028022f513
+DIST git-htmldocs-2.26.2.tar.xz 1304788 BLAKE2B e0de88c5c41646d5fb9b54e2ee873c7904e1b85c67f971499f0227eb2dd59cabd4ffc58c468cf8a7a7466920af972dbc7f95d78003e487edac9a15a9c49b80a2 SHA512 b577693180b4fc035af211e3b83e98ad5e1bfbb98706924858df6558383b82ca05f870bdae90f8a14c8bf664f091ee928af52dcdebdfb98dc7387fdfe2e3a396
+DIST git-htmldocs-2.26.3.tar.xz 1305208 BLAKE2B d5bb834b00a9d0cd3cdcd671e33142595e4ac28be8eab2326263f548718d52cf141b7fa6afee8da05a15ac75252455945dd34d60ffe5cda6cf1d612b7ee35953 SHA512 ff6c912572d32a1f32ec4c73e07e1404155ccbf81509a741e25e9dbcf42e5348dce59c40b0bb5d64993d8a981e2afd773393b2aeacde457870aa1f03feb9a1a6
+DIST git-htmldocs-2.28.1.tar.xz 1348296 BLAKE2B 6bbaf94a963204d85100554578fb2520c44b74332e6dfd0f468fa3217efad2a484ef427359411569ca503a809aec00edde21ab577ee9ddc9779f0b702402ed4c SHA512 9e672673f271a136f9c2d1ed827dbc76656b40315cb5d11d95aa18c006fad8ea2c2535f2092f1b6514a6ae7f88589178fc90299b496f446debb673e8f36f8909
+DIST git-htmldocs-2.29.3.tar.xz 1365468 BLAKE2B b8b2d46a5b35f6962f06bd9837ddc613aa5f4096dcdabea4308fcc52bf4f639fbdade2f91e01738cce6befb8b63faf57f8ecab1200048794d873f12055f04bdd SHA512 217a313636b5e7470e58d21428c81262f9d9909227f6a47c8445eb301bb20dd8393d0e600b8e7dad04b030a688561f93cdce317ad714cecd0505c198e1fe44a2
+DIST git-htmldocs-2.30.2.tar.xz 1342648 BLAKE2B a81b2111a79b7b211f99c0ac2b3d397d627316fc1eab56f091088b4ff26d80c353efcea4154f84640dea952dddaf496f3c8f63d2c371d6ce97bf888fad2db237 SHA512 7fc8bb1a9e484f5f49ad41c89ee8e5059970e3091e1d72b86800f8d255fe00be3d8072194cbc913ef6d98aa014ba9e8efae062a9ae595f4dcafaa0c3e637d297
+DIST git-htmldocs-2.31.0.tar.xz 1357332 BLAKE2B 06fe5fdde4193ffccf243eae8c112b6bf74b3a554283e0f688a47275a47de4c1c4dce9fe6dfa550885786ab8df46fa83fadd22746bc64e430af42785eda30583 SHA512 31a7d715454060bbc260a6001d971df0eea16c819de96a9316bb465a67661ebe805a8ea2f5f223c070b6aa1affd1e72970b223474e6221bf87ac3b233d229fdd
+DIST git-manpages-2.26.2.tar.xz 462052 BLAKE2B 27fc44360c9f890e9f7754e8423f5596548f076f5fec5dfc6c752e8b3caa5f64ba182c1566b67878b19fbb115297e08def1bf9d2711c7334cbb8e1b20fc039a1 SHA512 9591e94683a6b49d8b9f2afddc826576023fdfa6de6db4af3a28a2af00b175d5be710d86a31d0f1b8320cc38b6f27698e17fb3e8c1f2b0c5ced37296ef1109b6
+DIST git-manpages-2.26.3.tar.xz 462116 BLAKE2B 3191f719c5f2f0df34a66a041ab8590cbb43ed8df6d4b430df04e4255544048a982c00dbcbc7d7d9057830d5354c595d853e9f7558efdd6049be74e81d61a20d SHA512 8f9b64b0554867a56a647ac4f76351858342f84a38fd9977c606612c034dcad552afba8489a81ce227ed48a90d78f23d203452086175e218efb3f0fe8429f9f9
+DIST git-manpages-2.28.1.tar.xz 472404 BLAKE2B d6b411dee47439b91e61f93fdca24fc5a707807c9445b69df81be8cdf6b78e24ea8424c0a36a3b4bd7db82e303b4139449a3fdc7de43d65d50f8b9e936e73669 SHA512 b543934fb9a91636033a2a7262180bf62b5493be3c222fb882aa992fe15f9fc0b9cc6723f3afa65fe8c60b8909af4337139bc0c355df0ac063f9e915d4b574bd
+DIST git-manpages-2.29.3.tar.xz 478456 BLAKE2B e568b92badda851be5d5c0524455d1eb728e4633dd88144edc8e22d84c64ad195538d906ae3443789ea14607be536d1de0f30b448ab0860d605b65a6476455fb SHA512 5d1a26c1342c31ca3501f2e40ec55c6e5dddd1ee2de909ec65425dea92455f00ca23a10e7475dcfe5b9a60dc4c2012778e86797cc8922de20638fcc07c60d941
+DIST git-manpages-2.30.2.tar.xz 482180 BLAKE2B 97180d13ba73f229d205b662ca16d497baff57a23b9b621fab69bc1bb4f2ac4f52b861443917ae01ebab7130640e1b7352aa193d7c0cd945cb552749ee1367c9 SHA512 fcb2ab9dd4c29593d08b80f6731ccc3b9a54514d6cc002434f8e36277fd814d4be7e69f0563291cea4f16c35e4822def57ade50d7d10a897619b13c6a6893aa7
+DIST git-manpages-2.31.0.tar.xz 487764 BLAKE2B e5acc25fe28c666afd017d29a9cce7b0e37d2b1dee93f911683c5e54972fe4def59964409bd232666963b4509d4ca30fb9b95757e2fdfe308559e455bf8160d3 SHA512 9bf426d5aadd4ac011f9b3694547da795bf5e8bc77a79ef69de56d6f39c3a0fdc039db25d4671810a5320a6c057f2364ec096413eebbbeabc26a7d3b65c9c787
diff --git a/dev-vcs/git/files/git-2.31.0-darwin-prefix-gettext.patch b/dev-vcs/git/files/git-2.31.0-darwin-prefix-gettext.patch
new file mode 100644
index 0000000..df87def
--- /dev/null
+++ b/dev-vcs/git/files/git-2.31.0-darwin-prefix-gettext.patch
@@ -0,0 +1,22 @@
+Don't examine outside of the prefix for gettext on macOS/Darwin.
+https://bugs.gentoo.org/757309
+--- a/config.mak.uname
++++ b/config.mak.uname
+@@ -136,17 +136,6 @@ ifeq ($(uname_S),Darwin)
+ 	HAVE_BSD_SYSCTL = YesPlease
+ 	FREAD_READS_DIRECTORIES = UnfortunatelyYes
+ 	HAVE_NS_GET_EXECUTABLE_PATH = YesPlease
+-
+-	# Workaround for `gettext` being keg-only and not even being linked via
+-	# `brew link --force gettext`, should be obsolete as of
+-	# https://github.com/Homebrew/homebrew-core/pull/53489
+-	ifeq ($(shell test -d /usr/local/opt/gettext/ && echo y),y)
+-		BASIC_CFLAGS += -I/usr/local/include -I/usr/local/opt/gettext/include
+-		BASIC_LDFLAGS += -L/usr/local/lib -L/usr/local/opt/gettext/lib
+-		ifeq ($(shell test -x /usr/local/opt/gettext/bin/msgfmt && echo y),y)
+-			MSGFMT = /usr/local/opt/gettext/bin/msgfmt
+-		endif
+-	endif
+ endif
+ ifeq ($(uname_S),SunOS)
+ 	NEEDS_SOCKET = YesPlease
diff --git a/dev-vcs/git/files/git-2.22.0_rc0-optional-cvs.patch b/dev-vcs/git/files/git-2.31.0_rc0-optional-cvs.patch
similarity index 88%
rename from dev-vcs/git/files/git-2.22.0_rc0-optional-cvs.patch
rename to dev-vcs/git/files/git-2.31.0_rc0-optional-cvs.patch
index a7d7a78..0999dbe 100644
--- a/dev-vcs/git/files/git-2.22.0_rc0-optional-cvs.patch
+++ b/dev-vcs/git/files/git-2.31.0_rc0-optional-cvs.patch
@@ -1,4 +1,4 @@
-From 1d3a35734efa1a1778612bb60cbbb495f65d3fc0 Mon Sep 17 00:00:00 2001
+From 0c5ced8704ce69d7c84c2cc7cb26335616464468 Mon Sep 17 00:00:00 2001
 From: Robin Johnson <robbat2@gentoo.org>
 Date: Tue, 14 May 2019 08:53:06 +0200
 Subject: [PATCH] Makefile: Add NO_CVS define to disable all CVS interface
@@ -16,6 +16,7 @@
 Forward-ported from v2.12.0 to v2.17.0-rc1
 Forward-ported from v2.17.0-rc1 to v2.18.0-rc1
 Forward-ported from v2.18.0-rc1 to v2.22.0-rc0
+Forward-ported from v2.22.0-rc0 to v2.31.0-rc0
 
 Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
 ---
@@ -31,10 +32,10 @@
  9 files changed, 118 insertions(+), 33 deletions(-)
 
 diff --git a/Makefile b/Makefile
-index f965509b3c..ab8b22faf1 100644
+index 9b1bde2e0e..ae993a07fa 100644
 --- a/Makefile
 +++ b/Makefile
-@@ -327,6 +327,8 @@ all::
+@@ -305,6 +305,8 @@ all::
  # Define SANE_TEXT_GREP to "-a" if you use recent versions of GNU grep
  # and egrep that are pickier when their input contains non-ASCII data.
  #
@@ -43,7 +44,7 @@
  # The TCL_PATH variable governs the location of the Tcl interpreter
  # used to optimize git-gui for your system.  Only used if NO_TCLTK
  # is not set.  Defaults to the bare 'tclsh'.
-@@ -597,6 +599,7 @@ PROGRAM_OBJS =
+@@ -580,6 +582,7 @@ PROGRAM_OBJS =
  PROGRAMS =
  EXCLUDED_PROGRAMS =
  SCRIPT_PERL =
@@ -51,7 +52,7 @@
  SCRIPT_PYTHON =
  SCRIPT_SH =
  SCRIPT_LIB =
-@@ -632,31 +635,33 @@ SCRIPT_LIB += git-sh-i18n
+@@ -612,31 +615,33 @@ SCRIPT_LIB += git-sh-setup
  
  SCRIPT_PERL += git-add--interactive.perl
  SCRIPT_PERL += git-archimport.perl
@@ -90,7 +91,7 @@
  	$(INSTALL) $^ '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
  install-python-script: $(SCRIPT_PYTHON_GEN)
  	$(INSTALL) $^ '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
-@@ -665,12 +670,13 @@ install-python-script: $(SCRIPT_PYTHON_GEN)
+@@ -645,12 +650,13 @@ install-python-script: $(SCRIPT_PYTHON_GEN)
  clean-sh-script:
  	$(RM) $(SCRIPT_SH_GEN)
  clean-perl-script:
@@ -105,7 +106,7 @@
  	  $(SCRIPT_PYTHON_GEN) \
  	  git-instaweb
  
-@@ -2189,13 +2195,27 @@ git.res: git.rc GIT-VERSION-FILE GIT-PREFIX
+@@ -2233,13 +2239,27 @@ git.res: git.rc GIT-VERSION-FILE GIT-PREFIX
  	  -DGIT_VERSION="\\\"$(GIT_VERSION)\\\"" -i $< -o $@
  
  # This makes sure we depend on the NO_PERL setting itself.
@@ -134,7 +135,7 @@
  PERL_HEADER_TEMPLATE = perl/header_templates/fixed_prefix.template.pl
  PERL_DEFINES = $(PERL_PATH_SQ):$(PERLLIB_EXTRA_SQ):$(perllibdir_SQ)
  
-@@ -2216,7 +2236,7 @@ endif
+@@ -2260,7 +2280,7 @@ endif
  
  PERL_DEFINES += $(gitexecdir) $(perllibdir) $(localedir)
  
@@ -143,7 +144,7 @@
  	$(QUIET_GEN)$(RM) $@ $@+ && \
  	sed -e '1{' \
  	    -e '	s|#!.*perl|#!$(PERL_PATH_SQ)|' \
-@@ -2262,14 +2282,18 @@ git-instaweb: git-instaweb.sh GIT-SCRIPT-DEFINES
+@@ -2306,14 +2326,18 @@ git-instaweb: git-instaweb.sh GIT-SCRIPT-DEFINES
  	chmod +x $@+ && \
  	mv $@+ $@
  else # NO_PERL
@@ -165,8 +166,8 @@
  
  # This makes sure we depend on the NO_PYTHON setting itself.
  $(SCRIPT_PYTHON_GEN): GIT-BUILD-OPTIONS
-@@ -2518,7 +2542,7 @@ LOCALIZED_SH = $(SCRIPT_SH)
- LOCALIZED_SH += git-parse-remote.sh
+@@ -2569,7 +2593,7 @@ LOCALIZED_C = $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)
+ LOCALIZED_SH = $(SCRIPT_SH)
  LOCALIZED_SH += git-rebase--preserve-merges.sh
  LOCALIZED_SH += git-sh-setup.sh
 -LOCALIZED_PERL = $(SCRIPT_PERL)
@@ -191,10 +192,10 @@
  if test $? -ne 1
  then
 diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh
-index a5e5dca753..ef6d9c911c 100755
+index 2d29d486ee..2ca6db10e0 100755
 --- a/t/t9400-git-cvsserver-server.sh
 +++ b/t/t9400-git-cvsserver-server.sh
-@@ -11,9 +11,15 @@ cvs CLI client via git-cvsserver server'
+@@ -14,9 +14,15 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
  . ./test-lib.sh
  
  if ! test_have_prereq PERL; then
@@ -212,10 +213,10 @@
  if test $? -ne 1
  then
 diff --git a/t/t9401-git-cvsserver-crlf.sh b/t/t9401-git-cvsserver-crlf.sh
-index 84787eee9a..eecba88527 100755
+index a34805acdc..0d7759f73b 100755
 --- a/t/t9401-git-cvsserver-crlf.sh
 +++ b/t/t9401-git-cvsserver-crlf.sh
-@@ -57,15 +57,20 @@ check_status_options() {
+@@ -60,15 +60,20 @@ check_status_options() {
      return $stat
  }
  
@@ -242,10 +243,10 @@
  fi
  perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
 diff --git a/t/t9600-cvsimport.sh b/t/t9600-cvsimport.sh
-index 251fdd66c4..596cd9d35d 100755
+index 5680849218..7288db820b 100755
 --- a/t/t9600-cvsimport.sh
 +++ b/t/t9600-cvsimport.sh
-@@ -8,14 +8,25 @@ if ! test_have_prereq NOT_ROOT; then
+@@ -11,14 +11,25 @@ if ! test_have_prereq NOT_ROOT; then
  	test_done
  fi
  
@@ -274,7 +275,7 @@
  
  	mkdir "$CVSROOT/module" &&
  	$CVS co -d module-cvs module &&
-@@ -47,23 +58,23 @@ EOF
+@@ -50,23 +61,23 @@ EOF
  	)
  '
  
@@ -302,7 +303,7 @@
  	(cd module-cvs &&
  	cat <<EOF >o_fortuna &&
  O Fortune,
-@@ -91,7 +102,7 @@ EOF
+@@ -94,7 +105,7 @@ EOF
  	)
  '
  
@@ -311,7 +312,7 @@
  
  	(cd module-git &&
  	git config cvsimport.trackRevisions true &&
-@@ -102,7 +113,7 @@ test_expect_success PERL 'update git module' '
+@@ -105,7 +116,7 @@ test_expect_success PERL 'update git module' '
  
  '
  
@@ -320,7 +321,7 @@
  
  	(cd module-git &&
  	 git log --format="o_fortuna 1.1 %H" -1 HEAD^ &&
-@@ -110,7 +121,7 @@ test_expect_success PERL 'update has correct .git/cvs-revisions' '
+@@ -113,7 +124,7 @@ test_expect_success PERL 'update has correct .git/cvs-revisions' '
  	test_cmp expected module-git/.git/cvs-revisions
  '
  
@@ -329,7 +330,7 @@
  
  	(cd module-cvs &&
  		echo 1 >tick &&
-@@ -119,7 +130,7 @@ test_expect_success PERL 'update cvs module' '
+@@ -122,7 +133,7 @@ test_expect_success PERL 'update cvs module' '
  	)
  '
  
@@ -338,7 +339,7 @@
  
  	(cd module-git &&
  		git config cvsimport.module module &&
-@@ -131,7 +142,7 @@ test_expect_success PERL 'cvsimport.module config works' '
+@@ -134,7 +145,7 @@ test_expect_success PERL 'cvsimport.module config works' '
  
  '
  
@@ -347,7 +348,7 @@
  
  	(cd module-git &&
  	 git log --format="o_fortuna 1.1 %H" -1 HEAD^^ &&
-@@ -140,7 +151,7 @@ test_expect_success PERL 'second update has correct .git/cvs-revisions' '
+@@ -143,7 +154,7 @@ test_expect_success PERL 'second update has correct .git/cvs-revisions' '
  	test_cmp expected module-git/.git/cvs-revisions
  '
  
@@ -356,7 +357,7 @@
  
  	$CVS co -d import-from-wt module &&
  	(cd import-from-wt &&
-@@ -153,12 +164,12 @@ test_expect_success PERL 'import from a CVS working tree' '
+@@ -156,12 +167,12 @@ test_expect_success PERL 'import from a CVS working tree' '
  
  '
  
@@ -367,16 +368,16 @@
  
  '
  
--test_expect_success PERL 'test entire HEAD' 'test_cmp_branch_tree master'
-+test_expect_success 'test entire HEAD' 'test_cmp_branch_tree master'
+-test_expect_success PERL 'test entire HEAD' 'test_cmp_branch_tree main'
++test_expect_success 'test entire HEAD' 'test_cmp_branch_tree main'
  
  test_done
 diff --git a/t/t9601-cvsimport-vendor-branch.sh b/t/t9601-cvsimport-vendor-branch.sh
-index 827d39f5bf..d730a41f67 100755
+index 116cddba3a..a7e7299c81 100755
 --- a/t/t9601-cvsimport-vendor-branch.sh
 +++ b/t/t9601-cvsimport-vendor-branch.sh
-@@ -34,6 +34,17 @@
- test_description='git cvsimport handling of vendor branches'
+@@ -37,6 +37,17 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+ 
  . ./lib-cvs.sh
  
 +if ! test_have_prereq PERL
@@ -394,11 +395,11 @@
  
  test_expect_success PERL 'import a module with a vendor branch' '
 diff --git a/t/t9602-cvsimport-branches-tags.sh b/t/t9602-cvsimport-branches-tags.sh
-index e1db323f54..68f097401f 100755
+index e5266c9a87..0e1878ffd3 100755
 --- a/t/t9602-cvsimport-branches-tags.sh
 +++ b/t/t9602-cvsimport-branches-tags.sh
-@@ -6,6 +6,17 @@
- test_description='git cvsimport handling of branches and tags'
+@@ -9,6 +9,17 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+ 
  . ./lib-cvs.sh
  
 +if ! test_have_prereq PERL
@@ -416,11 +417,11 @@
  
  test_expect_success PERL 'import module' '
 diff --git a/t/t9603-cvsimport-patchsets.sh b/t/t9603-cvsimport-patchsets.sh
-index 3e64b11eac..606980b05c 100755
+index 0e9daa5768..598c8595c5 100755
 --- a/t/t9603-cvsimport-patchsets.sh
 +++ b/t/t9603-cvsimport-patchsets.sh
-@@ -14,6 +14,17 @@
- test_description='git cvsimport testing for correct patchset estimation'
+@@ -17,6 +17,17 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+ 
  . ./lib-cvs.sh
  
 +if ! test_have_prereq PERL
@@ -438,10 +439,10 @@
  
  test_expect_failure PERL 'import with criss cross times on revisions' '
 diff --git a/t/test-lib.sh b/t/test-lib.sh
-index 908ddb9c46..9a06440599 100644
+index d3f6af6a65..588067bfd8 100644
 --- a/t/test-lib.sh
 +++ b/t/test-lib.sh
-@@ -1428,6 +1428,7 @@ case $uname_s in
+@@ -1482,6 +1482,7 @@ parisc* | hppa*)
  esac
  
  ( COLUMNS=1 && test $COLUMNS = 1 ) && test_set_prereq COLUMNS_CAN_BE_1
@@ -450,5 +451,5 @@
  test -z "$NO_PTHREADS" && test_set_prereq PTHREADS
  test -z "$NO_PYTHON" && test_set_prereq PYTHON
 -- 
-2.21.0
+2.30.1
 
diff --git a/dev-vcs/git/git-2.29.2.ebuild b/dev-vcs/git/git-2.31.0-r1.ebuild
similarity index 89%
rename from dev-vcs/git/git-2.29.2.ebuild
rename to dev-vcs/git/git-2.31.0-r1.ebuild
index 823482f..eb209ee 100644
--- a/dev-vcs/git/git-2.29.2.ebuild
+++ b/dev-vcs/git/git-2.31.0-r1.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=7
@@ -6,7 +6,7 @@
 GENTOO_DEPEND_ON_PERL=no
 
 # bug #329479: git-remote-testgit is not multiple-version aware
-PYTHON_COMPAT=( python3_{6,7,8} )
+PYTHON_COMPAT=( python3_{6..9} )
 
 inherit toolchain-funcs elisp-common l10n perl-module bash-completion-r1 python-single-r1 systemd
 
@@ -20,12 +20,12 @@
 	# 9999-r0: maint
 	# 9999-r1: master
 	# 9999-r2: next
-	# 9999-r3: pu
+	# 9999-r3: seen
 	case "${PVR}" in
 		9999) EGIT_BRANCH=maint ;;
 		9999-r1) EGIT_BRANCH=master ;;
 		9999-r2) EGIT_BRANCH=next;;
-		9999-r3) EGIT_BRANCH=pu ;;
+		9999-r3) EGIT_BRANCH=seen ;;
 	esac
 fi
 
@@ -51,25 +51,24 @@
 
 LICENSE="GPL-2"
 SLOT="0"
-IUSE="+blksha1 +curl cgi doc emacs gnome-keyring +gpg highlight +iconv libressl mediawiki mediawiki-experimental +nls +pcre +pcre-jit perforce +perl +ppcsha1 subversion tk +threads +webdav xinetd cvs test"
+IUSE="+blksha1 +curl cgi doc emacs gnome-keyring +gpg highlight +iconv libressl mediawiki mediawiki-experimental +nls +pcre perforce +perl +ppcsha1 subversion tk +threads +webdav xinetd cvs test"
 
 # Common to both DEPEND and RDEPEND
 DEPEND="
-	gnome-keyring? ( app-crypt/libsecret )
+	gnome-keyring? (
+		app-crypt/libsecret
+		dev-libs/glib:2
+	)
 	!libressl? ( dev-libs/openssl:0= )
 	libressl? ( dev-libs/libressl:= )
 	sys-libs/zlib
-	pcre? (
-		pcre-jit? ( dev-libs/libpcre2[jit(+)] )
-		!pcre-jit? ( dev-libs/libpcre )
-	)
+	pcre? ( dev-libs/libpcre2 )
 	perl? ( dev-lang/perl:=[-build(-)] )
 	tk? ( dev-lang/tk:0= )
 	curl? (
 		net-misc/curl
 		webdav? ( dev-libs/expat )
 	)
-	emacs? ( >=app-editors/emacs-23.1:* )
 	iconv? ( virtual/libiconv )
 "
 
@@ -79,6 +78,7 @@
 		dev-perl/Error
 		dev-perl/MailTools
 		dev-perl/Authen-SASL
+		virtual/perl-libnet
 		cgi? (
 			dev-perl/CGI
 			highlight? ( app-text/highlight )
@@ -113,6 +113,8 @@
 		app-text/xmlto
 		sys-apps/texinfo
 	)
+	emacs? ( >=app-editors/emacs-23.1:* )
+	gnome-keyring? ( virtual/pkgconfig )
 	nls? ( sys-devel/gettext )
 	test? (	app-crypt/gnupg	)
 "
@@ -131,7 +133,6 @@
 	cvs? ( perl )
 	mediawiki? ( perl )
 	mediawiki-experimental? ( mediawiki )
-	pcre-jit? ( pcre )
 	perforce? ( ${PYTHON_REQUIRED_USE} )
 	subversion? ( perl )
 	webdav? ( curl )
@@ -141,7 +142,7 @@
 
 PATCHES=(
 	# bug #350330 - automagic CVS when we don't want it is bad.
-	"${FILESDIR}"/git-2.22.0_rc0-optional-cvs.patch
+	"${FILESDIR}"/git-2.31.0_rc0-optional-cvs.patch
 
 	# Make submodule output quiet
 	"${FILESDIR}"/git-2.21.0-quiet-submodules-testcase.patch
@@ -205,40 +206,15 @@
 	sed -i -e '/\/usr\/local/s/BASIC_/#BASIC_/' Makefile || die
 
 	if use pcre; then
-		if use pcre-jit; then
-			myopts+=( USE_LIBPCRE2=YesPlease )
-			extlibs+=( -lpcre2-8 )
-		else
-			myopts+=(
-				USE_LIBPCRE1=YesPlease
-				NO_LIBPCRE1_JIT=YesPlease
-			)
-			extlibs+=( -lpcre )
-		fi
-	fi
-# Disabled until ~m68k-mint can be keyworded again
-#	if [[ ${CHOST} == *-mint* ]] ; then
-#		myopts+=(
-#			NO_MMAP=YesPlease
-#			NO_IPV6=YesPlease
-#			NO_STRLCPY=YesPlease
-#			NO_MEMMEM=YesPlease
-#			NO_MKDTEMP=YesPlease
-#			NO_MKSTEMPS=YesPlease
-#		)
-#	fi
-	if [[ ${CHOST} == ia64-*-hpux* ]]; then
-		myopts+=( NO_NSEC=YesPlease )
-	fi
-	if [[ ${CHOST} == *-*-aix* ]]; then
-		myopts+=( NO_FNMATCH_CASEFOLD=YesPlease )
+		myopts+=( USE_LIBPCRE2=YesPlease )
+		extlibs+=( -lpcre2-8 )
 	fi
 	if [[ ${CHOST} == *-solaris* ]]; then
 		myopts+=(
 			NEEDS_LIBICONV=YesPlease
 			HAVE_CLOCK_MONOTONIC=1
 		)
-		if grep -q getdelim "${EROOT}"/usr/include/stdio.h ; then
+		if grep -Fq getdelim "${EROOT}"/usr/include/stdio.h ; then
 			myopts+=( HAVE_GETDELIM=1 )
 		fi
 	fi
@@ -259,7 +235,7 @@
 }
 
 src_unpack() {
-	if [[ ${PV} != *9999 ]]; then
+	if [[ ${PV} != *9999 ]] ; then
 		unpack ${MY_P}.tar.${SRC_URI_SUFFIX}
 		cd "${S}" || die
 		unpack ${PN}-manpages-${DOC_VER}.tar.${SRC_URI_SUFFIX}
@@ -288,6 +264,11 @@
 
 	default
 
+	if use prefix ; then
+		# bug #757309
+		eapply "${FILESDIR}"/git-2.31.0-darwin-prefix-gettext.patch
+	fi
+
 	sed -i \
 		-e 's:^\(CFLAGS[[:space:]]*=\).*$:\1 $(OPTCFLAGS) -Wall:' \
 		-e 's:^\(LDFLAGS[[:space:]]*=\).*$:\1 $(OPTLDFLAGS):' \
@@ -336,9 +317,7 @@
 	fi
 
 	if use perl && use cgi ; then
-		git_emake \
-			gitweb \
-			|| die "emake gitweb (cgi) failed"
+		git_emake gitweb || die "emake gitweb (cgi) failed"
 	fi
 
 	if [[ ${CHOST} == *-darwin* && ! tc-is-gcc ]]; then
@@ -350,39 +329,36 @@
 
 	pushd Documentation &>/dev/null || die
 	if [[ ${PV} == *9999 ]] ; then
-		git_emake man \
-			|| die "emake man failed"
+		git_emake man || die "emake man failed"
 		if use doc ; then
-			git_emake info html \
-				|| die "emake info html failed"
+			git_emake info html || die "emake info html failed"
 		fi
 	else
 		if use doc ; then
-			git_emake info \
-				|| die "emake info html failed"
+			git_emake info || die "emake info html failed"
 		fi
 	fi
 	popd &>/dev/null || die
 
 	if use gnome-keyring ; then
 		pushd contrib/credential/libsecret &>/dev/null || die
-		git_emake || die "emake git-credential-libsecret failed"
+		git_emake CC="$(tc-getCC)" CFLAGS="${CFLAGS}" PKG_CONFIG="$(tc-getPKG_CONFIG)"
 		popd &>/dev/null || die
 	fi
 
 	pushd contrib/subtree &>/dev/null || die
-	git_emake git-subtree
+	git_emake git-subtree || die
 	# git-subtree.1 requires the full USE=doc dependency stack
 	use doc && git_emake git-subtree.html git-subtree.1
 	popd &>/dev/null || die
 
 	pushd contrib/diff-highlight &>/dev/null || die
-	git_emake
+	git_emake || die
 	popd &>/dev/null || die
 
 	if use mediawiki ; then
 		pushd contrib/mw-to-git &>/dev/null || die
-		git_emake
+		git_emake || die
 		popd &>/dev/null || die
 
 	fi
@@ -520,9 +496,8 @@
 		newdoc  "${S}"/gitweb/README README.gitweb
 
 		for d in "${ED}"/usr/lib{,64}/perl5/ ; do
-			if test -d "${d}" ; then find "${d}" \
-				-name .packlist \
-				-delete || die
+			if [[ -d "${d}" ]] ; then
+				find "${d}" -name .packlist -delete || die
 			fi
 		done
 	else
@@ -539,10 +514,11 @@
 		newins "${FILESDIR}"/git-daemon.xinetd git-daemon
 	fi
 
-	if use !prefix ; then
+	if ! use prefix ; then
 		newinitd "${FILESDIR}"/git-daemon-r1.initd git-daemon
 		newconfd "${FILESDIR}"/git-daemon.confd git-daemon
-		systemd_newunit "${FILESDIR}/git-daemon_at-r1.service" "git-daemon@.service"
+		systemd_newunit "${FILESDIR}/git-daemon_at-r1.service" \
+			"git-daemon@.service"
 		systemd_dounit "${FILESDIR}/git-daemon.socket"
 	fi
 
@@ -552,7 +528,7 @@
 	# we could remove sources in src_prepare, but install does not
 	# handle missing locale dir well
 	rm_loc() {
-		if [[ -e "${ED}/usr/share/locale/${1}" ]]; then
+		if [[ -e "${ED}/usr/share/locale/${1}" ]] ; then
 			rm -r "${ED}/usr/share/locale/${1}" || die
 		fi
 	}
@@ -602,8 +578,8 @@
 
 	local cvs=0
 	use cvs && let cvs=${cvs}+1
-	if [[ ${EUID} -eq 0 ]]; then
-		if [[ ${cvs} -eq 1 ]]; then
+	if [[ ${EUID} -eq 0 ]] ; then
+		if [[ ${cvs} -eq 1 ]] ; then
 			ewarn "Skipping CVS tests because CVS does not work as root!"
 			ewarn "You should retest with FEATURES=userpriv!"
 			disabled+=( ${tests_cvs[@]} )
@@ -617,7 +593,7 @@
 		[[ ${cvs} -gt 1 ]] && \
 			has_version "dev-vcs/cvs[server]" && \
 			let cvs=${cvs}+1
-		if [[ ${cvs} -lt 3 ]]; then
+		if [[ ${cvs} -lt 3 ]] ; then
 			einfo "Disabling CVS tests (needs dev-vcs/cvs[USE=server])"
 			disabled+=( ${tests_cvs[@]} )
 		fi
@@ -639,12 +615,13 @@
 	done
 	einfo "Disabled tests:"
 	for i in ${disabled[@]} ; do
-		[[ -f "${i}" ]] && mv -f "${i}" "${i}.DISABLED" && einfo "Disabled ${i}"
+		if [[ -f "${i}" ]] ; then
+			mv -f "${i}" "${i}.DISABLED" && einfo "Disabled ${i}"
+		fi
 	done
 
 	# Avoid the test system removing the results because we want them ourselves
-	sed -e '/^[[:space:]]*$(MAKE) clean/s,^,#,g' \
-		-i Makefile || die
+	sed -e '/^[[:space:]]*$(MAKE) clean/s,^,#,g' -i Makefile || die
 
 	# Clean old results first, must always run
 	nonfatal git_emake clean