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>
Shawn O. Pearce committed
Oct 23, 2007 at 16:55 UTC
d4e890e5de1ea7107d8d1b4134ab0144bbf27b8c
1 file changed
+52
-9
lib/index.tcl
+52
-9
@@ -1,6 +1,55 @@
1
# git-gui index (add/remove) support
2
# Copyright (C) 2006, 2007 Shawn Pearce
3
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
+
53
proc update_indexinfo {msg pathList after} {
54
global update_index_cp
55
@@ -41,9 +90,7 @@ proc write_update_indexinfo {fd pathList totalCnt batch msg after} {
90
global file_states current_diff_path
91
92
if {$update_index_cp >= $totalCnt} {
44
- close $fd
45
- unlock_index
46
- uplevel #0 $after
93
+ _close_updateindex $fd $after
94
return
95
}
96
@@ -116,9 +163,7 @@ proc write_update_index {fd pathList totalCnt batch msg after} {
163
global file_states current_diff_path
164
165
if {$update_index_cp >= $totalCnt} {
119
- close $fd
120
- unlock_index
121
- uplevel #0 $after
166
+ _close_updateindex $fd $after
167
return
168
}
169
@@ -201,9 +246,7 @@ proc write_checkout_index {fd pathList totalCnt batch msg after} {
246
global file_states current_diff_path
247
248
if {$update_index_cp >= $totalCnt} {
204
- close $fd
205
- unlock_index
206
- uplevel #0 $after
249
+ _close_updateindex $fd $after
250
return
251
}
252