aboutsummaryrefslogtreecommitdiff
path: root/diff-lib.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-05-19 13:17:49 -0700
committerJunio C Hamano <gitster@pobox.com>2015-05-19 13:17:49 -0700
commitd0c692263f453f267ddd82b90b1a2fcff9d45f5f (patch)
treefbf5d1a1a60267b2e8904f180b97e65874fd506a /diff-lib.c
parent1ea28e149403ba92f95205f324cc3119fb92df07 (diff)
parentd95d728aba06a34394d15466045cbdabdada58a2 (diff)
downloadgit-d0c692263f453f267ddd82b90b1a2fcff9d45f5f.tar.gz
git-d0c692263f453f267ddd82b90b1a2fcff9d45f5f.tar.xz
Merge branch 'nd/diff-i-t-a'
After "git add -N", the path appeared in output of "git diff HEAD" and "git diff --cached HEAD", leading "git status" to classify it as "Changes to be committed". Such a path, however, is not yet to be scheduled to be committed. "git diff" showed the change to the path as modification, not as a "new file", in the header of its output. Treat such paths as "yet to be added to the index but Git already know about them"; "git diff HEAD" and "git diff --cached HEAD" should not talk about them, and "git diff" should show them as new files yet to be added to the index. * nd/diff-i-t-a: diff-lib.c: adjust position of i-t-a entries in diff
Diffstat (limited to 'diff-lib.c')
-rw-r--r--diff-lib.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/diff-lib.c b/diff-lib.c
index 241a8435e..0d8c5358e 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -212,6 +212,11 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
ce->sha1, !is_null_sha1(ce->sha1),
ce->name, 0);
continue;
+ } else if (ce->ce_flags & CE_INTENT_TO_ADD) {
+ diff_addremove(&revs->diffopt, '+', ce->ce_mode,
+ EMPTY_BLOB_SHA1_BIN, 0,
+ ce->name, 0);
+ continue;
}
changed = match_stat_with_submodule(&revs->diffopt, ce, &st,
@@ -376,6 +381,13 @@ static void do_oneway_diff(struct unpack_trees_options *o,
struct rev_info *revs = o->unpack_data;
int match_missing, cached;
+ /* i-t-a entries do not actually exist in the index */
+ if (idx && (idx->ce_flags & CE_INTENT_TO_ADD)) {
+ idx = NULL;
+ if (!tree)
+ return; /* nothing to diff.. */
+ }
+
/* if the entry is not checked out, don't examine work tree */
cached = o->index_only ||
(idx && ((idx->ce_flags & CE_VALID) || ce_skip_worktree(idx)));