From: Alexander Gavrilov <hidden> Date: 2016-06-15 22:45:13
This series improves git gui blame usability by providing
better integration with gitk, and thus supporting more ways
of navigating the history.
Viewing the history context is especially useful if the
repository is imported from a VCS without atomic commits,
and thus related changes are often fragmented into a sequence
of several commit objects.
Note: Show History Context won't work if gitk is unpatched.
Usage scenario:
1. Start git gui blame from an IDE macro; use
--line=... to immediately scroll to the same
position as the IDE editor.
2. Use 'Show History Context' to view the diff
and surrounding commits.
3. Use 'Blame parent commit' in gitk to explore
blame for other files touched by the same commit.
4. If the change is irrelevant (e.g. some variable
was renamed), close gitk and use 'Blame Parent Commit'
in Gui Blame to restart search.
GITK:
gitk: Allow overriding the default commit.
---
gitk | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
gitk: Support calling git gui blame from gitk.
---
gitk | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
GIT-GUI:
git-gui: Support starting gitk from Gui Blame
---
git-gui.sh | 1 +
lib/blame.tcl | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
lib/option.tcl | 1 +
3 files changed, 55 insertions(+), 2 deletions(-)
git-gui: Support passing blame to a parent commit.
---
lib/blame.tcl | 48 ++++++++++++++++++++++++++++++++++++++----------
1 files changed, 38 insertions(+), 10 deletions(-)
git-gui: Better positioning in Blame Parent Commit
---
lib/blame.tcl | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 61 insertions(+), 4 deletions(-)
git-gui: Allow specifying an initial line for git gui blame.
---
git-gui.sh | 13 +++++++++++--
lib/blame.tcl | 4 ++--
lib/browser.tcl | 2 +-
3 files changed, 14 insertions(+), 5 deletions(-)
DOCS:
Document new options of gui tools.
---
Documentation/config.txt | 14 ++++++++++++++
Documentation/git-gui.txt | 5 +++++
Documentation/gitk.txt | 5 +++++
3 files changed, 24 insertions(+), 0 deletions(-)
From: Alexander Gavrilov <hidden> Date: 2016-06-15 22:45:12
Other GUI tools may occasionally need to start
gitk and make it automatically select a certain
commit. This patch supports doing it using a new
command-line option.
Signed-off-by: Alexander Gavrilov <redacted>
---
gitk | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
@@ -418,10 +418,12 @@ proc stop_rev_list {view} { } proc reset_pending_select {selid} {- global pending_select mainheadid+ global pending_select mainheadid selectheadid if {$selid ne {}} { set pending_select $selid+ } elseif {$selectheadid ne {}} {+ set pending_select $selectheadid } else { set pending_select $mainheadid }
@@ -1609,6 +1611,7 @@ proc getcommit {id} { proc readrefs {} { global tagids idtags headids idheads tagobjid global otherrefids idotherrefs mainhead mainheadid+ global selecthead selectheadid foreach v {tagids idtags headids idheads otherrefids idotherrefs} { catch {unset $v}
@@ -1655,6 +1658,12 @@ proc readrefs {} { set mainhead [string range $thehead 11 end] } }+ set selectheadid {}+ if {$selecthead ne {}} {+ catch {+ set selectheadid [exec git rev-parse --verify $selecthead]+ }+ } } # skip over fake commits
@@ -9865,6 +9874,9 @@ if {![file isdirectory $gitdir]} { exit 1 }+set selecthead {}+set selectheadid {}+ set revtreeargs {} set cmdline_files {} set i 0
@@ -9876,6 +9888,9 @@ foreach arg $argv { set cmdline_files [lrange $argv [expr {$i + 1}] end] break }+ "--select-commit=*" {+ set selecthead [string range $arg 16 end]+ } "--argscmd=*" { set revtreeargscmd [string range $arg 10 end] }
@@ -9886,6 +9901,10 @@ foreach arg $argv { incr i }+if {$selecthead eq "HEAD"} {+ set selecthead {}+}+ if {$i >= [llength $argv] && $revtreeargs ne {}} { # no -- on command line, but some arguments (other than --argscmd) if {[catch {
From: Alexander Gavrilov <hidden> Date: 2016-06-15 22:45:13
Add a new item to the file list popup menu, that
calls git gui blame for the selected file, starting
with the first parent of the current commit.
Signed-off-by: Alexander Gavrilov <redacted>
---
gitk | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
From: Alexander Gavrilov <hidden> Date: 2016-06-15 22:45:13
Add a context menu command to load commits
that are within a certain time range from the
selected commit into gitk.
It can be useful for understanding of the code,
especially if the repository is imported from
a VCS that does not support atomic commits.
Signed-off-by: Alexander Gavrilov <redacted>
---
git-gui.sh | 1 +
lib/blame.tcl | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
lib/option.tcl | 1 +
3 files changed, 55 insertions(+), 2 deletions(-)
@@ -259,6 +259,9 @@ constructor new {i_commit i_path} {$w.ctxmaddcommand\-label[mc"Do Full Copy Detection"]\-command[cb_fullcopyblame]+$w.ctxmaddcommand\+-label[mc"Show History Context"]\+-command[cb_gitkcommit]foreachi$w_columns{for{setg0}{$g<[llength$group_colors]}{incrg}{
@@ -125,6 +125,7 @@ proc do_options {} {{bgui.matchtrackingbranch{mc"Match Tracking Branches"}}{bgui.fastcopyblame{mc"Blame Copy Only On Changed Files"}}{i-20..200gui.copyblamethreshold{mc"Minimum Letters To Blame Copy On"}}+{i-0..300gui.blamehistoryctx{mc"Blame History Context Radius (days)"}}{i-0..99gui.diffcontext{mc"Number of Diff Context Lines"}}{i-0..99gui.commitmsgwidth{mc"Commit Message Text Width"}}{tgui.newbranchtemplate{mc"New Branch Name Template"}}
From: Alexander Gavrilov <hidden> Date: 2016-06-15 22:45:13
Add a context menu item that switches the view to the
parent of the commit under cursor. It is useful to see
how the file looked before the change, and find older
changes in the same lines.
Signed-off-by: Alexander Gavrilov <redacted>
---
lib/blame.tcl | 48 ++++++++++++++++++++++++++++++++++++++----------
1 files changed, 38 insertions(+), 10 deletions(-)
From: Alexander Gavrilov <hidden> Date: 2016-06-15 22:45:13
Invoke diff-tree between the commit and its parent,
and use the hunks to fix the target line number,
accounting for addition and removal of lines.
Signed-off-by: Alexander Gavrilov <redacted>
---
lib/blame.tcl | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 61 insertions(+), 4 deletions(-)
@@ -984,19 +984,76 @@ method _blameparent {} {setdat[_get_click_amov_info$this]if{$datne{}}{setcmit[lindex$dat0]+setnew_path[lindex$dat1]if{[catch{setcparent[gitrev-parse--verify"$cmit^"]}]}{error_popup[strcat[mc"Cannot find parent commit:"]"\n\n$err"]return;}-_load_new_commit$this\-$cparent\-[lindex$dat1]\-[list[lindex$dat2]]+_kill$this++# 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{setfd[evalgit_readdiff-tree\+--unified=0$cparent$cmit$new_path]}err]}{+$statusstop[mc"Unable to display parent"]+error_popup[strcat[mc"Error loading diff:"]"\n\n$err"]+return+}++setr_orig_line[lindex$dat2]++fconfigure$fd\+-blocking0\+-encodingbinary\+-translationbinary+fileevent$fdreadable[cb_read_diff_load_commit\+$fd$cparent$new_path$r_orig_line]+setcurrent_fd$fd}}+method_read_diff_load_commit{fdcparentnew_pathtline}{+if{$fdne$current_fd}{+catch{close$fd}+return+}++while{[gets$fdline]>=0}{+if{[regexp{^@@-(\d+)(,(\d+))?\+(\d+)(,(\d+))?@@}$lineline\+old_lineoszold_sizenew_linensznew_size]}{++if{$oszeq{}}{setold_size1}+if{$nszeq{}}{setnew_size1}++if{$new_line<=$tline}{+if{[expr{$new_line+$new_size}]>$tline}{+# Target line within the hunk+setline_shift[expr{+($new_size-$old_size)*($tline-$new_line)/$new_size+}]+}else{+setline_shift[expr{$new_size-$old_size}]+}++setr_orig_line[expr{$r_orig_line-$line_shift}]+}+}+}++if{[eof$fd]}{+close$fd;+setcurrent_fd{}++_load_new_commit$this\+$cparent\+$new_path\+[list$r_orig_line]+}+}ifdeleted{catch{close$fd}}+method_show_tooltip{cur_wpos}{if{$tooltip_wmne{}}{_open_tooltip$this$cur_w
From: Alexander Gavrilov <hidden> Date: 2016-06-15 22:45:13
Add a command-line option to make git gui blame automatically
scroll to a specific line in the file. Useful for integration
with other tools.
Signed-off-by: Alexander Gavrilov <redacted>
---
git-gui.sh | 13 +++++++++++--
lib/blame.tcl | 4 ++--
lib/browser.tcl | 2 +-
3 files changed, 14 insertions(+), 5 deletions(-)
@@ -2345,7 +2354,7 @@ blame {putsstderr[mc"fatal: cannot stat path %s: No such file or directory"$path]exit1}-blame::new$head$path+blame::new$head$path$jump_spec}}return
@@ -58,7 +58,7 @@ field tooltip_t {} ; # Text widget in $tooltip_wmfieldtooltip_timer{};# Current timer event for our tooltipfieldtooltip_commit{};# Commit(s) in tooltip-constructornew{i_commiti_path}{+constructornew{i_commiti_pathi_jump}{globalcursor_ptrvariableactive_colorvariablegroup_colors
@@ -338,7 +338,7 @@ constructor new {i_commit i_path} {wmprotocol$topWM_DELETE_WINDOW"destroy $top"bind$top<Destroy>[cb_kill]-_load$this{}+_load$this$i_jump}method_kill{}{
@@ -772,6 +772,20 @@ gui.spellingdictionary:: the linkgit:git-gui[1]. When set to "none" spell checking is turned off.+gui.fastcopyblame::+ If true, 'git gui blame' uses '-C' instead of '-C -C' for original location+ detection. It makes blame significantly more usable on huge repositories.++gui.copyblamethreshold::+ Specifies the theshold to use in 'git gui blame' original location detection,+ measured in alphanumeric characters. See the linkgit:git-blame[1] manual+ for more information on copy detection.++gui.blamehistoryctx::+ Specifies the radius of history context (in days) to show in gitk for+ the selected commit when the corresponding context menu item is invoked.+ If this parameter is zero, all history is shown.+ help.browser:: Specify the browser that will be used to display help in the 'web' format. See linkgit:git-help[1].
@@ -65,6 +65,11 @@ git gui blame v0.99.8 Makefile:: example the file is read from the object database and not the working directory.+git gui blame --line=100 Makefile::++ Loads annotations as described above and automatically+ scrolls the view to center on line 100.+ git gui citool:: Make one commit and return to the shell when it is complete.
@@ -49,6 +49,11 @@ frequently used options. the history between two branches (i.e. the HEAD and the MERGE_HEAD) that modify the conflicted files.+--select-commit=<ref>::++ Automatically select the specified commit after loading the graph.+ Default behavior is equivalent to specifying '--select-commit=HEAD'.+ <revs>:: Limit the revisions to show. This can be either a single revision
From: Shawn O. Pearce <hidden> Date: 2016-06-15 22:45:13
Alexander Gavrilov [off-list ref] wrote:
Add a context menu command to load commits
that are within a certain time range from the
selected commit into gitk.
It can be useful for understanding of the code,
especially if the repository is imported from
a VCS that does not support atomic commits.
The git-gui part of this series is now staged in my pu branch.
If Paul is going to also apply this to gitk we can ship it in
the next feature release of Git (1.6.1).
--
Shawn.
From: Paul Mackerras <hidden> Date: 2016-06-15 22:45:13
Alexander Gavrilov writes:
Other GUI tools may occasionally need to start
gitk and make it automatically select a certain
commit. This patch supports doing it using a new
command-line option.
Thanks, applied, with some edits to the description.
Could you have used the existing pending_select for this? Was there a
reason not to use it?
Paul.
Why the parent commit rather than the current commit?
For the lines that the current commit *adds*, you know who is to blame
(the current commit). Once you know that, you are usually interested in
who is to blame for the lines that the current commit *removed*. To get
this information, you must "Blame the parent commit".
-- Hannes