Skip to content

Commit d396f41

Browse files
committed
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 #2779 Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Pratyush Yadav <[email protected]>
1 parent 177f3d3 commit d396f41

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

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
@@ -554,7 +554,8 @@ proc apply_or_revert_hunk {x y revert} {
554554
if {$current_diff_side eq $ui_index} {
555555
set failed_msg [mc "Failed to unstage selected hunk."]
556556
lappend apply_cmd --reverse --cached
557-
if {[string index $mi 0] ne {M}} {
557+
set file_state [string index $mi 0]
558+
if {$file_state ne {M} && $file_state ne {A}} {
558559
unlock_index
559560
return
560561
}
@@ -567,7 +568,8 @@ proc apply_or_revert_hunk {x y revert} {
567568
lappend apply_cmd --cached
568569
}
569570

570-
if {[string index $mi 1] ne {M}} {
571+
set file_state [string index $mi 1]
572+
if {$file_state ne {M} && $file_state ne {A}} {
571573
unlock_index
572574
return
573575
}
@@ -659,7 +661,8 @@ proc apply_or_revert_range_or_line {x y revert} {
659661
set failed_msg [mc "Failed to unstage selected line."]
660662
set to_context {+}
661663
lappend apply_cmd --reverse --cached
662-
if {[string index $mi 0] ne {M}} {
664+
set file_state [string index $mi 0]
665+
if {$file_state ne {M} && $file_state ne {A}} {
663666
unlock_index
664667
return
665668
}
@@ -674,7 +677,8 @@ proc apply_or_revert_range_or_line {x y revert} {
674677
lappend apply_cmd --cached
675678
}
676679

677-
if {[string index $mi 1] ne {M}} {
680+
set file_state [string index $mi 1]
681+
if {$file_state ne {M} && $file_state ne {A}} {
678682
unlock_index
679683
return
680684
}

0 commit comments

Comments
 (0)