diff: add --ita-[in]visible-in-index

The option --ita-invisible-in-index exposes the "ita_invisible_in_index" diff flag to outside to allow easier experimentation with this new mode. The "plan" is to make --ita-invisible-in-index default to keep consistent behavior with 'status' and 'commit', but a bunch other commands like 'apply', 'merge', 'reset'.... need to be taken into consideration as well. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Oct 24, 2016 at 17:42 UTC b42b45191950a4ac39f6f5ae042c15ad114da79b
3 files changed +15 -1
Documentation/diff-options.txt
+8
@@ -570,5 +570,13 @@ endif::git-format-patch[]
570 --line-prefix=<prefix>::
571 Prepend an additional prefix to every line of output.
572
573 +--ita-invisible-in-index::
574 + By default entries added by "git add -N" appear as an existing
575 + empty file in "git diff" and a new file in "git diff --cached".
576 + This option makes the entry appear as a new file in "git diff"
577 + and non-existent in "git diff --cached". This option could be
578 + reverted with `--ita-visible-in-index`. Both options are
579 + experimental and could be removed in future.
580 +
581 For more detailed explanation on these common options, see also
582 linkgit:gitdiffcore[7].
diff.c
+4
@@ -3951,6 +3951,10 @@ int diff_opt_parse(struct diff_options *options,
3951 return parse_submodule_opt(options, arg);
3952 else if (skip_prefix(arg, "--ws-error-highlight=", &arg))
3953 return parse_ws_error_highlight(options, arg);
3954 + else if (!strcmp(arg, "--ita-invisible-in-index"))
3955 + options->ita_invisible_in_index = 1;
3956 + else if (!strcmp(arg, "--ita-visible-in-index"))
3957 + options->ita_invisible_in_index = 0;
3958
3959 /* misc options */
3960 else if (!strcmp(arg, "-z"))
t/t2203-add-intent.sh
+3 -1
@@ -57,7 +57,9 @@ test_expect_success 'i-t-a entry is simply ignored' '
57 git add -N nitfol &&
58 git commit -m second &&
59 test $(git ls-tree HEAD -- nitfol | wc -l) = 0 &&
60 - test $(git diff --name-only HEAD -- nitfol | wc -l) = 1
60 + test $(git diff --name-only HEAD -- nitfol | wc -l) = 1 &&
61 + test $(git diff --name-only --ita-invisible-in-index HEAD -- nitfol | wc -l) = 0 &&
62 + test $(git diff --name-only --ita-invisible-in-index -- nitfol | wc -l) = 1
63 '
64
65 test_expect_success 'can commit with an unrelated i-t-a entry in index' '