mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
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
This commit is contained in:
parent
8dd57a1ed2
commit
1b40f7e540
1 changed files with 25 additions and 29 deletions
|
@ -257,16 +257,15 @@ final class PhabricatorRepositoryPullEngine
|
|||
|
||||
$path = rtrim($repository->getLocalPath(), '/');
|
||||
|
||||
if ($repository->isHosted()) {
|
||||
$repository->execxRemoteCommand(
|
||||
'init --bare -- %s',
|
||||
$path);
|
||||
} else {
|
||||
$repository->execxRemoteCommand(
|
||||
'clone --bare -- %P %s',
|
||||
$repository->getRemoteURIEnvelope(),
|
||||
$path);
|
||||
}
|
||||
// See T13448. In all cases, we create repositories by using "git init"
|
||||
// to build a bare, empty working copy. If we try to use "git clone"
|
||||
// instead, we'll pull in too many refs if "Fetch Refs" is also
|
||||
// configured. There's no apparent way to make "git clone" behave narrowly
|
||||
// and no apparent reason to bother.
|
||||
|
||||
$repository->execxRemoteCommand(
|
||||
'init --bare -- %s',
|
||||
$path);
|
||||
}
|
||||
|
||||
|
||||
|
@ -290,29 +289,27 @@ final class PhabricatorRepositoryPullEngine
|
|||
$files = Filesystem::listDirectory($path, $include_hidden = true);
|
||||
if (!$files) {
|
||||
$message = pht(
|
||||
"Expected to find a git repository at '%s', but there ".
|
||||
"is an empty directory there. Remove the directory: the daemon ".
|
||||
"will run '%s' for you.",
|
||||
$path,
|
||||
'git clone');
|
||||
'Expected to find a Git repository at "%s", but there is an '.
|
||||
'empty directory there. Remove the directory. A daemon will '.
|
||||
'construct the working copy for you.',
|
||||
$path);
|
||||
} else {
|
||||
$message = pht(
|
||||
"Expected to find a git repository at '%s', but there is ".
|
||||
"a non-repository directory (with other stuff in it) there. Move ".
|
||||
"or remove this directory (or reconfigure the repository to use a ".
|
||||
"different directory), and then either clone a repository ".
|
||||
"yourself or let the daemon do it.",
|
||||
'Expected to find a Git repository at "%s", but there is '.
|
||||
'a non-repository directory (with other stuff in it) there. '.
|
||||
'Move or remove this directory. A daemon will construct '.
|
||||
'the working copy for you.',
|
||||
$path);
|
||||
}
|
||||
} else if (is_file($path)) {
|
||||
$message = pht(
|
||||
"Expected to find a git repository at '%s', but there is a ".
|
||||
"file there instead. Remove it and let the daemon clone a ".
|
||||
"repository for you.",
|
||||
'Expected to find a Git repository at "%s", but there is a '.
|
||||
'file there instead. Move or remove this file. A daemon will '.
|
||||
'construct the working copy for you.',
|
||||
$path);
|
||||
} else {
|
||||
$message = pht(
|
||||
"Expected to find a git repository at '%s', but did not.",
|
||||
'Expected to find a git repository at "%s", but did not.',
|
||||
$path);
|
||||
}
|
||||
} else {
|
||||
|
@ -327,11 +324,10 @@ final class PhabricatorRepositoryPullEngine
|
|||
} else if (!Filesystem::pathsAreEquivalent($repo_path, $path)) {
|
||||
$err = true;
|
||||
$message = pht(
|
||||
"Expected to find repo at '%s', but the actual git repository root ".
|
||||
"for this directory is '%s'. Something is misconfigured. ".
|
||||
"The repository's 'Local Path' should be set to some place where ".
|
||||
"the daemon can check out a working copy, ".
|
||||
"and should not be inside another git repository.",
|
||||
'Expected to find a Git repository at "%s", but the actual Git '.
|
||||
'repository root for this directory is "%s". Something is '.
|
||||
'misconfigured. This directory should be writable by the daemons '.
|
||||
'and not inside another Git repository.',
|
||||
$path,
|
||||
$repo_path);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue