Skip to content

Commit 267de8c

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 #2779 Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Pratyush Yadav <[email protected]>
1 parent ac08008 commit 267de8c

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
@@ -1948,6 +1948,7 @@ set all_icons(U$ui_index) file_merge
19481948
set all_icons(T$ui_index) file_statechange
19491949

19501950
set all_icons(_$ui_workdir) file_plain
1951+
set all_icons(A$ui_workdir) file_plain
19511952
set all_icons(M$ui_workdir) file_mod
19521953
set all_icons(D$ui_workdir) file_question
19531954
set all_icons(U$ui_workdir) file_merge
@@ -1974,6 +1975,7 @@ foreach i {
19741975
{A_ {mc "Staged for commit"}}
19751976
{AM {mc "Portions staged for commit"}}
19761977
{AD {mc "Staged for commit, missing"}}
1978+
{AA {mc "Intended to be added"}}
19771979

19781980
{_D {mc "Missing"}}
19791981
{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)