mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 16:52:41 +01:00
Don't try to prune unreachable commits from repositories with no outdated refs
Summary:
Fixes T11269. The basic issue is that `git log` in an empty repository exits with an error message.
Prior to recent Git (2.6?), this message reads:
> fatal: bad default revision 'HEAD'
This message was somewhat recently changed by <ce11360467
>. After that, it reads:
> fatal: your current branch 'master' does not have any commits yet
This change isn't //technically// a //complete// fix because you could still hit this issue like this:
- Create an empty repository.
- Push some stuff to `master`.
- Delete `master`.
However, this is very rare and even in this case the repository will fix itself once you push something again. We can try to fix that if any users ever actually hit it.
Test Plan:
- Created a new empty Git repository.
- Ran `bin/repository update Rxx`.
- Before patch: "git log" error because of the empty repository.
- After patch: clean update.
- Also ran `repository update` on a non-empty repository.
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T11269
Differential Revision: https://secure.phabricator.com/D16234
This commit is contained in:
parent
62131de8cd
commit
5ffdb73273
1 changed files with 7 additions and 0 deletions
|
@ -759,6 +759,13 @@ final class PhabricatorRepositoryDiscoveryEngine
|
|||
'repositoryPHID = %s',
|
||||
$repository->getPHID());
|
||||
|
||||
// If we don't have any refs to update, bail out before building a graph
|
||||
// stream. In particular, this improves behavior in empty repositories,
|
||||
// where `git log` exits with an error.
|
||||
if (!$old_refs) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We can share a single graph stream across all the checks we need to do.
|
||||
$stream = new PhabricatorGitGraphStream($repository);
|
||||
|
||||
|
|
Loading…
Reference in a new issue