Function: selectCommitDiff()

selectCommitDiff(args: { after: string; before: string; hints?: { entityIds?: string[]; fileId?: string; includeUnchanged?: boolean; pluginKey?: string; schemaKeys?: string[]; }; lix: Lix; }): SelectQueryBuilder<any, "diff", DiffRow>

Compare two commits and return differences between their leaf entity states.

Reconstructs entity states at each commit by walking commit ancestry, then compares them. Unlike version-based diffs, this dynamically computes states without requiring version materialization.

Diff status meanings:

  • added: Entity exists only in after commit
  • removed: Entity exists only in before commit
  • modified: Entity exists in both with different change_ids
  • unchanged: Entity exists in both with same change_id

Uses fast-path optimization when includeUnchanged: false (default) by first identifying changed entity triples, then only reconstructing leaf states for those.

The hints parameter filters results at the database level for better performance:

  • includeUnchanged: Include unchanged entities (default: true). Set false for fast-path optimization.
  • fileId: Limit to specific file
  • pluginKey: Filter by plugin that created changes
  • schemaKeys: Include only specific entity types
  • entityIds: Include only specific entities

Examples

// Get changes between commits
const changes = await selectCommitDiff({
  lix,
  before: 'abc123',
  after: 'xyz789',
  hints: { includeUnchanged: false }
}).execute();
// Filter by file and status
const fileDiff = await selectCommitDiff({ lix, before, after })
  .where('diff.file_id', '=', 'messages.json')
  .where('diff.status', '!=', 'unchanged')
  .execute();

Parameters

ParameterType
args{ after: string; before: string; hints?: { entityIds?: string[]; fileId?: string; includeUnchanged?: boolean; pluginKey?: string; schemaKeys?: string[]; }; lix: Lix; }
args.afterstring
args.beforestring
args.hints?{ entityIds?: string[]; fileId?: string; includeUnchanged?: boolean; pluginKey?: string; schemaKeys?: string[]; }
args.hints.entityIds?string[]
args.hints.fileId?string
args.hints.includeUnchanged?boolean
args.hints.pluginKey?string
args.hints.schemaKeys?string[]
args.lixLix

Returns

SelectQueryBuilder<any, "diff", DiffRow>