git-gui i18n: internationalize use of colon punctuation
[gitweb.git] / lib / index.tcl
index 3c1fce7475d362d1880d915ff4bdf168fda28593..3a3e534aeff723b080a7c9a758f51e81e88fae23 100644 (file)
@@ -8,36 +8,41 @@ proc _delete_indexlock {} {
 }
 
 proc _close_updateindex {fd after} {
+       global use_ttk NS
        fconfigure $fd -blocking 1
        if {[catch {close $fd} err]} {
                set w .indexfried
-               toplevel $w
+               Dialog $w
+               wm withdraw $w
                wm title $w [strcat "[appname] ([reponame]): " [mc "Index Error"]]
                wm geometry $w "+[winfo rootx .]+[winfo rooty .]"
-               pack [label $w.msg \
-                       -justify left \
-                       -anchor w \
-                       -text [strcat \
-                               [mc "Updating the Git index failed.  A rescan will be automatically started to resynchronize git-gui."] \
-                               "\n\n$err"] \
-                       ] -anchor w
-
-               frame $w.buttons
-               button $w.buttons.continue \
+               set s [mc "Updating the Git index failed.  A rescan will be automatically started to resynchronize git-gui."]
+               text $w.msg -yscrollcommand [list $w.vs set] \
+                       -width [string length $s] -relief flat \
+                       -borderwidth 0 -highlightthickness 0 \
+                       -background [get_bg_color $w]
+               $w.msg tag configure bold -font font_uibold -justify center
+               ${NS}::scrollbar $w.vs -command [list $w.msg yview]
+               $w.msg insert end $s bold \n\n$err {}
+               $w.msg configure -state disabled
+
+               ${NS}::button $w.continue \
                        -text [mc "Continue"] \
                        -command [list destroy $w]
-               pack $w.buttons.continue -side right -padx 5
-               button $w.buttons.unlock \
+               ${NS}::button $w.unlock \
                        -text [mc "Unlock Index"] \
                        -command "destroy $w; _delete_indexlock"
-               pack $w.buttons.unlock -side right
-               pack $w.buttons -side bottom -fill x -pady 10 -padx 10
+               grid $w.msg - $w.vs -sticky news
+               grid $w.unlock $w.continue - -sticky se -padx 2 -pady 2
+               grid columnconfigure $w 0 -weight 1
+               grid rowconfigure $w 0 -weight 1
 
                wm protocol $w WM_DELETE_WINDOW update
-               bind $w.buttons.continue <Visibility> "
+               bind $w.continue <Visibility> "
                        grab $w
-                       focus $w.buttons.continue
+                       focus %W
                "
+               wm deiconify $w
                tkwait window $w
 
                $::main_status stop
@@ -98,7 +103,11 @@ proc write_update_indexinfo {fd pathList totalCnt batch after} {
                set s $file_states($path)
                switch -glob -- [lindex $s 0] {
                A? {set new _O}
+               MT -
+               TM -
+               T_ {set new _T}
                M? {set new _M}
+               TD -
                D_ {set new _D}
                D? {set new _?}
                ?? {continue}
@@ -161,7 +170,12 @@ proc write_update_index {fd pathList totalCnt batch after} {
                AD {set new __}
                ?D {set new D_}
                _O -
+               AT -
                AM {set new A_}
+               TM -
+               MT -
+               _T {set new T_}
+               _U -
                U? {
                        if {[file exists $path]} {
                                set new M_
@@ -231,6 +245,7 @@ proc write_checkout_index {fd pathList totalCnt batch after} {
                switch -glob -- [lindex $file_states($path) 0] {
                U? {continue}
                ?M -
+               ?T -
                ?D {
                        puts -nonewline $fd "[encoding convertto $path]\0"
                        display_file $path ?_
@@ -252,6 +267,7 @@ proc unstage_helper {txt paths} {
                switch -glob -- [lindex $file_states($path) 0] {
                A? -
                M? -
+               T? -
                D? {
                        lappend pathList $path
                        if {$path eq $current_diff_path} {
@@ -275,7 +291,7 @@ proc do_unstage_selection {} {
 
        if {[array size selected_paths] > 0} {
                unstage_helper \
-                       {Unstaging selected files from commit} \
+                       [mc "Unstaging selected files from commit"] \
                        [array names selected_paths]
        } elseif {$current_diff_path ne {}} {
                unstage_helper \
@@ -293,10 +309,18 @@ proc add_helper {txt paths} {
        set after {}
        foreach path $paths {
                switch -glob -- [lindex $file_states($path) 0] {
+               _U -
+               U? {
+                       if {$path eq $current_diff_path} {
+                               unlock_index
+                               merge_stage_workdir $path
+                               return
+                       }
+               }
                _O -
                ?M -
                ?D -
-               U? {
+               ?T {
                        lappend pathList $path
                        if {$path eq $current_diff_path} {
                                set after {reshow_diff;}
@@ -319,7 +343,7 @@ proc do_add_selection {} {
 
        if {[array size selected_paths] > 0} {
                add_helper \
-                       {Adding selected files} \
+                       [mc "Adding selected files"] \
                        [array names selected_paths]
        } elseif {$current_diff_path ne {}} {
                add_helper \
@@ -332,14 +356,36 @@ proc do_add_all {} {
        global file_states
 
        set paths [list]
+       set untracked_paths [list]
        foreach path [array names file_states] {
                switch -glob -- [lindex $file_states($path) 0] {
                U? {continue}
                ?M -
+               ?T -
                ?D {lappend paths $path}
+               ?O {lappend untracked_paths $path}
+               }
+       }
+       if {[llength $untracked_paths]} {
+               set reply 0
+               switch -- [get_config gui.stageuntracked] {
+               no {
+                       set reply 0
+               }
+               yes {
+                       set reply 1
+               }
+               ask -
+               default {
+                       set reply [ask_popup [mc "Stage %d untracked files?" \
+                                                                         [llength $untracked_paths]]]
+               }
+               }
+               if {$reply} {
+                       set paths [concat $paths $untracked_paths]
                }
        }
-       add_helper {Adding all changed files} $paths
+       add_helper [mc "Adding all changed files"] $paths
 }
 
 proc revert_helper {txt paths} {
@@ -353,6 +399,7 @@ proc revert_helper {txt paths} {
                switch -glob -- [lindex $file_states($path) 0] {
                U? {continue}
                ?M -
+               ?T -
                ?D {
                        lappend pathList $path
                        if {$path eq $current_diff_path} {
@@ -367,7 +414,7 @@ proc revert_helper {txt paths} {
        # such distinction is needed in some languages. Previously, the
        # code used "Revert changes in" for both, but that can't work
        # in languages where 'in' must be combined with word from
-       # rest of string (in diffrent way for both cases of course).
+       # rest of string (in different way for both cases of course).
        #
        # FIXME: Unfortunately, even that isn't enough in some languages
        # as they have quite complex plural-form rules. Unfortunately,
@@ -409,11 +456,11 @@ proc do_revert_selection {} {
 
        if {[array size selected_paths] > 0} {
                revert_helper \
-                       {Reverting selected files} \
+                       [mc "Reverting selected files"] \
                        [array names selected_paths]
        } elseif {$current_diff_path ne {}} {
                revert_helper \
-                       "Reverting [short_path $current_diff_path]" \
+                       [mc "Reverting %s" [short_path $current_diff_path]] \
                        [list $current_diff_path]
        }
 }