summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3e45ee1)
raw | patch | inline | side by side (parent: 3e45ee1)
author | Shawn O. Pearce <spearce@spearce.org> | |
Wed, 9 May 2007 02:48:47 +0000 (22:48 -0400) | ||
committer | Shawn O. Pearce <spearce@spearce.org> | |
Wed, 9 May 2007 02:48:47 +0000 (22:48 -0400) |
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>
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>
git-gui.sh | patch | blob | history | |
lib/blame.tcl | patch | blob | history |
diff --git a/git-gui.sh b/git-gui.sh
index e90cdde96c46af611aba61299303ebee650c4fcb..62b1a36a8a9d4939d90db2b4263b7355afcbda41 100755 (executable)
--- a/git-gui.sh
+++ b/git-gui.sh
}
blame {
set subcommand_args {rev? path?}
+ set head {}
set path {}
set is_path 0
foreach a $argv {
break
} elseif {$a eq {--}} {
if {$path ne {}} {
- if {$current_branch ne {}} usage
- set current_branch $path
+ if {$head ne {}} usage
+ set head $path
set path {}
}
set is_path 1
- } elseif {$current_branch eq {}} {
- if {$current_branch ne {}} usage
- set current_branch $a
+ } elseif {$head eq {}} {
+ if {$head ne {}} usage
+ set head $a
} else {
usage
}
}
unset is_path
- if {$current_branch eq {} && $path ne {}} {
+ if {$head eq {}} {
set current_branch [git symbolic-ref HEAD]
regsub ^refs/((heads|tags|remotes)/)? \
$current_branch {} current_branch
+ } else {
+ set current_branch $head
}
- if {$current_branch eq {} || $path eq {}} usage
- blame::new $current_branch $path
+
+ if {$path eq {}} usage
+ blame::new $head $path
return
}
citool -
diff --git a/lib/blame.tcl b/lib/blame.tcl
index 37ce3e7a86a828d35369f2e7b59a94456c13e637..8ac0104187e4a06fd70b93c68134d875613f7c32 100644 (file)
--- a/lib/blame.tcl
+++ b/lib/blame.tcl
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]
}
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]