• Sean McGivern's avatar
    Optimise ExtractsRef when there is no slash · b2de3273
    Sean McGivern authored
    ExtractsRef attempts to take a string containing slashes and figure out
    which part's a reference to a tree-ish object, and which part's a path
    in that tree-ish. For instance, `foo/bar/baz` might mean:
    
    1. A ref of `foo`, a path of `bar/baz`
    2. A ref of `foo/bar`, a path of `baz`
    3. A ref of `foo/bar/baz`, and no path (the root)
    
    To do this, it needs to load the full list of references (branches and
    tags) for the repository, which can be slow and put pressure on Redis as
    it uses SMEMBERS, which is an O(n) operation.
    
    When there is no slash in the string, there is no ambiguity: it must be
    a reference and no path (the third case above). In that case we can skip
    loading the references entirely and just detect that by looking at the
    string in question.
    b2de3273
extracts_ref.rb 4.14 KB