Back to the room

Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works

Code Observatory / method

read_blob

codeintel.git_source.Checkout.read_blob

PINNED SOURCE Source and edges from the index at this commit. An execution appears only where one was recorded.

PHAROS at 975a38dMIT license

Around this symbol

Search all symbols

Loading

Calls (2)
SymbolFileResolved by
_git_envgit_source.pysame file
GitErrorgit_source.pysame file
Called by (1)
SymbolFileResolved by
_index_batchindexer.pyunique name
Inside (1)
SymbolFileResolved by
Checkoutgit_source.pysame file
codeintel.git_source.Checkout.read_blobbackend/app/codeintel/git_source.py, lines 383–406Open source
    def read_blob(self, sha: str) -> bytes:        """Read one blob through a persistent ``git cat-file --batch`` process."""        if not re.fullmatch(r"[0-9a-f]{40,64}", sha):            raise ValueError("invalid blob sha")        if self._reader is None:            self._reader = subprocess.Popen(                ["git", f"--git-dir={self.git_dir}", "cat-file", "--batch"],                stdin=subprocess.PIPE,                stdout=subprocess.PIPE,                stderr=subprocess.DEVNULL,                env=_git_env(),            )        proc = self._reader        assert proc.stdin and proc.stdout        proc.stdin.write(sha.encode() + b"\n")        proc.stdin.flush()        header = proc.stdout.readline().decode()        parts = header.split()        if len(parts) != 3 or parts[1] != "blob":            raise GitError(f"cannot read blob {sha[:12]}", retryable=False)        size = int(parts[2])        data = proc.stdout.read(size)        proc.stdout.read(1)  # trailing newline        return data

What the index recorded

Signature
def read_blob(self, sha: str) -> bytes:
File
backend/app/codeintel/git_source.py
Lines
383–406
Parser
python-ast
Git blob
6f88470169e4935929c5f865a974bd86da564c1a
Call sites
14 named, 5 resolved, 9 left unlinked
Outside this subset
4 more edges reach code outside the graph shown here

Read it on GitHub at this commit