From: Junio C Hamano Date: Tue, 19 May 2015 20:17:49 +0000 (-0700) Subject: Merge branch 'nd/diff-i-t-a' X-Git-Tag: v2.5.0-rc0~116 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/d0c692263f453f267ddd82b90b1a2fcff9d45f5f?ds=inline;hp=-c 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 --- d0c692263f453f267ddd82b90b1a2fcff9d45f5f diff --combined diff-lib.c index 241a8435eb,714501a7a3..0d8c5358e4 --- a/diff-lib.c +++ b/diff-lib.c @@@ -125,7 -125,7 +125,7 @@@ int run_diff_files(struct rev_info *rev dpath->next = NULL; memcpy(dpath->path, ce->name, path_len); dpath->path[path_len] = '\0'; - hashclr(dpath->sha1); + oidclr(&dpath->oid); memset(&(dpath->parent[0]), 0, sizeof(struct combine_diff_parent)*5); @@@ -155,7 -155,7 +155,7 @@@ if (2 <= stage) { int mode = nce->ce_mode; num_compare_stages++; - hashcpy(dpath->parent[stage-2].sha1, nce->sha1); + hashcpy(dpath->parent[stage-2].oid.hash, nce->sha1); dpath->parent[stage-2].mode = ce_mode_from_stat(nce, mode); dpath->parent[stage-2].status = DIFF_STATUS_MODIFIED; @@@ -212,6 -212,11 +212,11 @@@ 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, @@@ -339,14 -344,14 +344,14 @@@ static int show_modified(struct rev_inf memcpy(p->path, new->name, pathlen); p->path[pathlen] = 0; p->mode = mode; - hashclr(p->sha1); + oidclr(&p->oid); memset(p->parent, 0, 2 * sizeof(struct combine_diff_parent)); p->parent[0].status = DIFF_STATUS_MODIFIED; p->parent[0].mode = new->ce_mode; - hashcpy(p->parent[0].sha1, new->sha1); + hashcpy(p->parent[0].oid.hash, new->sha1); p->parent[1].status = DIFF_STATUS_MODIFIED; p->parent[1].mode = old->ce_mode; - hashcpy(p->parent[1].sha1, old->sha1); + hashcpy(p->parent[1].oid.hash, old->sha1); show_combined_diff(p, 2, revs->dense_combined_merges, revs); free(p); return 0; @@@ -376,6 -381,13 +381,13 @@@ static void do_oneway_diff(struct unpac 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)));