Code

git-gui: Mark revision chooser tooltip for translation
[git.git] / lib / diff.tcl
index a1d5e523d2efd900c96c7905f8b0d6b76f4b2f32..d0134096409c78221fe5dd46e9af714e555965f5 100644 (file)
@@ -39,13 +39,13 @@ proc handle_empty_diff {} {
        set s $file_states($path)
        if {[lindex $s 0] ne {_M}} return
 
-       info_popup "No differences detected.
+       info_popup [mc "No differences detected.
 
-[short_path $path] has no changes.
+%s has no changes.
 
 The modification date of this file was updated by another application, but the content within the file was not changed.
 
-A rescan will be automatically started to find other files which may have the same state."
+A rescan will be automatically started to find other files which may have the same state." [short_path $path]]
 
        clear_diff
        display_file $path __
@@ -84,26 +84,44 @@ proc show_diff {path w {lno {}}} {
        #
        if {$m eq {_O}} {
                set max_sz [expr {128 * 1024}]
+               set type unknown
                if {[catch {
-                               if {[file type $path] == {link}} {
+                               set type [file type $path]
+                               switch -- $type {
+                               directory {
+                                       set type submodule
+                                       set content {}
+                                       set sz 0
+                               }
+                               link {
                                        set content [file readlink $path]
                                        set sz [string length $content]
-                               } else {
+                               }
+                               file {
                                        set fd [open $path r]
                                        fconfigure $fd -eofchar {}
                                        set content [read $fd $max_sz]
                                        close $fd
                                        set sz [file size $path]
                                }
+                               default {
+                                       error "'$type' not supported"
+                               }
+                               }
                        } err ]} {
                        set diff_active 0
                        unlock_index
                        ui_status "Unable to display [escape_path $path]"
-                       error_popup "Error loading file:\n\n$err"
+                   error_popup [append [mc "Error loading file:"] "\n\n$err"]
                        return
                }
                $ui_diff conf -state normal
-               if {![catch {set type [exec file $path]}]} {
+               if {$type eq {submodule}} {
+                       $ui_diff insert end [append \
+                               "* " \
+                               [mc "Git Repository (subproject)"] \
+                               "\n"] d_@
+               } elseif {![catch {set type [exec file $path]}]} {
                        set n [string length $path]
                        if {[string equal -length $n $path $type]} {
                                set type [string range $type $n end]
@@ -164,7 +182,7 @@ proc show_diff {path w {lno {}}} {
                set diff_active 0
                unlock_index
                ui_status "Unable to display [escape_path $path]"
-               error_popup "Error loading diff:\n\n$err"
+               error_popup [append [mc "Error loading diff:"] "\n\n$err"]
                return
        }
 
@@ -281,14 +299,14 @@ proc apply_hunk {x y} {
        set apply_cmd {apply --cached --whitespace=nowarn}
        set mi [lindex $file_states($current_diff_path) 0]
        if {$current_diff_side eq $ui_index} {
-               set mode unstage
+               set failed_msg [mc "Failed to unstage selected hunk."]
                lappend apply_cmd --reverse
                if {[string index $mi 0] ne {M}} {
                        unlock_index
                        return
                }
        } else {
-               set mode stage
+               set failed_msg [mc "Failed to stage selected hunk."]
                if {[string index $mi 1] ne {M}} {
                        unlock_index
                        return
@@ -313,7 +331,7 @@ proc apply_hunk {x y} {
                puts -nonewline $p $current_diff_header
                puts -nonewline $p [$ui_diff get $s_lno $e_lno]
                close $p} err]} {
-               error_popup "Failed to $mode selected hunk.\n\n$err"
+               error_popup [append $failed_msg "\n\n$err"]
                unlock_index
                return
        }