git-gui: Assume untracked directories are Git submodules
If `git ls-files --others` returned us the name of a directory then it is because Git has decided that this directory itself contains a valid Git repository and its files shouldn't be listed as untracked for this repository. In such a case we should label the object as a Git repository and not just as a directory. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Sep 9, 2007 at 20:13 UTC
3b9dfde3d636aeb961318d41b3ab59f72414d010
1 file changed
+18
-3
lib/diff.tcl
+18
-3
@@ -84,17 +84,30 @@ proc show_diff {path w {lno {}}} {
84
#
85
if {$m eq {_O}} {
86
set max_sz [expr {128 * 1024}]
87
+ set type unknown
88
if {[catch {
88
- if {[file type $path] == {link}} {
89
+ set type [file type $path]
90
+ switch -- $type {
91
+ directory {
92
+ set type submodule
93
+ set content {}
94
+ set sz 0
95
+ }
96
+ link {
97
set content [file readlink $path]
98
set sz [string length $content]
91
- } else {
99
+ }
100
+ file {
101
set fd [open $path r]
102
fconfigure $fd -eofchar {}
103
set content [read $fd $max_sz]
104
close $fd
105
set sz [file size $path]
106
}
107
+ default {
108
+ error "'$type' not supported"
109
+ }
110
+ }
111
} err ]} {
112
set diff_active 0
113
unlock_index
@@ -103,7 +116,9 @@ proc show_diff {path w {lno {}}} {
116
return
117
}
118
$ui_diff conf -state normal
106
- if {![catch {set type [exec file $path]}]} {
119
+ if {$type eq {submodule}} {
120
+ $ui_diff insert end "* Git Repository (subproject)\n" d_@
121
+ } elseif {![catch {set type [exec file $path]}]} {
122
set n [string length $path]
123
if {[string equal -length $n $path $type]} {
124
set type [string range $type $n end]