Skip to content

Commit 0f01b67

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 787bfe4 commit 0f01b67

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

git-gui/git-gui.sh

+2
Original file line numberDiff line numberDiff line change
@@ -2087,6 +2087,7 @@ set all_icons(U$ui_index) file_merge
20872087
set all_icons(T$ui_index) file_statechange
20882088
20892089
set all_icons(_$ui_workdir) file_plain
2090+
set all_icons(A$ui_workdir) file_plain
20902091
set all_icons(M$ui_workdir) file_mod
20912092
set all_icons(D$ui_workdir) file_question
20922093
set all_icons(U$ui_workdir) file_merge
@@ -2113,6 +2114,7 @@ foreach i {
21132114
{A_ {mc "Staged for commit"}}
21142115
{AM {mc "Portions staged for commit"}}
21152116
{AD {mc "Staged for commit, missing"}}
2117+
{AA {mc "Intended to be added"}}
21162118
21172119
{_D {mc "Missing"}}
21182120
{D_ {mc "Staged for removal"}}

git-gui/lib/diff.tcl

+8-4
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,8 @@ proc apply_or_revert_hunk {x y revert} {
582582
if {$current_diff_side eq $ui_index} {
583583
set failed_msg [mc "Failed to unstage selected hunk."]
584584
lappend apply_cmd --reverse --cached
585-
if {[string index $mi 0] ne {M}} {
585+
set file_state [string index $mi 0]
586+
if {$file_state ne {M} && $file_state ne {A}} {
586587
unlock_index
587588
return
588589
}
@@ -595,7 +596,8 @@ proc apply_or_revert_hunk {x y revert} {
595596
lappend apply_cmd --cached
596597
}
597598

598-
if {[string index $mi 1] ne {M}} {
599+
set file_state [string index $mi 1]
600+
if {$file_state ne {M} && $file_state ne {A}} {
599601
unlock_index
600602
return
601603
}
@@ -687,7 +689,8 @@ proc apply_or_revert_range_or_line {x y revert} {
687689
set failed_msg [mc "Failed to unstage selected line."]
688690
set to_context {+}
689691
lappend apply_cmd --reverse --cached
690-
if {[string index $mi 0] ne {M}} {
692+
set file_state [string index $mi 0]
693+
if {$file_state ne {M} && $file_state ne {A}} {
691694
unlock_index
692695
return
693696
}
@@ -702,7 +705,8 @@ proc apply_or_revert_range_or_line {x y revert} {
702705
lappend apply_cmd --cached
703706
}
704707

705-
if {[string index $mi 1] ne {M}} {
708+
set file_state [string index $mi 1]
709+
if {$file_state ne {M} && $file_state ne {A}} {
706710
unlock_index
707711
return
708712
}

0 commit comments

Comments
 (0)