[pacman-dev] [PATCH] libmakepkg/source/git: Use --bare with a refspec instead of --mirror

Johannes Löthberg johannes at kyriasis.com
Sun Jan 20 14:13:06 UTC 2019

This pulls in all of the branches in the same way as --mirror, but won't
also pull in all of the non-branch references.

For example the refs/pull/*/{head,merge} references that GitHub creates
for every PR that has ever been opened against the repo can pull in a
very large amount of objects that aren't useful, and which can massively
inflate a repository.

Signed-off-by: Johannes Löthberg <johannes at kyriasis.com>
 scripts/libmakepkg/source/git.sh.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/libmakepkg/source/git.sh.in b/scripts/libmakepkg/source/git.sh.in
index 130c11e1..6a75c1c2 100644
--- a/scripts/libmakepkg/source/git.sh.in
+++ b/scripts/libmakepkg/source/git.sh.in
@@ -43,7 +43,7 @@ download_git() {
 	if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then
 		msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "git"
-		if ! git clone --mirror "$url" "$dir"; then
+		if ! git clone --bare --config=remote.origin.fetch=+refs/heads/*:refs/heads/* "$url" "$dir"; then
 			error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "git"
 			plain "$(gettext "Aborting...")"
 			exit 1

More information about the pacman-dev mailing list