@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.

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

+28 -18
+28 -18
src/applications/diffusion/query/browse/DiffusionGitBrowseQuery.php
··· 116 116 // NOTE: We need to read the file out of git and write it to a temporary 117 117 // location because "git config -f" doesn't accept a "commit:path"-style 118 118 // argument. 119 - list($contents) = $repository->execxLocalCommand( 119 + 120 + // NOTE: This file may not exist, e.g. because the commit author removed 121 + // it when they added the submodule. See T1448. If it's not present, just 122 + // show the submodule without enriching it. If ".gitmodules" was removed 123 + // it seems to partially break submodules, but the repository as a whole 124 + // continues to work fine and we've seen at least two cases of this in 125 + // the wild. 126 + 127 + list($err, $contents) = $repository->execLocalCommand( 120 128 'cat-file blob %s:.gitmodules', 121 129 $commit); 122 130 123 - $tmp = new TempFile(); 124 - Filesystem::writeFile($tmp, $contents); 125 - list($module_info) = $repository->execxLocalCommand( 126 - 'config -l -f %s', 127 - $tmp); 131 + if (!$err) { 132 + $tmp = new TempFile(); 133 + Filesystem::writeFile($tmp, $contents); 134 + list($module_info) = $repository->execxLocalCommand( 135 + 'config -l -f %s', 136 + $tmp); 128 137 129 - $dict = array(); 130 - $lines = explode("\n", trim($module_info)); 131 - foreach ($lines as $line) { 132 - list($key, $value) = explode('=', $line, 2); 133 - $parts = explode('.', $key); 134 - $dict[$key] = $value; 135 - } 138 + $dict = array(); 139 + $lines = explode("\n", trim($module_info)); 140 + foreach ($lines as $line) { 141 + list($key, $value) = explode('=', $line, 2); 142 + $parts = explode('.', $key); 143 + $dict[$key] = $value; 144 + } 136 145 137 - foreach ($submodules as $path) { 138 - $full_path = $path->getFullPath(); 139 - $key = $dict['submodule.'.$full_path.'.url']; 140 - if (isset($dict[$key])) { 141 - $path->setExternalURI($key); 146 + foreach ($submodules as $path) { 147 + $full_path = $path->getFullPath(); 148 + $key = 'submodule.'.$full_path.'.url'; 149 + if (isset($dict[$key])) { 150 + $path->setExternalURI($dict[$key]); 151 + } 142 152 } 143 153 } 144 154 }