• Duy Nguyen's avatar
    diff: turn --ita-invisible-in-index on by default · 0231ae71
    Duy Nguyen authored
    Due to the implementation detail of intent-to-add entries, the current
    "git diff" (i.e. no treeish or --cached argument) would show the
    changes in the i-t-a file, but it does not mark the file as new, while
    "diff --cached" would mark the file as new while showing its content
    as empty.
    
         $ git diff                     | $ diff --cached
        --------------------------------|-------------------------------
         diff --git a/new b/new         | diff --git a/new b/new
         index e69de29..5ad28e2 100644  | new file mode 100644
         --- a/new                      | index 0000000..e69de29
         +++ b/new                      |
         @@ -0,0 +1 @@                  |
         +haha                          |
    
    One evidence of the current output being wrong is that, the output
    from "git diff" (with ita entries) cannot be applied because it
    assumes empty files exist before applying.
    
    Turning on --ita-invisible-in-index [1] [2] would fix this. The result
    is "new file" line moving from "git diff --cached" to "git diff".
    
         $ git diff                     | $ diff --cached
        --------------------------------|-------------------------------
         diff --git a/new b/new         |
         new file mode 100644           |
         index 0000000..5ad28e2         |
         --- /dev/null                  |
         +++ b/new                      |
         @@ -0,0 +1 @@                  |
         +haha                          |
    
    This option is on by default in git-status [1] but we need more fixup
    in rename detection code [3]. Luckily we don't need to do anything
    else for the rename detection code in diff.c (wt-status.c uses a
    customized one).
    
    [1] 425a28e0 (diff-lib: allow ita entries treated as "not yet exist
        in index" - 2016-10-24)
    [2] b42b4519 (diff: add --ita-[in]visible-in-index - 2016-10-24)
    [3] bc3dca07 (Merge branch 'nd/ita-wt-renames-in-status' - 2018-01-23)
    Signed-off-by: Duy Nguyen's avatarNguyễn Thái Ngọc Duy <[email protected]>
    Signed-off-by: default avatarJunio C Hamano <[email protected]>
    0231ae71
t4011-diff-symlink.sh 3.43 KB