summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 95b6a2d)
raw | patch | inline | side by side (parent: 95b6a2d)
author | Alexander Gavrilov <angavrilov@gmail.com> | |
Mon, 8 Sep 2008 07:18:52 +0000 (11:18 +0400) | ||
committer | Shawn O. Pearce <sop@google.com> | |
Fri, 12 Sep 2008 15:09:09 +0000 (08:09 -0700) |
Make Blame Parent Commit and Show History Context work
properly for lines blamed on the working copy.
Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <sop@google.com>
properly for lines blamed on the working copy.
Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <sop@google.com>
git-gui.sh | patch | blob | history | |
lib/blame.tcl | patch | blob | history |
diff --git a/git-gui.sh b/git-gui.sh
index 10d8a4422f151eda78a24ff533eb20c3d775d099..9fbee24c2edf46e616cbc950c7233bfb2286654b 100755 (executable)
--- a/git-gui.sh
+++ b/git-gui.sh
set is_3way_diff 0
set selected_commit_type new
+set nullid "0000000000000000000000000000000000000000"
+set nullid2 "0000000000000000000000000000000000000001"
+
######################################################################
##
## task management
diff --git a/lib/blame.tcl b/lib/blame.tcl
index 827c85d67f0b0f18d22b1399624e6819cf93f23f..0d635cd3a7152402e2363d8f9fb041bdd4835f14 100644 (file)
--- a/lib/blame.tcl
+++ b/lib/blame.tcl
}
method _gitkcommit {} {
+ global nullid
+
set dat [_get_click_amov_info $this]
if {$dat ne {}} {
set cmit [lindex $dat 0]
+
+ # If the line belongs to the working copy, use HEAD instead
+ if {$cmit eq $nullid} {
+ if {[catch {set cmit [git rev-parse --verify HEAD]} err]} {
+ error_popup [strcat [mc "Cannot find HEAD commit:"] "\n\n$err"]
+ return;
+ }
+ }
+
set radius [get_config gui.blamehistoryctx]
set cmdline [list --select-commit=$cmit]
}
method _blameparent {} {
+ global nullid
+
set dat [_get_click_amov_info $this]
if {$dat ne {}} {
set cmit [lindex $dat 0]
set new_path [lindex $dat 1]
- if {[catch {set cparent [git rev-parse --verify "$cmit^"]}]} {
+ # Allow using Blame Parent on lines modified in the working copy
+ if {$cmit eq $nullid} {
+ set parent_ref "HEAD"
+ } else {
+ set parent_ref "$cmit^"
+ }
+ if {[catch {set cparent [git rev-parse --verify $parent_ref]} err]} {
error_popup [strcat [mc "Cannot find parent commit:"] "\n\n$err"]
return;
}
# Generate a diff between the commit and its parent,
# and use the hunks to update the line number.
# Request zero context to simplify calculations.
- if {[catch {set fd [eval git_read diff-tree \
- --unified=0 $cparent $cmit $new_path]} err]} {
+ if {$cmit eq $nullid} {
+ set diffcmd [list diff-index --unified=0 $cparent -- $new_path]
+ } else {
+ set diffcmd [list diff-tree --unified=0 $cparent $cmit -- $new_path]
+ }
+ if {[catch {set fd [eval git_read $diffcmd]} err]} {
$status stop [mc "Unable to display parent"]
error_popup [strcat [mc "Error loading diff:"] "\n\n$err"]
return