summaryrefslogtreecommitdiff
path: root/lib/blame.tcl
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-05-09 02:48:47 (GMT)
committerShawn O. Pearce <spearce@spearce.org>2007-05-09 02:48:47 (GMT)
commita0db0d61fbc447f13cb0aadf01c83eb193b22dc9 (patch)
tree900fc05999875ac255bb152a71f56f32b6672124 /lib/blame.tcl
parent3e45ee1ef268c73539903f89c737af89034d391f (diff)
downloadgit-a0db0d61fbc447f13cb0aadf01c83eb193b22dc9.zip
git-a0db0d61fbc447f13cb0aadf01c83eb193b22dc9.tar.gz
git-a0db0d61fbc447f13cb0aadf01c83eb193b22dc9.tar.bz2
git-gui: Generate blame on uncommitted working tree file
If the user doesn't give us a revision parameter to our blame subcommand then we can generate blame against the working tree file by passing the file path off to blame with the --contents argument. In this case we cannot obtain the contents of the file from the ODB; instead we must obtain the contents by reading the working directory file as-is. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'lib/blame.tcl')
-rw-r--r--lib/blame.tcl16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/blame.tcl b/lib/blame.tcl
index 37ce3e7..8ac0104 100644
--- a/lib/blame.tcl
+++ b/lib/blame.tcl
@@ -170,8 +170,12 @@ constructor new {i_commit i_path} {
bind $top <Visibility> "focus $top"
bind $top <Destroy> [list delete_this $this]
- set cmd [list git cat-file blob "$commit:$path"]
- set fd [open "| $cmd" r]
+ if {$commit eq {}} {
+ set fd [open $path r]
+ } else {
+ set cmd [list git cat-file blob "$commit:$path"]
+ set fd [open "| $cmd" r]
+ }
fconfigure $fd -blocking 0 -translation lf -encoding binary
fileevent $fd readable [cb _read_file $fd]
}
@@ -194,7 +198,13 @@ method _read_file {fd} {
if {[eof $fd]} {
close $fd
_status $this
- set cmd [list git blame -M -C --incremental $commit -- $path]
+ set cmd [list git blame -M -C --incremental]
+ if {$commit eq {}} {
+ lappend cmd --contents $path
+ } else {
+ lappend cmd $commit
+ }
+ lappend cmd -- $path
set fd [open "| $cmd" r]
fconfigure $fd -blocking 0 -translation lf -encoding binary
fileevent $fd readable [cb _read_blame $fd]