|
1 | 1 | # git-gui index (add/remove) support |
2 | 2 | # Copyright (C) 2006, 2007 Shawn Pearce |
3 | 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 | + $::main_status stop |
| 50 | + unlock_index |
| 51 | + uplevel #0 $after |
| 52 | +} |
| 53 | + |
4 | 54 | proc update_indexinfo {msg pathList after} { |
5 | 55 | global update_index_cp |
6 | 56 |
|
@@ -35,10 +85,7 @@ proc write_update_indexinfo {fd pathList totalCnt batch after} { |
35 | 85 | global file_states current_diff_path |
36 | 86 |
|
37 | 87 | if {$update_index_cp >= $totalCnt} { |
38 | | - close $fd |
39 | | - unlock_index |
40 | | - $::main_status stop |
41 | | - uplevel #0 $after |
| 88 | + _close_updateindex $fd $after |
42 | 89 | return |
43 | 90 | } |
44 | 91 |
|
@@ -100,10 +147,7 @@ proc write_update_index {fd pathList totalCnt batch after} { |
100 | 147 | global file_states current_diff_path |
101 | 148 |
|
102 | 149 | if {$update_index_cp >= $totalCnt} { |
103 | | - close $fd |
104 | | - unlock_index |
105 | | - $::main_status stop |
106 | | - uplevel #0 $after |
| 150 | + _close_updateindex $fd $after |
107 | 151 | return |
108 | 152 | } |
109 | 153 |
|
@@ -175,10 +219,7 @@ proc write_checkout_index {fd pathList totalCnt batch after} { |
175 | 219 | global file_states current_diff_path |
176 | 220 |
|
177 | 221 | if {$update_index_cp >= $totalCnt} { |
178 | | - close $fd |
179 | | - unlock_index |
180 | | - $::main_status stop |
181 | | - uplevel #0 $after |
| 222 | + _close_updateindex $fd $after |
182 | 223 | return |
183 | 224 | } |
184 | 225 |
|
|
0 commit comments