Skip to content

Commit 57cae87

Browse files
angavrilovspearce
authored andcommitted
Add options to control the search for copies in blame.
On huge repositories, -C -C can be way too slow to be unconditionally enabled, and it can also be useful to control its precision. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
1 parent fbc0e7a commit 57cae87

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

git-gui.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,8 @@ set default_config(user.email) {}
642642
set default_config(gui.matchtrackingbranch) false
643643
set default_config(gui.pruneduringfetch) false
644644
set default_config(gui.trustmtime) false
645+
set default_config(gui.fastcopyblame) false
646+
set default_config(gui.copyblamethreshold) 40
645647
set default_config(gui.diffcontext) 5
646648
set default_config(gui.commitmsgwidth) 75
647649
set default_config(gui.newbranchtemplate) {}

lib/blame.tcl

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@ variable group_colors {
3333
#ececec
3434
}
3535

36-
# Switches for original location detection
37-
#
38-
variable original_options [list -C -C]
39-
if {[git-version >= 1.5.3]} {
40-
lappend original_options -w ; # ignore indentation changes
41-
}
42-
4336
# Current blame data; cleared/reset on each load
4437
#
4538
field commit ; # input commit to blame
@@ -511,7 +504,6 @@ method _exec_blame {cur_w cur_d options cur_s} {
511504
method _read_blame {fd cur_w cur_d} {
512505
upvar #0 $cur_d line_data
513506
variable group_colors
514-
variable original_options
515507

516508
if {$fd ne $current_fd} {
517509
catch {close $fd}
@@ -684,6 +676,18 @@ method _read_blame {fd cur_w cur_d} {
684676
if {[eof $fd]} {
685677
close $fd
686678
if {$cur_w eq $w_asim} {
679+
# Switches for original location detection
680+
set threshold [get_config gui.copyblamethreshold]
681+
set original_options [list "-C$threshold"]
682+
683+
if {![is_config_true gui.fastcopyblame]} {
684+
# thorough copy search; insert before the threshold
685+
set original_options [linsert $original_options 0 -C]
686+
}
687+
if {[git-version >= 1.5.3]} {
688+
lappend original_options -w ; # ignore indentation changes
689+
}
690+
687691
_exec_blame $this $w_amov @amov_data \
688692
$original_options \
689693
[mc "Loading original location annotations..."]

lib/option.tcl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ proc do_options {} {
123123
{b gui.trustmtime {mc "Trust File Modification Timestamps"}}
124124
{b gui.pruneduringfetch {mc "Prune Tracking Branches During Fetch"}}
125125
{b gui.matchtrackingbranch {mc "Match Tracking Branches"}}
126+
{b gui.fastcopyblame {mc "Blame Copy Only On Changed Files"}}
127+
{i-20..200 gui.copyblamethreshold {mc "Minimum Letters To Blame Copy On"}}
126128
{i-0..99 gui.diffcontext {mc "Number of Diff Context Lines"}}
127129
{i-0..99 gui.commitmsgwidth {mc "Commit Message Text Width"}}
128130
{t gui.newbranchtemplate {mc "New Branch Name Template"}}

0 commit comments

Comments
 (0)