Skip to content

Commit dc2407f

Browse files
dschoGit for Windows Build Agent
authored andcommitted
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 git-for-windows#2779 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
1 parent d6f6df2 commit dc2407f

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

git-gui/git-gui.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,6 +1934,7 @@ set all_icons(U$ui_index) file_merge
19341934
set all_icons(T$ui_index) file_statechange
19351935

19361936
set all_icons(_$ui_workdir) file_plain
1937+
set all_icons(A$ui_workdir) file_plain
19371938
set all_icons(M$ui_workdir) file_mod
19381939
set all_icons(D$ui_workdir) file_question
19391940
set all_icons(U$ui_workdir) file_merge
@@ -1960,6 +1961,7 @@ foreach i {
19601961
{A_ {mc "Staged for commit"}}
19611962
{AM {mc "Portions staged for commit"}}
19621963
{AD {mc "Staged for commit, missing"}}
1964+
{AA {mc "Intended to be added"}}
19631965

19641966
{_D {mc "Missing"}}
19651967
{D_ {mc "Staged for removal"}}

git-gui/lib/diff.tcl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,8 @@ proc apply_or_revert_hunk {x y revert} {
556556
if {$current_diff_side eq $ui_index} {
557557
set failed_msg [mc "Failed to unstage selected hunk."]
558558
lappend apply_cmd --reverse --cached
559-
if {[string index $mi 0] ne {M}} {
559+
set file_state [string index $mi 0]
560+
if {$file_state ne {M} && $file_state ne {A}} {
560561
unlock_index
561562
return
562563
}
@@ -569,7 +570,8 @@ proc apply_or_revert_hunk {x y revert} {
569570
lappend apply_cmd --cached
570571
}
571572

572-
if {[string index $mi 1] ne {M}} {
573+
set file_state [string index $mi 1]
574+
if {$file_state ne {M} && $file_state ne {A}} {
573575
unlock_index
574576
return
575577
}
@@ -661,7 +663,8 @@ proc apply_or_revert_range_or_line {x y revert} {
661663
set failed_msg [mc "Failed to unstage selected line."]
662664
set to_context {+}
663665
lappend apply_cmd --reverse --cached
664-
if {[string index $mi 0] ne {M}} {
666+
set file_state [string index $mi 0]
667+
if {$file_state ne {M} && $file_state ne {A}} {
665668
unlock_index
666669
return
667670
}
@@ -676,7 +679,8 @@ proc apply_or_revert_range_or_line {x y revert} {
676679
lappend apply_cmd --cached
677680
}
678681

679-
if {[string index $mi 1] ne {M}} {
682+
set file_state [string index $mi 1]
683+
if {$file_state ne {M} && $file_state ne {A}} {
680684
unlock_index
681685
return
682686
}

0 commit comments

Comments
 (0)