<commit_before>git-diff-index(1)
=================

NAME
----
git-diff-index - Compares content and mode of blobs between the index and repository


SYNOPSIS
--------
'git-diff-index' [-m] [--cached] [<common diff options>] <tree-ish> [<path>...]

DESCRIPTION
-----------
Compares the content and mode of the blobs found via a tree
object with the content of the current index and, optionally
ignoring the stat state of the file on disk.  When paths are
specified, compares only those named paths.  Otherwise all
entries in the index are compared.

OPTIONS
-------
include::diff-options.txt[]

<tree-ish>::
	The id of a tree object to diff against.

--cached::
	do not consider the on-disk file at all

-m::
	By default, files recorded in the index but not checked
	out are reported as deleted.  This flag makes
	"git-diff-index" say that all non-checked-out files are up
	to date.

Output format
-------------
include::diff-format.txt[]

Operating Modes
---------------
You can choose whether you want to trust the index file entirely
(using the '--cached' flag) or ask the diff logic to show any files
that don't match the stat state as being "tentatively changed".  Both
of these operations are very useful indeed.

Cached Mode
-----------
If '--cached' is specified, it allows you to ask:

	show me the differences between HEAD and the current index
	contents (the ones I'd write with a "git-write-tree")

For example, let's say that you have worked on your working directory, updated
some files in the index and are ready to commit. You want to see exactly
*what* you are going to commit is without having to write a new tree
object and compare it that way, and to do that, you just do

	git-diff-index --cached HEAD

Example: let's say I had renamed `commit.c` to `git-commit.c`, and I had
done an "git-update-index" to make that effective in the index file.
"git-diff-files" wouldn't show anything at all, since the index file
matches my working directory. But doing a "git-diff-index" does:

  torvalds@ppc970:~/git> git-diff-index --cached HEAD
  -100644 blob    4161aecc6700a2eb579e842af0b7f22b98443f74        commit.c
  +100644 blob    4161aecc6700a2eb579e842af0b7f22b98443f74        git-commit.c

You can trivially see that the above is a rename.

In fact, "git-diff-index --cached" *should* always be entirely equivalent to
actually doing a "git-write-tree" and comparing that. Except this one is much
nicer for the case where you just want to check where you are.

So doing a "git-diff-index --cached" is basically very useful when you are
asking yourself "what have I already marked for being committed, and 
what's the difference to a previous tree".

Non-cached Mode
---------------
The "non-cached" mode takes a different approach, and is potentially
the more useful of the two in that what it does can't be emulated with
a "git-write-tree" + "git-diff-tree". Thus that's the default mode.
The non-cached version asks the question:

  show me the differences between HEAD and the currently checked out
  tree - index contents _and_ files that aren't up-to-date<commit_msg>Minor grammar fixes for git-diff-index.txt<commit_after>git-diff-index(1)
=================

NAME
----
git-diff-index - Compares content and mode of blobs between the index and repository


SYNOPSIS
--------
'git-diff-index' [-m] [--cached] [<common diff options>] <tree-ish> [<path>...]

DESCRIPTION
-----------
Compares the content and mode of the blobs found via a tree
object with the content of the current index and, optionally
ignoring the stat state of the file on disk.  When paths are
specified, compares only those named paths.  Otherwise all
entries in the index are compared.

OPTIONS
-------
include::diff-options.txt[]

<tree-ish>::
	The id of a tree object to diff against.

--cached::
	do not consider the on-disk file at all

-m::
	By default, files recorded in the index but not checked
	out are reported as deleted.  This flag makes
	"git-diff-index" say that all non-checked-out files are up
	to date.

Output format
-------------
include::diff-format.txt[]

Operating Modes
---------------
You can choose whether you want to trust the index file entirely
(using the '--cached' flag) or ask the diff logic to show any files
that don't match the stat state as being "tentatively changed".  Both
of these operations are very useful indeed.

Cached Mode
-----------
If '--cached' is specified, it allows you to ask:

	show me the differences between HEAD and the current index
	contents (the ones I'd write with a "git-write-tree")

For example, let's say that you have worked on your working directory, updated
some files in the index and are ready to commit. You want to see exactly
*what* you are going to commit, without having to write a new tree
object and compare it that way, and to do that, you just do

	git-diff-index --cached HEAD

Example: let's say I had renamed `commit.c` to `git-commit.c`, and I had
done an "git-update-index" to make that effective in the index file.
"git-diff-files" wouldn't show anything at all, since the index file
matches my working directory. But doing a "git-diff-index" does:

  torvalds@ppc970:~/git> git-diff-index --cached HEAD
  -100644 blob    4161aecc6700a2eb579e842af0b7f22b98443f74        commit.c
  +100644 blob    4161aecc6700a2eb579e842af0b7f22b98443f74        git-commit.c

You can see easily that the above is a rename.

In fact, "git-diff-index --cached" *should* always be entirely equivalent to
actually doing a "git-write-tree" and comparing that. Except this one is much
nicer for the case where you just want to check where you are.

So doing a "git-diff-index --cached" is basically very useful when you are
asking yourself "what have I already marked for being committed, and 
what's the difference to a previous tree".

Non-cached Mode
---------------
The "non-cached" mode takes a different approach, and is potentially
the more useful of the two in that what it does can't be emulated with
a "git-write-tree" + "git-diff-tree". Thus that's the default mode.
The non-cached version asks the question:

  show me the differences between HEAD and the currently checked out
  tree - index contents _and_ files that aren't up-to-date
{'fraction_non_alphanumeric': 0.09864603481624758, 'fraction_numerical': 0.02192134107027724, 'mean_word_length': 3.4226657163221668, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2208186', 'n_tokens_mistral': 1878, 'n_tokens_neox': 1746, 'n_words': 894}