From 852990d06cba8e4470464b878e2d8134f0ddd91c Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 18 Nov 2020 21:36:14 +0100 Subject: [PATCH] Make sure git gc runs if needed when syncing git mirrors in cache dir to avoid them getting very stale --- src/Composer/Util/Git.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Util/Git.php b/src/Composer/Util/Git.php index aa1f8dcb1..f752f9597 100644 --- a/src/Composer/Util/Git.php +++ b/src/Composer/Util/Git.php @@ -261,7 +261,7 @@ class Git $commandCallable = function ($url) { $sanitizedUrl = preg_replace('{://([^@]+?):(.+?)@}', '://', $url); - return sprintf('git remote set-url origin %s && git remote update --prune origin && git remote set-url origin %s', ProcessExecutor::escape($url), ProcessExecutor::escape($sanitizedUrl)); + return sprintf('git remote set-url origin %s && git remote update --prune origin && git remote set-url origin %s && git gc --auto', ProcessExecutor::escape($url), ProcessExecutor::escape($sanitizedUrl)); }; $this->runCommand($commandCallable, $url, $dir); } catch (\Exception $e) {