Skip to content

Commit 95c5172

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 <johannes.schindelin@gmx.de> Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
1 parent c6ca5c1 commit 95c5172

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
@@ -2078,6 +2078,7 @@ set all_icons(U$ui_index) file_merge
20782078
set all_icons(T$ui_index) file_statechange
20792079

20802080
set all_icons(_$ui_workdir) file_plain
2081+
set all_icons(A$ui_workdir) file_plain
20812082
set all_icons(M$ui_workdir) file_mod
20822083
set all_icons(D$ui_workdir) file_question
20832084
set all_icons(U$ui_workdir) file_merge
@@ -2104,6 +2105,7 @@ foreach i {
21042105
{A_ {mc "Staged for commit"}}
21052106
{AM {mc "Portions staged for commit"}}
21062107
{AD {mc "Staged for commit, missing"}}
2108+
{AA {mc "Intended to be added"}}
21072109

21082110
{_D {mc "Missing"}}
21092111
{D_ {mc "Staged for removal"}}

git-gui/lib/diff.tcl

+8-4
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,8 @@ proc apply_or_revert_hunk {x y revert} {
568568
if {$current_diff_side eq $ui_index} {
569569
set failed_msg [mc "Failed to unstage selected hunk."]
570570
lappend apply_cmd --reverse --cached
571-
if {[string index $mi 0] ne {M}} {
571+
set file_state [string index $mi 0]
572+
if {$file_state ne {M} && $file_state ne {A}} {
572573
unlock_index
573574
return
574575
}
@@ -581,7 +582,8 @@ proc apply_or_revert_hunk {x y revert} {
581582
lappend apply_cmd --cached
582583
}
583584

584-
if {[string index $mi 1] ne {M}} {
585+
set file_state [string index $mi 1]
586+
if {$file_state ne {M} && $file_state ne {A}} {
585587
unlock_index
586588
return
587589
}
@@ -673,7 +675,8 @@ proc apply_or_revert_range_or_line {x y revert} {
673675
set failed_msg [mc "Failed to unstage selected line."]
674676
set to_context {+}
675677
lappend apply_cmd --reverse --cached
676-
if {[string index $mi 0] ne {M}} {
678+
set file_state [string index $mi 0]
679+
if {$file_state ne {M} && $file_state ne {A}} {
677680
unlock_index
678681
return
679682
}
@@ -688,7 +691,8 @@ proc apply_or_revert_range_or_line {x y revert} {
688691
lappend apply_cmd --cached
689692
}
690693

691-
if {[string index $mi 1] ne {M}} {
694+
set file_state [string index $mi 1]
695+
if {$file_state ne {M} && $file_state ne {A}} {
692696
unlock_index
693697
return
694698
}

0 commit comments

Comments
 (0)