git-gui: Correct toggling of added/untracked status for new files.
New files also lack index data from diff-files therefore we cannot use their diff-files index data when we update-index. Instead we can use the fact that Git has them hardcoded as "0 0{40}" and do the same thing ourselves. This way you can toggle an untracked file into added status and back out to untracked. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Nov 19, 2006 at 01:20 UTC
51cc47fedaaea46a556aac7d4e32683abca1b57b
1 file changed
+5
-2
git-gui
+5
-2
@@ -1174,9 +1174,10 @@ proc short_path {path} {
1174
}
1175
1176
set next_icon_id 0
1177
+set null_sha1 [string repeat 0 40]
1178
1179
proc merge_state {path new_state {head_info {}} {index_info {}}} {
1179
- global file_states next_icon_id
1180
+ global file_states next_icon_id null_sha1
1181
1182
set s0 [string index $new_state 0]
1183
set s1 [string index $new_state 1]
@@ -1197,7 +1198,9 @@ proc merge_state {path new_state {head_info {}} {index_info {}}} {
1198
if {$s1 eq {?}} {set s1 [string index $state 1]} \
1199
elseif {$s1 eq {_}} {set s1 _}
1200
1200
- if {$s0 ne {_} && [string index $state 0] eq {_}
1201
+ if {$s0 eq {A} && $s1 eq {_} && $head_info eq {}} {
1202
+ set head_info [list 0 $null_sha1]
1203
+ } elseif {$s0 ne {_} && [string index $state 0] eq {_}
1204
&& $head_info eq {}} {
1205
set head_info $index_info
1206
}