diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2016-10-24 17:42:19 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-10-24 10:47:28 -0700 |
commit | 425a28e0a4edfc39585cec6b0b6368c0ad9dbf7e (patch) | |
tree | 453a583c0e244d2edb0f729f831e5d7c76f5894c /wt-status.c | |
parent | 21f862b498925194f8f1ebe8203b7a7df756555b (diff) | |
download | git-425a28e0a4edfc39585cec6b0b6368c0ad9dbf7e.tar.gz |
diff-lib: allow ita entries treated as "not yet exist in index"
When comparing the index and the working tree to show which paths are
new, and comparing the tree recorded in the HEAD and the index to see if
committing the contents recorded in the index would result in an empty
commit, we would want the former comparison to say "these are new paths"
and the latter to say "there is no change" for paths that are marked as
intent-to-add.
We made a similar attempt at d95d728a ("diff-lib.c: adjust position of
i-t-a entries in diff", 2015-03-16), which redefined the semantics of
these two comparison modes globally, which was a disaster and had to be
reverted at 78cc1a54 ("Revert "diff-lib.c: adjust position of i-t-a
entries in diff"", 2015-06-23).
To make sure we do not repeat the same mistake, introduce a new internal
diffopt option so that this different semantics can be asked for only by
callers that ask it, while making sure other unaudited callers will get
the same comparison result.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wt-status.c')
-rw-r--r-- | wt-status.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/wt-status.c b/wt-status.c index 9628c1d5d7..5b0965ef27 100644 --- a/wt-status.c +++ b/wt-status.c @@ -437,7 +437,7 @@ static void wt_status_collect_changed_cb(struct diff_queue_struct *q, switch (p->status) { case DIFF_STATUS_ADDED: - die("BUG: worktree status add???"); + d->mode_worktree = p->two->mode; break; case DIFF_STATUS_DELETED: @@ -547,6 +547,7 @@ static void wt_status_collect_changes_worktree(struct wt_status *s) setup_revisions(0, NULL, &rev, NULL); rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK; DIFF_OPT_SET(&rev.diffopt, DIRTY_SUBMODULES); + rev.diffopt.ita_invisible_in_index = 1; if (!s->show_untracked_files) DIFF_OPT_SET(&rev.diffopt, IGNORE_UNTRACKED_IN_SUBMODULES); if (s->ignore_submodule_arg) { @@ -570,6 +571,7 @@ static void wt_status_collect_changes_index(struct wt_status *s) setup_revisions(0, NULL, &rev, &opt); DIFF_OPT_SET(&rev.diffopt, OVERRIDE_SUBMODULE_CONFIG); + rev.diffopt.ita_invisible_in_index = 1; if (s->ignore_submodule_arg) { handle_ignore_submodules_arg(&rev.diffopt, s->ignore_submodule_arg); } else { @@ -605,6 +607,8 @@ static void wt_status_collect_changes_initial(struct wt_status *s) if (!ce_path_match(ce, &s->pathspec, NULL)) continue; + if (ce_intent_to_add(ce)) + continue; it = string_list_insert(&s->change, ce->name); d = it->util; if (!d) { @@ -911,6 +915,7 @@ static void wt_longstatus_print_verbose(struct wt_status *s) init_revisions(&rev, NULL); DIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV); + rev.diffopt.ita_invisible_in_index = 1; memset(&opt, 0, sizeof(opt)); opt.def = s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference; |