class Git::Commands::DiffIndex

Implements the ‘git diff-index` command

Compares a tree object to either the index or the working tree.

When ‘–cached` is given (`cached: true`) it compares the tree to the index (staged changes). Without `–cached` it compares the tree to the working tree, treating any file that differs from the index as changed even if the on-disk content is identical to the tree.

@example Compare HEAD tree to the working tree (raw output)

# git diff-index HEAD
Git::Commands::DiffIndex.new(ctx).call('HEAD')

@example Compare HEAD tree to the index (staged changes, raw output)

# git diff-index --cached HEAD
Git::Commands::DiffIndex.new(ctx).call('HEAD', cached: true)

@example Compare HEAD tree to the index, showing a patch

# git diff-index --cached --patch HEAD
Git::Commands::DiffIndex.new(ctx).call('HEAD', cached: true, patch: true)

@example Limit comparison to a specific path

# git diff-index --cached HEAD -- lib/
Git::Commands::DiffIndex.new(ctx).call('HEAD', 'lib/', cached: true)

@note ‘arguments` block audited against git-scm.com/docs/git-diff-index/2.53.0

@see git-scm.com/docs/git-diff-index git-diff-index documentation

@see Git::Commands

@api private