> ## Documentation Index
> Fetch the complete documentation index at: https://docs.diversion.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Compare refs

> Compare two refs (commit/branch/workspace/tag/tree) in this repo



## OpenAPI

````yaml get /repos/{repo_id}/compare
openapi: 3.0.3
info:
  title: Diversion Core API
  description: >-
    Definition of the Core API used to access low-level functionality of
    Diversion
  version: 0.2.0
servers:
  - url: https://api.diversion.dev/v0
    description: Base endpoint
security: []
paths:
  /repos/{repo_id}/compare:
    parameters:
      - $ref: '#/components/parameters/RepoParam'
    get:
      tags:
        - Repository Content Comparison
      summary: Compare two refs (commit/branch/workspace/tag/tree) in this repo
      operationId: src.handlersv2.tree.compare
      parameters:
        - in: query
          name: base_id
          description: |
            A workspace_id, branch_id, commit_id or tag_id.
            If omitted, assuming the empty tree, unless other_id is a workspace,
            in which case base_id is assumed to be the workspace base ref.
          schema:
            type: string
            maxLength: 128
            default: ''
        - $ref: '#/components/parameters/OtherRefParam'
      responses:
        '200':
          $ref: '#/components/responses/ComparisonList'
      security:
        - OAuth2:
            - coreapi/read
components:
  parameters:
    RepoParam:
      in: path
      name: repo_id
      required: true
      schema:
        type: string
        example: example_id
        minLength: 3
        maxLength: 128
      description: >-
        The repo ID of the repository. Repo _name_ can be used instead of the
        ID, but usage of ID for permanent linking and API requests is preferred.
    OtherRefParam:
      in: query
      name: other_id
      description: A reference to a source version from which changes will be taken
      schema:
        type: string
        example: example_id
        minLength: 3
        maxLength: 128
  responses:
    ComparisonList:
      description: A list of tree comparison objects
      content:
        application/json:
          schema:
            type: object
            properties:
              object:
                type: string
                enum:
                  - ComparisonItem
              items:
                type: array
                items:
                  $ref: '#/components/schemas/ComparisonItem'
              cascaded_changes_count:
                type: integer
                format: int64
                description: Number of cascaded changes, for insight of total compare size
            required:
              - object
              - items
              - cascaded_changes_count
  schemas:
    ComparisonItem:
      description: >-
        Describes a comparison result at a single path. At least one of
        base/other items must be present.
      type: object
      properties:
        base_item:
          $ref: '#/components/schemas/FileEntry'
        other_item:
          $ref: '#/components/schemas/FileEntry'
        status:
          $ref: '#/components/schemas/ObjectStatus'
      required:
        - status
    FileEntry:
      type: object
      properties:
        path:
          type: string
          example: hello.cc
        prev_path:
          type: string
          description: Optional hint in case the item was renamed or moved
        status:
          $ref: '#/components/schemas/ObjectStatus'
        mode:
          $ref: '#/components/schemas/FileMode'
        mtime:
          type: string
          format: date-time
        blob:
          type: object
          properties:
            storage_uri:
              $ref: '#/components/schemas/StorageUri'
            storage_backend:
              $ref: '#/components/schemas/StorageBackend'
            size:
              type: integer
              format: int64
              description: Size in bytes
            sha:
              type: string
          required:
            - storage_uri
            - storage_backend
            - size
            - sha
      required:
        - path
        - status
        - size
        - mode
    ObjectStatus:
      type: integer
      enum:
        - 1
        - 2
        - 3
        - 4
      description: 'One of: 1 - INTACT, 2 - ADDED, 3 - MODIFIED, 4 - DELETED'
      x-ogen-enum-naming:
        '1': ObjectStatus_INTACT
        '2': ObjectStatus_ADDED
        '3': ObjectStatus_MODIFIED
        '4': ObjectStatus_DELETED
    FileMode:
      type: integer
      description: The file mode (as Unix mode)
      enum:
        - 16877
        - 33188
        - 33261
        - 40960
      x-ogen-enum-naming:
        '16877': FileMode_TREE
        '33188': FileMode_FILE
        '33261': FileMode_EXECUTABLE
        '40960': FileMode_SYMLINK
    StorageUri:
      type: string
      description: Coupled with storage_backend, a uri to storage location
      example: repo_id/2aae6c35c94fcfb415dbe95f408b9ce91ee846ed
    StorageBackend:
      type: integer
      enum:
        - 1
        - 2
      description: 'One of: 1 - EFS, 2 - S3'
      x-ogen-enum-naming:
        '1': StorageBackend_EFS
        '2': StorageBackend_S3
  securitySchemes:
    OAuth2:
      type: oauth2
      x-tokenInfoFunc: src.token_info.token_auth
      description: This API uses OAuth 2 with the implicit grant flow
      flows:
        implicit:
          authorizationUrl: https://auth.diversion.dev/oauth2/authorize
          scopes:
            coreapi/read: Operations with no possible side-effects
            coreapi/write: Modifying operations
            coreapi/admin: >-
              Organizational operations like adding a repo or changing repo
              properties

````