Skip to content

Commit b42b451

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 425a28e commit b42b451

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

Documentation/diff-options.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,5 +570,13 @@ endif::git-format-patch[]
570570
--line-prefix=<prefix>::
571571
Prepend an additional prefix to every line of output.
572572

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+
573581
For more detailed explanation on these common options, see also
574582
linkgit:gitdiffcore[7].

diff.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3951,6 +3951,10 @@ int diff_opt_parse(struct diff_options *options,
39513951
return parse_submodule_opt(options, arg);
39523952
else if (skip_prefix(arg, "--ws-error-highlight=", &arg))
39533953
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;
39543958

39553959
/* misc options */
39563960
else if (!strcmp(arg, "-z"))

t/t2203-add-intent.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ test_expect_success 'i-t-a entry is simply ignored' '
5757
git add -N nitfol &&
5858
git commit -m second &&
5959
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
6163
'
6264

6365
test_expect_success 'can commit with an unrelated i-t-a entry in index' '

0 commit comments

Comments
 (0)