diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2007-09-09 20:56:04 -0400 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2007-09-09 21:02:57 -0400 |
commit | 5f51ccd2598977694d383e9059e89cafb9ae1214 (patch) | |
tree | 8dc3b020c388cecb38039108ef149bd7a2a40f52 /lib | |
parent | Merge branch 'maint' (diff) | |
parent | git-gui: Trim trailing slashes from untracked submodule names (diff) | |
download | tgif-5f51ccd2598977694d383e9059e89cafb9ae1214.tar.xz |
Merge branch 'maint'
* maint:
git-gui: Trim trailing slashes from untracked submodule names
git-gui: Assume untracked directories are Git submodules
git-gui: handle "deleted symlink" diff marker
git-gui: show unstaged symlinks in diff viewer
Diffstat (limited to 'lib')
-rw-r--r-- | lib/diff.tcl | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/lib/diff.tcl b/lib/diff.tcl index b1129d551b..d013409640 100644 --- a/lib/diff.tcl +++ b/lib/diff.tcl @@ -84,12 +84,30 @@ proc show_diff {path w {lno {}}} { # if {$m eq {_O}} { set max_sz [expr {128 * 1024}] + set type unknown if {[catch { - set fd [open $path r] - fconfigure $fd -eofchar {} - set content [read $fd $max_sz] - close $fd - set sz [file size $path] + 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] + } + 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 @@ -98,7 +116,12 @@ proc show_diff {path w {lno {}}} { 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] @@ -198,6 +221,7 @@ proc read_diff {fd} { if {[string match {mode *} $line] || [string match {new file *} $line] || [string match {deleted file *} $line] + || [string match {deleted symlink} $line] || [string match {Binary files * and * differ} $line] || $line eq {\ No newline at end of file} || [regexp {^\* Unmerged path } $line]} { |