Class: Git::Commands::DiffIndex Private
- Defined in:
- lib/git/commands/diff_index.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
arguments block audited against https://git-scm.com/docs/git-diff-index/2.53.0
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.
Examples:
Compare HEAD tree to the working tree (raw output)
Compare HEAD tree to the working tree (raw output)
# git diff-index HEAD
Git::Commands::DiffIndex.new(ctx).call('HEAD')
Compare HEAD tree to the index (staged changes, raw output)
Compare HEAD tree to the index (staged changes, raw output)
# git diff-index --cached HEAD
Git::Commands::DiffIndex.new(ctx).call('HEAD', cached: true)
Compare HEAD tree to the index, showing a patch
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)
Limit comparison to a specific path
Limit comparison to a specific path
# git diff-index --cached HEAD -- lib/
Git::Commands::DiffIndex.new(ctx).call('HEAD', 'lib/', cached: true)
See Also:
Instance Method Summary collapse
Methods inherited from Base
allow_exit_status, arguments, #initialize, requires_git_version, skip_version_validation
Constructor Details
This class inherits a constructor from Git::Commands::Base
Instance Method Details
#call(tree_ish, **options) ⇒ Git::CommandLineResult #call(tree_ish, *paths, **options) ⇒ Git::CommandLineResult
Overloads:
-
#call(tree_ish, **options) ⇒ Git::CommandLineResult
Compare a tree to the index or working tree
Examples:
Compare HEAD to the working tree
# git diff-index HEAD DiffIndex.new(ctx).call('HEAD')Compare HEAD to the index (staged changes only)
# git diff-index --cached HEAD DiffIndex.new(ctx).call('HEAD', cached: true)Parameters:
-
tree_ish
(String)
—
the tree object to compare against (e.g.,
'HEAD', a commit SHA, or a tag name) -
options
(Hash)
—
command options
Options Hash (**options):
-
:m
(Boolean, nil)
— default:
nil
—
treat non-checked-out files as up to date
By default, files recorded in the index but not checked out are reported as deleted. This flag makes
git diff-indexreport all such files as up to date. -
:cached
(Boolean, nil)
— default:
nil
—
compare the tree to the index only (staged changes), without considering the working tree
-
:merge_base
(Boolean, nil)
— default:
nil
—
use the merge base between the tree-ish and
HEADrather than the tree-ish directlytree_ishmust be a commit when this option is used. -
:patch
(Boolean, nil)
— default:
nil
—
generate unified diff patch output
Alias: :p, :u
-
:no_patch
(Boolean, nil)
— default:
nil
—
suppress all diff output
Alias: :s
-
:raw
(Boolean, nil)
— default:
nil
—
generate diff in raw format (default output)
-
:patch_with_raw
(Boolean, nil)
— default:
nil
—
synonym for
patch: true, raw: true -
:unified
(Integer, String)
— default:
nil
—
number of context lines around diff hunks (e.g.,
3)Alias: :U
-
:output
(String)
— default:
nil
—
write diff output to a file instead of stdout
-
:output_indicator_new
(String)
— default:
nil
—
character for new lines in patch output
-
:output_indicator_old
(String)
— default:
nil
—
character for old lines in patch output
-
:output_indicator_context
(String)
— default:
nil
—
character for context lines in patch output
-
:indent_heuristic
(Boolean, nil)
— default:
nil
—
shift hunk boundaries for readability (
--indent-heuristic) -
:no_indent_heuristic
(Boolean, nil)
— default:
nil
—
do not shift hunk boundaries for readability (
--no-indent-heuristic) -
:minimal
(Boolean, nil)
— default:
nil
—
spend extra time to minimize diff size
-
:patience
(Boolean, nil)
— default:
nil
—
use patience diff algorithm
-
:histogram
(Boolean, nil)
— default:
nil
—
use histogram diff algorithm
-
:anchored
(String, Array<String>)
— default:
nil
—
anchor lines matching the given text to prevent them from appearing as additions or deletions (repeatable)
-
:diff_algorithm
(String)
— default:
nil
—
diff algorithm to use
Accepted values:
'default','myers','minimal','patience','histogram'. -
:stat
(Boolean, String, nil)
— default:
nil
—
show a diffstat
Pass
truefor the default format, or a string like'80,40,5'for customwidth,name-width,countlimits. -
:stat_width
(Integer, String)
— default:
nil
—
override diffstat total width
-
:stat_name_width
(Integer, String)
— default:
nil
—
override diffstat filename column width
-
:stat_graph_width
(Integer, String)
— default:
nil
—
override diffstat graph column width
-
:stat_count
(Integer, String)
— default:
nil
—
limit diffstat to this many lines
-
:compact_summary
(Boolean, nil)
— default:
nil
—
include creation/deletion mode changes in stat
-
:numstat
(Boolean, nil)
— default:
nil
—
show per-file insertion/deletion counts (machine-friendly)
-
:shortstat
(Boolean, nil)
— default:
nil
—
show aggregate totals line only
-
:dirstat
(Boolean, String, nil)
— default:
nil
—
show distribution of changes per directory
Pass
truefor the default, or a string like'lines,cumulative,10'to pass params.Alias: :X
-
:cumulative
(Boolean, nil)
— default:
nil
—
synonym for
dirstat: 'cumulative' -
:dirstat_by_file
(Boolean, String, nil)
— default:
nil
—
synonym for
dirstat: 'files,...' -
:summary
(Boolean, nil)
— default:
nil
—
show condensed extended header information
-
:patch_with_stat
(Boolean, nil)
— default:
nil
—
synonym for
patch: true, stat: true -
:z
(Boolean, nil)
— default:
nil
—
use NUL as output field terminator instead of newline
-
:name_only
(Boolean, nil)
— default:
nil
—
show only changed file names
-
:name_status
(Boolean, nil)
— default:
nil
—
show changed file names with status letters
-
:submodule
(Boolean, String, nil)
— default:
nil
—
how to show submodule differences
Pass
truefor the default, or a string like'log'or'diff'for a format name. -
:color
(Boolean, String, nil)
— default:
nil
—
control diff colorization (
--color)Pass
truefor--coloror a string like'always'or'auto'for a specific mode. -
:no_color
(Boolean, nil)
— default:
nil
—
suppress colorized output (
--no-color) -
:color_moved
(Boolean, String, nil)
— default:
nil
—
color moved lines differently (
--color-moved)Pass
truefor the default, or a mode string such as'zebra'or'dimmed-zebra'. -
:no_color_moved
(Boolean, nil)
— default:
nil
—
disable moved-line coloring (
--no-color-moved) -
:color_moved_ws
(String)
— default:
nil
—
whitespace handling for moved-line color detection
Comma-separated list of modes, e.g.
'ignore-space-at-eol,ignore-space-change'. -
:no_color_moved_ws
(Boolean, nil)
— default:
nil
—
synonym for
color_moved_ws: 'no' -
:word_diff
(Boolean, String, nil)
— default:
nil
—
show a word-level diff
Pass
truefor the defaultplainmode, or a string like'color','porcelain', or'none'for a specific mode. -
:word_diff_regex
(String)
— default:
nil
—
regular expression defining word boundaries for word diff
-
:color_words
(Boolean, String, nil)
— default:
nil
—
equivalent to
word_diff: 'color'plus an optional word regex -
:ignore_cr_at_eol
(Boolean, nil)
— default:
nil
—
ignore carriage-return at end of line
-
:ignore_space_at_eol
(Boolean, nil)
— default:
nil
—
ignore whitespace changes at end of line
-
:ignore_space_change
(Boolean, nil)
— default:
nil
—
ignore changes in amount of whitespace
Alias: :b
-
:ignore_all_space
(Boolean, nil)
— default:
nil
—
ignore all whitespace when comparing lines
Alias: :w
-
:ignore_blank_lines
(Boolean, nil)
— default:
nil
—
ignore changes whose lines are all blank
-
:ignore_matching_lines
(String, Array<String>)
— default:
nil
—
ignore changes whose lines all match the given regex (repeatable)
Alias: :I
-
:check
(Boolean, nil)
— default:
nil
—
warn if changes introduce whitespace errors or conflict markers
-
:ws_error_highlight
(String)
— default:
nil
—
highlight whitespace errors in the given diff line types (e.g.
'new','old,new','all') -
:no_renames
(Boolean, nil)
— default:
nil
—
disable rename detection
-
:rename_empty
(Boolean, nil)
— default:
nil
—
use empty blobs as rename sources (
--rename-empty) -
:no_rename_empty
(Boolean, nil)
— default:
nil
—
disallow empty blobs as rename sources (
--no-rename-empty) -
:full_index
(Boolean, nil)
— default:
nil
—
show full blob SHA in index line
-
:binary
(Boolean, nil)
— default:
nil
—
output binary diff suitable for
git apply -
:abbrev
(Boolean, String, nil)
— default:
nil
—
abbreviate blob names in raw output
Pass
truefor the default, or an integer string like'10'for a specific length. -
:break_rewrites
(Boolean, String, nil)
— default:
nil
—
break total rewrites into delete-and-create pairs
Pass
truefor defaults, or a threshold string like'80%'or'50%/70%'for custom break and rename thresholds.Alias: :B
-
:find_renames
(Boolean, String, nil)
— default:
nil
—
detect renames
Pass
truefor the default threshold, or a string like'90%'for a custom similarity threshold.Alias: :M
-
:find_copies
(Boolean, String, nil)
— default:
nil
—
detect copies as well as renames
Pass
truefor the default threshold, or a string like'75%'for a custom similarity threshold.Alias: :C
-
:find_copies_harder
(Boolean, nil)
— default:
nil
—
inspect all unmodified files as copy sources (very expensive for large repos)
-
:irreversible_delete
(Boolean, nil)
— default:
nil
—
omit preimage for deleted files
Alias: :D
-
:l
(Integer, String)
— default:
nil
—
limit the number of rename/copy candidates considered during exhaustive detection
-
:diff_filter
(String)
— default:
nil
—
select only certain kinds of changed files
A string of status letters such as
'A','M','D','ACDM', or lowercase forms to exclude (e.g.'ad'excludes added and deleted). -
:S
(String)
— default:
nil
—
find changes that alter the occurrence count of the given string (pickaxe)
-
:G
(String)
— default:
nil
—
find changes whose patch text contains lines matching the given regex (pickaxe)
-
:find_object
(String)
— default:
nil
—
find changes involving the given object id
-
:pickaxe_all
(Boolean, nil)
— default:
nil
—
show all changes in a changeset when using
-Sor-G -
:pickaxe_regex
(Boolean, nil)
— default:
nil
—
treat the
-Sstring as an extended POSIX regular expression -
:O
(String)
— default:
nil
—
path to an orderfile controlling output file order
-
:skip_to
(String)
— default:
nil
—
discard files before the named file in the output
-
:rotate_to
(String)
— default:
nil
—
move files before the named file to end of output
-
:R
(Boolean, nil)
— default:
nil
—
swap the two diff inputs
-
:relative
(Boolean, String, nil)
— default:
nil
—
show paths relative to a directory (
--relative)Pass
trueto use the current directory, or a path string to name the directory explicitly. -
:no_relative
(Boolean, nil)
— default:
nil
—
use absolute paths in output (
--no-relative) -
:text
(Boolean, nil)
— default:
nil
—
treat all files as text
Alias: :a
-
:inter_hunk_context
(Integer, String)
— default:
nil
—
show context between diff hunks up to this many lines, fusing close hunks
-
:function_context
(Boolean, nil)
— default:
nil
—
show whole function as context for each change
Alias: :W
-
:exit_code
(Boolean, nil)
— default:
nil
—
exit with status 1 if differences are found, 0 if none
-
:quiet
(Boolean, nil)
— default:
nil
—
suppress all output
Implies
--exit-code. -
:ext_diff
(Boolean, nil)
— default:
nil
—
allow external diff helpers (
--ext-diff) -
:no_ext_diff
(Boolean, nil)
— default:
nil
—
disallow external diff helpers (
--no-ext-diff) -
:textconv
(Boolean, nil)
— default:
nil
—
allow external text-conversion filters (
--textconv) -
:no_textconv
(Boolean, nil)
— default:
nil
—
disallow external text-conversion filters (
--no-textconv) -
:ignore_submodules
(Boolean, String, nil)
— default:
nil
—
ignore submodule changes
Pass
truefor--ignore-submodules(equivalent to'all'), or a string such as'untracked','dirty','none', or'all'. -
:src_prefix
(String)
— default:
nil
—
source prefix for diff headers (e.g.
'a/') -
:dst_prefix
(String)
— default:
nil
—
destination prefix for diff headers (e.g.
'b/') -
:no_prefix
(Boolean, nil)
— default:
nil
—
omit source and destination prefixes
-
:default_prefix
(Boolean, nil)
— default:
nil
—
use the default
a/andb/prefixes -
:line_prefix
(String)
— default:
nil
—
prepend this prefix to every output line
-
:ita_invisible_in_index
(Boolean, nil)
— default:
nil
—
make
git add -Nentries appear as new files ingit diffand non-existent ingit diff --cached -
:max_depth
(Integer, String)
— default:
nil
—
maximum directory depth to descend for each pathspec (tree-to-tree diffs only)
Returns:
-
(Git::CommandLineResult)
—
the result of calling
git diff-index
Raises:
-
(ArgumentError)
—
if unsupported options are provided
-
(Git::FailedError)
—
if git exits outside the allowed range (exit code > 1)
-
tree_ish
(String)
—
-
#call(tree_ish, *paths, **options) ⇒ Git::CommandLineResult
Compare a tree to the index or working tree, limiting output to specific paths
Examples:
Compare HEAD to the index for a single directory
# git diff-index --cached HEAD -- lib/ DiffIndex.new(ctx).call('HEAD', 'lib/', cached: true)Compare HEAD to the working tree for multiple paths
# git diff-index HEAD -- lib/ spec/ DiffIndex.new(ctx).call('HEAD', 'lib/', 'spec/')Parameters:
-
tree_ish
(String)
—
the tree object to compare against
-
paths
(Array<String>)
—
pathspecs limiting which files are compared
-
options
(Hash)
—
command options (same as the single-argument overload)
Returns:
-
(Git::CommandLineResult)
—
the result of calling
git diff-index
Raises:
-
(ArgumentError)
—
if unsupported options are provided
-
(Git::FailedError)
—
if git exits outside the allowed range (exit code > 1)
-
tree_ish
(String)
—
|
|
# File 'lib/git/commands/diff_index.rb', line 164
|