]> git.ipfire.org Git - thirdparty/git.git/commitdiff
diff: add --ita-[in]visible-in-index
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Mon, 24 Oct 2016 10:42:20 +0000 (17:42 +0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 24 Oct 2016 17:47:51 +0000 (10:47 -0700)
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>
Documentation/diff-options.txt
diff.c
t/t2203-add-intent.sh

index 2d77a196269b2d50de9c661fa8869badf155730a..b249f6a2e7b97d8e249f79dfed1a023c8d29a78d 100644 (file)
@@ -570,5 +570,13 @@ endif::git-format-patch[]
 --line-prefix=<prefix>::
        Prepend an additional prefix to every line of output.
 
+--ita-invisible-in-index::
+       By default entries added by "git add -N" appear as an existing
+       empty file in "git diff" and a new file in "git diff --cached".
+       This option makes the entry appear as a new file in "git diff"
+       and non-existent in "git diff --cached". This option could be
+       reverted with `--ita-visible-in-index`. Both options are
+       experimental and could be removed in future.
+
 For more detailed explanation on these common options, see also
 linkgit:gitdiffcore[7].
diff --git a/diff.c b/diff.c
index a178ed39bc77988dcc6282d252002f5446305628..297e0340e93cdf3e14be14f03d41506756d48511 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -3951,6 +3951,10 @@ int diff_opt_parse(struct diff_options *options,
                return parse_submodule_opt(options, arg);
        else if (skip_prefix(arg, "--ws-error-highlight=", &arg))
                return parse_ws_error_highlight(options, arg);
+       else if (!strcmp(arg, "--ita-invisible-in-index"))
+               options->ita_invisible_in_index = 1;
+       else if (!strcmp(arg, "--ita-visible-in-index"))
+               options->ita_invisible_in_index = 0;
 
        /* misc options */
        else if (!strcmp(arg, "-z"))
index 2276e4e6b66b5bb6bb0efef310d3cf1c6d7494df..0e54f63cf79dcdab8abe50112a5c3f5b08010ccb 100755 (executable)
@@ -57,7 +57,9 @@ test_expect_success 'i-t-a entry is simply ignored' '
        git add -N nitfol &&
        git commit -m second &&
        test $(git ls-tree HEAD -- nitfol | wc -l) = 0 &&
-       test $(git diff --name-only HEAD -- nitfol | wc -l) = 1
+       test $(git diff --name-only HEAD -- nitfol | wc -l) = 1 &&
+       test $(git diff --name-only --ita-invisible-in-index HEAD -- nitfol | wc -l) = 0 &&
+       test $(git diff --name-only --ita-invisible-in-index -- nitfol | wc -l) = 1
 '
 
 test_expect_success 'can commit with an unrelated i-t-a entry in index' '