diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-10-27 14:58:50 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-10-27 14:58:50 -0700 |
commit | 650360210afbd585f33ed622d3e700b1941b1ddb (patch) | |
tree | 52a6857344b7e569f5fa3557cf4cd7827166f7c9 /diff-lib.c | |
parent | Merge branch 'js/prepare-sequencer' (diff) | |
parent | commit: don't be fooled by ita entries when creating initial commit (diff) | |
download | tgif-650360210afbd585f33ed622d3e700b1941b1ddb.tar.xz |
Merge branch 'nd/ita-empty-commit'
When new paths were added by "git add -N" to the index, it was
enough to circumvent the check by "git commit" to refrain from
making an empty commit without "--allow-empty". The same logic
prevented "git status" to show such a path as "new file" in the
"Changes not staged for commit" section.
* nd/ita-empty-commit:
commit: don't be fooled by ita entries when creating initial commit
commit: fix empty commit creation when there's no changes but ita entries
diff: add --ita-[in]visible-in-index
diff-lib: allow ita entries treated as "not yet exist in index"
Diffstat (limited to 'diff-lib.c')
-rw-r--r-- | diff-lib.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/diff-lib.c b/diff-lib.c index 3007c8524c..52447466b5 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -214,6 +214,12 @@ int run_diff_files(struct rev_info *revs, unsigned int option) !is_null_oid(&ce->oid), ce->name, 0); continue; + } else if (revs->diffopt.ita_invisible_in_index && + ce_intent_to_add(ce)) { + 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, @@ -379,6 +385,14 @@ 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 (revs->diffopt.ita_invisible_in_index && + idx && ce_intent_to_add(idx)) { + 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))); @@ -521,7 +535,8 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt) return 0; } -int index_differs_from(const char *def, int diff_flags) +int index_differs_from(const char *def, int diff_flags, + int ita_invisible_in_index) { struct rev_info rev; struct setup_revision_opt opt; @@ -533,6 +548,7 @@ int index_differs_from(const char *def, int diff_flags) DIFF_OPT_SET(&rev.diffopt, QUICK); DIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS); rev.diffopt.flags |= diff_flags; + rev.diffopt.ita_invisible_in_index = ita_invisible_in_index; run_diff_index(&rev, 1); if (rev.pending.alloc) free(rev.pending.objects); |