@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Always initialize Git repositories with "git init", never with "git clone"

Summary:
Fixes T13448. We currently "git clone" to initialize repositories, but this will fetch too many refs if "Fetch Refs" is configured.

In modern Phabricator, there's no apparent reason to "git clone"; we can just "git init" instead. This workflow naturally falls through to an update, where we'll do a "git fetch" and pull in exactly the refs we want.

Test Plan:
- Configured an observed repository with "Fetch Refs".
- Destroyed the working copy.
- Ran "bin/repository pull X --trace --verbose".
- Before: saw "git clone" pull in the world.
- After: saw "git init" create a bare empty working copy, then "git fetch" fill it surgically.

Both flows end up in the same place, this one is just simpler and does less work.

Maniphest Tasks: T13448

Differential Revision: https://secure.phabricator.com/D20894

+25 -29
+25 -29
src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
··· 257 257 258 258 $path = rtrim($repository->getLocalPath(), '/'); 259 259 260 - if ($repository->isHosted()) { 261 - $repository->execxRemoteCommand( 262 - 'init --bare -- %s', 263 - $path); 264 - } else { 265 - $repository->execxRemoteCommand( 266 - 'clone --bare -- %P %s', 267 - $repository->getRemoteURIEnvelope(), 268 - $path); 269 - } 260 + // See T13448. In all cases, we create repositories by using "git init" 261 + // to build a bare, empty working copy. If we try to use "git clone" 262 + // instead, we'll pull in too many refs if "Fetch Refs" is also 263 + // configured. There's no apparent way to make "git clone" behave narrowly 264 + // and no apparent reason to bother. 265 + 266 + $repository->execxRemoteCommand( 267 + 'init --bare -- %s', 268 + $path); 270 269 } 271 270 272 271 ··· 290 289 $files = Filesystem::listDirectory($path, $include_hidden = true); 291 290 if (!$files) { 292 291 $message = pht( 293 - "Expected to find a git repository at '%s', but there ". 294 - "is an empty directory there. Remove the directory: the daemon ". 295 - "will run '%s' for you.", 296 - $path, 297 - 'git clone'); 292 + 'Expected to find a Git repository at "%s", but there is an '. 293 + 'empty directory there. Remove the directory. A daemon will '. 294 + 'construct the working copy for you.', 295 + $path); 298 296 } else { 299 297 $message = pht( 300 - "Expected to find a git repository at '%s', but there is ". 301 - "a non-repository directory (with other stuff in it) there. Move ". 302 - "or remove this directory (or reconfigure the repository to use a ". 303 - "different directory), and then either clone a repository ". 304 - "yourself or let the daemon do it.", 298 + 'Expected to find a Git repository at "%s", but there is '. 299 + 'a non-repository directory (with other stuff in it) there. '. 300 + 'Move or remove this directory. A daemon will construct '. 301 + 'the working copy for you.', 305 302 $path); 306 303 } 307 304 } else if (is_file($path)) { 308 305 $message = pht( 309 - "Expected to find a git repository at '%s', but there is a ". 310 - "file there instead. Remove it and let the daemon clone a ". 311 - "repository for you.", 306 + 'Expected to find a Git repository at "%s", but there is a '. 307 + 'file there instead. Move or remove this file. A daemon will '. 308 + 'construct the working copy for you.', 312 309 $path); 313 310 } else { 314 311 $message = pht( 315 - "Expected to find a git repository at '%s', but did not.", 312 + 'Expected to find a git repository at "%s", but did not.', 316 313 $path); 317 314 } 318 315 } else { ··· 327 324 } else if (!Filesystem::pathsAreEquivalent($repo_path, $path)) { 328 325 $err = true; 329 326 $message = pht( 330 - "Expected to find repo at '%s', but the actual git repository root ". 331 - "for this directory is '%s'. Something is misconfigured. ". 332 - "The repository's 'Local Path' should be set to some place where ". 333 - "the daemon can check out a working copy, ". 334 - "and should not be inside another git repository.", 327 + 'Expected to find a Git repository at "%s", but the actual Git '. 328 + 'repository root for this directory is "%s". Something is '. 329 + 'misconfigured. This directory should be writable by the daemons '. 330 + 'and not inside another Git repository.', 335 331 $path, 336 332 $repo_path); 337 333 }