git-gui: accommodate for intent-to-add files

As of Git v2.28.0, the diff for files staged via `git add -N` marks them
as new files. Git GUI was ill-prepared for that, and this patch teaches
Git GUI about them.

Please note that this will not even fix things with v2.28.0, as the
`rp/apply-cached-with-i-t-a` patches are required on Git's side, too.

This fixes https://github.com/git-for-windows/git/issues/2779

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
This commit is contained in:
Johannes Schindelin 2020-08-12 15:06:17 +00:00
Родитель 9596ddbd44
Коммит 02493cfc2f
2 изменённых файлов: 10 добавлений и 4 удалений

Просмотреть файл

@ -2079,6 +2079,7 @@ set all_icons(U$ui_index) file_merge
set all_icons(T$ui_index) file_statechange
set all_icons(_$ui_workdir) file_plain
set all_icons(A$ui_workdir) file_plain
set all_icons(M$ui_workdir) file_mod
set all_icons(D$ui_workdir) file_question
set all_icons(U$ui_workdir) file_merge
@ -2105,6 +2106,7 @@ foreach i {
{A_ {mc "Staged for commit"}}
{AM {mc "Portions staged for commit"}}
{AD {mc "Staged for commit, missing"}}
{AA {mc "Intended to be added"}}
{_D {mc "Missing"}}
{D_ {mc "Staged for removal"}}

Просмотреть файл

@ -582,7 +582,8 @@ proc apply_or_revert_hunk {x y revert} {
if {$current_diff_side eq $ui_index} {
set failed_msg [mc "Failed to unstage selected hunk."]
lappend apply_cmd --reverse --cached
if {[string index $mi 0] ne {M}} {
set file_state [string index $mi 0]
if {$file_state ne {M} && $file_state ne {A}} {
unlock_index
return
}
@ -595,7 +596,8 @@ proc apply_or_revert_hunk {x y revert} {
lappend apply_cmd --cached
}
if {[string index $mi 1] ne {M}} {
set file_state [string index $mi 1]
if {$file_state ne {M} && $file_state ne {A}} {
unlock_index
return
}
@ -687,7 +689,8 @@ proc apply_or_revert_range_or_line {x y revert} {
set failed_msg [mc "Failed to unstage selected line."]
set to_context {+}
lappend apply_cmd --reverse --cached
if {[string index $mi 0] ne {M}} {
set file_state [string index $mi 0]
if {$file_state ne {M} && $file_state ne {A}} {
unlock_index
return
}
@ -702,7 +705,8 @@ proc apply_or_revert_range_or_line {x y revert} {
lappend apply_cmd --cached
}
if {[string index $mi 1] ne {M}} {
set file_state [string index $mi 1]
if {$file_state ne {M} && $file_state ne {A}} {
unlock_index
return
}