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>
This commit is contained in:
21
lib/diff.tcl
21
lib/diff.tcl
@ -84,17 +84,30 @@ proc show_diff {path w {lno {}}} {
|
|||||||
#
|
#
|
||||||
if {$m eq {_O}} {
|
if {$m eq {_O}} {
|
||||||
set max_sz [expr {128 * 1024}]
|
set max_sz [expr {128 * 1024}]
|
||||||
|
set type unknown
|
||||||
if {[catch {
|
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 content [file readlink $path]
|
||||||
set sz [string length $content]
|
set sz [string length $content]
|
||||||
} else {
|
}
|
||||||
|
file {
|
||||||
set fd [open $path r]
|
set fd [open $path r]
|
||||||
fconfigure $fd -eofchar {}
|
fconfigure $fd -eofchar {}
|
||||||
set content [read $fd $max_sz]
|
set content [read $fd $max_sz]
|
||||||
close $fd
|
close $fd
|
||||||
set sz [file size $path]
|
set sz [file size $path]
|
||||||
}
|
}
|
||||||
|
default {
|
||||||
|
error "'$type' not supported"
|
||||||
|
}
|
||||||
|
}
|
||||||
} err ]} {
|
} err ]} {
|
||||||
set diff_active 0
|
set diff_active 0
|
||||||
unlock_index
|
unlock_index
|
||||||
@ -103,7 +116,9 @@ proc show_diff {path w {lno {}}} {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
$ui_diff conf -state normal
|
$ui_diff conf -state normal
|
||||||
if {![catch {set type [exec file $path]}]} {
|
if {$type eq {submodule}} {
|
||||||
|
$ui_diff insert end "* Git Repository (subproject)\n" d_@
|
||||||
|
} elseif {![catch {set type [exec file $path]}]} {
|
||||||
set n [string length $path]
|
set n [string length $path]
|
||||||
if {[string equal -length $n $path $type]} {
|
if {[string equal -length $n $path $type]} {
|
||||||
set type [string range $type $n end]
|
set type [string range $type $n end]
|
||||||
|
Reference in New Issue
Block a user