# HG changeset patch # User Marcin Kuzminski # Date 2019-08-20 20:59:19 # Node ID 406ae170dc86d8668bdb176be5233874da421be8 # Parent 7807f9db28767573d7d61fe40d37987685229b26 git: simplify dangling commit checking to only full SHAs, otherwise we do too many checks in case of references which is slow on large repos diff --git a/vcsserver/git.py b/vcsserver/git.py --- a/vcsserver/git.py +++ b/vcsserver/git.py @@ -692,10 +692,20 @@ class GitRemote(RemoteBase): commit = repo.get(commit.target) is_tag = True - if not is_tag: + check_dangling = True + if is_tag: + check_dangling = False + + # we used a reference and it parsed means we're not having a dangling commit + if sha != commit.hex: + check_dangling = False + + if check_dangling: # check for dangling commit - branches = [x for x in repo.branches.with_commit(commit.hex)] - if not branches: + for branch in repo.branches.with_commit(commit.hex): + if branch: + break + else: raise exceptions.LookupException(None)(missing_commit_err) commit_id = commit.hex