1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 14:30:56 +01:00

Don't fail in Diffusion if .gitmodules is missing

Summary:
See T1448. If this file isn't present, just move on instead of failing, since it's a (sort of) legitimate repository state.

Also fix some silliness a little later that got introduced in refactoring, I think.

Test Plan: Added an external to my test repo and removed ".gitmodules". Verified that the directory is now viewable after this patch.

Reviewers: btrahan, davidreuss, jungejason

Reviewed By: davidreuss

CC: aran

Maniphest Tasks: T1448

Differential Revision: https://secure.phabricator.com/D2922
This commit is contained in:
epriestley 2012-07-05 06:12:35 -07:00
parent bf9cd55577
commit 4dd5bcf1cd

View file

@ -116,10 +116,19 @@ final class DiffusionGitBrowseQuery extends DiffusionBrowseQuery {
// NOTE: We need to read the file out of git and write it to a temporary // NOTE: We need to read the file out of git and write it to a temporary
// location because "git config -f" doesn't accept a "commit:path"-style // location because "git config -f" doesn't accept a "commit:path"-style
// argument. // argument.
list($contents) = $repository->execxLocalCommand(
// NOTE: This file may not exist, e.g. because the commit author removed
// it when they added the submodule. See T1448. If it's not present, just
// show the submodule without enriching it. If ".gitmodules" was removed
// it seems to partially break submodules, but the repository as a whole
// continues to work fine and we've seen at least two cases of this in
// the wild.
list($err, $contents) = $repository->execLocalCommand(
'cat-file blob %s:.gitmodules', 'cat-file blob %s:.gitmodules',
$commit); $commit);
if (!$err) {
$tmp = new TempFile(); $tmp = new TempFile();
Filesystem::writeFile($tmp, $contents); Filesystem::writeFile($tmp, $contents);
list($module_info) = $repository->execxLocalCommand( list($module_info) = $repository->execxLocalCommand(
@ -136,9 +145,10 @@ final class DiffusionGitBrowseQuery extends DiffusionBrowseQuery {
foreach ($submodules as $path) { foreach ($submodules as $path) {
$full_path = $path->getFullPath(); $full_path = $path->getFullPath();
$key = $dict['submodule.'.$full_path.'.url']; $key = 'submodule.'.$full_path.'.url';
if (isset($dict[$key])) { if (isset($dict[$key])) {
$path->setExternalURI($key); $path->setExternalURI($dict[$key]);
}
} }
} }
} }