Skip to content

Commit d4e890e

Browse files
committed
git-gui: Make sure we get errors from git-update-index
I'm seeing a lot of silent failures from git-update-index on Windows and this is leaving the index.lock file intact, which means users are later unable to perform additional operations. When the index is locked behind our back and we are unable to use it we may need to allow the user to delete the index lock and try again. However our UI state is probably not currect as we have assumed that some changes were applied but none of them actually did. A rescan is the easiest (in code anyway) solution to correct our UI to show what the index really has (or doesn't have). Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
1 parent bbbadf6 commit d4e890e

File tree

1 file changed

+52
-9
lines changed

1 file changed

+52
-9
lines changed

lib/index.tcl

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,55 @@
11
# git-gui index (add/remove) support
22
# Copyright (C) 2006, 2007 Shawn Pearce
33

4+
proc _delete_indexlock {} {
5+
if {[catch {file delete -- [gitdir index.lock]} err]} {
6+
error_popup [strcat [mc "Unable to unlock the index."] "\n\n$err"]
7+
}
8+
}
9+
10+
proc _close_updateindex {fd after} {
11+
fconfigure $fd -blocking 1
12+
if {[catch {close $fd} err]} {
13+
set w .indexfried
14+
toplevel $w
15+
wm title $w [strcat "[appname] ([reponame]): " [mc "Index Error"]]
16+
wm geometry $w "+[winfo rootx .]+[winfo rooty .]"
17+
pack [label $w.msg \
18+
-justify left \
19+
-anchor w \
20+
-text [strcat \
21+
[mc "Updating the Git index failed. A rescan will be automatically started to resynchronize git-gui."] \
22+
"\n\n$err"] \
23+
] -anchor w
24+
25+
frame $w.buttons
26+
button $w.buttons.continue \
27+
-text [mc "Continue"] \
28+
-command [list destroy $w]
29+
pack $w.buttons.continue -side right -padx 5
30+
button $w.buttons.unlock \
31+
-text [mc "Unlock Index"] \
32+
-command "destroy $w; _delete_indexlock"
33+
pack $w.buttons.unlock -side right
34+
pack $w.buttons -side bottom -fill x -pady 10 -padx 10
35+
36+
wm protocol $w WM_DELETE_WINDOW update
37+
bind $w.buttons.continue <Visibility> "
38+
grab $w
39+
focus $w.buttons.continue
40+
"
41+
tkwait window $w
42+
43+
$::main_status stop
44+
unlock_index
45+
rescan $after 0
46+
return
47+
}
48+
49+
unlock_index
50+
uplevel #0 $after
51+
}
52+
453
proc update_indexinfo {msg pathList after} {
554
global update_index_cp
655

@@ -41,9 +90,7 @@ proc write_update_indexinfo {fd pathList totalCnt batch msg after} {
4190
global file_states current_diff_path
4291

4392
if {$update_index_cp >= $totalCnt} {
44-
close $fd
45-
unlock_index
46-
uplevel #0 $after
93+
_close_updateindex $fd $after
4794
return
4895
}
4996

@@ -116,9 +163,7 @@ proc write_update_index {fd pathList totalCnt batch msg after} {
116163
global file_states current_diff_path
117164

118165
if {$update_index_cp >= $totalCnt} {
119-
close $fd
120-
unlock_index
121-
uplevel #0 $after
166+
_close_updateindex $fd $after
122167
return
123168
}
124169

@@ -201,9 +246,7 @@ proc write_checkout_index {fd pathList totalCnt batch msg after} {
201246
global file_states current_diff_path
202247

203248
if {$update_index_cp >= $totalCnt} {
204-
close $fd
205-
unlock_index
206-
uplevel #0 $after
249+
_close_updateindex $fd $after
207250
return
208251
}
209252

0 commit comments

Comments
 (0)