summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e5ef6f9)
raw | patch | inline | side by side (parent: e5ef6f9)
author | Paul Mackerras <paulus@samba.org> | |
Tue, 23 Oct 2007 00:15:11 +0000 (10:15 +1000) | ||
committer | Paul Mackerras <paulus@samba.org> | |
Tue, 23 Oct 2007 00:15:11 +0000 (10:15 +1000) |
When the user has specified a list of paths, either on the command line
or when creating a view, gitk currently displays the diffs for all files
that a commit has modified, not just the ones that match the path list.
This is different from other git commands such as git log. This change
makes gitk behave the same as these other git commands by default, that
is, gitk only displays the diffs for files that match the path list.
There is now a checkbox labelled "Limit diffs to listed paths" in the
Edit/Preferences pane. If that is unchecked, gitk will display the
diffs for all files as before.
When gitk is run with the --merge flag, it will get the list of unmerged
files at startup, intersect that with the paths listed on the command line
(if any), and use that as the list of paths.
Signed-off-by: Paul Mackerras <paulus@samba.org>
or when creating a view, gitk currently displays the diffs for all files
that a commit has modified, not just the ones that match the path list.
This is different from other git commands such as git log. This change
makes gitk behave the same as these other git commands by default, that
is, gitk only displays the diffs for files that match the path list.
There is now a checkbox labelled "Limit diffs to listed paths" in the
Edit/Preferences pane. If that is unchecked, gitk will display the
diffs for all files as before.
When gitk is run with the --merge flag, it will get the list of unmerged
files at startup, intersect that with the paths listed on the command line
(if any), and use that as the list of paths.
Signed-off-by: Paul Mackerras <paulus@samba.org>
gitk | patch | blob | history |
index 41a1c69e19c52cc07afaf4c14fc6ef8a6178e541..248f5fbd04b267a42e1711293ce2ae0f0eb56d97 100755 (executable)
--- a/gitk
+++ b/gitk
global stuffsaved findmergefiles maxgraphpct
global maxwidth showneartags showlocalchanges
global viewname viewfiles viewargs viewperm nextviewnum
- global cmitmode wrapcomment datetimeformat
+ global cmitmode wrapcomment datetimeformat limitdiffs
global colors bgcolor fgcolor diffcolors diffcontext selectbgcolor
if {$stuffsaved} return
puts $f [list set showneartags $showneartags]
puts $f [list set showlocalchanges $showlocalchanges]
puts $f [list set datetimeformat $datetimeformat]
+ puts $f [list set limitdiffs $limitdiffs]
puts $f [list set bgcolor $bgcolor]
puts $f [list set fgcolor $fgcolor]
puts $f [list set colors $colors]
}
}
+proc path_filter {filter name} {
+ foreach p $filter {
+ set l [string length $p]
+ if {[string compare -length $l $p $name] == 0 &&
+ ([string length $name] == $l || [string index $name $l] eq "/")} {
+ return 1
+ }
+ }
+ return 0
+}
+
proc addtocflist {ids} {
- global treediffs cflist
- add_flist $treediffs($ids)
+ global treediffs cflist viewfiles curview limitdiffs
+
+ if {$limitdiffs && $viewfiles($curview) ne {}} {
+ set flist {}
+ foreach f $treediffs($ids) {
+ if {[path_filter $viewfiles($curview) $f]} {
+ lappend flist $f
+ }
+ }
+ } else {
+ set flist $treediffs($ids)
+ }
+ add_flist $flist
getblobdiffs $ids
}
global diffopts blobdifffd diffids env
global diffinhdr treediffs
global diffcontext
+ global limitdiffs viewfiles curview
set env(GIT_DIFF_OPTS) $diffopts
- if {[catch {set bdf [open [diffcmd $ids "-p -C --no-commit-id -U$diffcontext"] r]} err]} {
+ set cmd [diffcmd $ids "-p -C --no-commit-id -U$diffcontext"]
+ if {$limitdiffs && $viewfiles($curview) ne {}} {
+ set cmd [concat $cmd $viewfiles($curview)]
+ }
+ if {[catch {set bdf [open $cmd r]} err]} {
puts "error getting diffs: $err"
return
}
global maxwidth maxgraphpct diffopts
global oldprefs prefstop showneartags showlocalchanges
global bgcolor fgcolor ctext diffcolors selectbgcolor
- global uifont tabstop
+ global uifont tabstop limitdiffs
set top .gitkprefs
set prefstop $top
raise $top
return
}
- foreach v {maxwidth maxgraphpct diffopts showneartags showlocalchanges} {
+ foreach v {maxwidth maxgraphpct diffopts showneartags showlocalchanges \
+ limitdiffs} {
set oldprefs($v) [set $v]
}
toplevel $top
label $top.tabstopl -text "tabstop" -font optionfont
spinbox $top.tabstop -from 1 -to 20 -width 4 -textvariable tabstop
grid x $top.tabstopl $top.tabstop -sticky w
+ frame $top.ldiff
+ label $top.ldiff.l -text "Limit diffs to listed paths" -font optionfont
+ checkbutton $top.ldiff.b -variable limitdiffs
+ pack $top.ldiff.b $top.ldiff.l -side left
+ grid x $top.ldiff -sticky w
label $top.cdisp -text "Colors: press to choose"
$top.cdisp configure -font $uifont
proc prefscan {} {
global maxwidth maxgraphpct diffopts
- global oldprefs prefstop showneartags showlocalchanges
+ global oldprefs prefstop showneartags showlocalchanges limitdiffs
- foreach v {maxwidth maxgraphpct diffopts showneartags showlocalchanges} {
+ foreach v {maxwidth maxgraphpct diffopts showneartags showlocalchanges \
+ limitdiffs} {
set $v $oldprefs($v)
}
catch {destroy $prefstop}
proc prefsok {} {
global maxwidth maxgraphpct
global oldprefs prefstop showneartags showlocalchanges
- global charspc ctext tabstop
+ global charspc ctext tabstop limitdiffs
catch {destroy $prefstop}
unset prefstop
if {$maxwidth != $oldprefs(maxwidth)
|| $maxgraphpct != $oldprefs(maxgraphpct)} {
redisplay
- } elseif {$showneartags != $oldprefs(showneartags)} {
+ } elseif {$showneartags != $oldprefs(showneartags) ||
+ $limitdiffs != $oldprefs(limitdiffs)} {
reselectline
}
}
set maxrefs 20
set maxlinelen 200
set showlocalchanges 1
+set limitdiffs 1
set datetimeformat "%Y-%m-%d %H:%M:%S"
set colors {green red blue magenta darkgrey brown orange}
exit 1
}
+set mergeonly 0
set revtreeargs {}
set cmdline_files {}
set i 0
switch -- $arg {
"" { }
"-d" { set datemode 1 }
+ "--merge" {
+ set mergeonly 1
+ lappend revtreeargs $arg
+ }
"--" {
set cmdline_files [lrange $argv [expr {$i + 1}] end]
break
}
}
+if {$mergeonly} {
+ # find the list of unmerged files
+ set mlist {}
+ set nr_unmerged 0
+ if {[catch {
+ set fd [open "| git ls-files -u" r]
+ } err]} {
+ show_error {} . "Couldn't get list of unmerged files: $err"
+ exit 1
+ }
+ while {[gets $fd line] >= 0} {
+ set i [string first "\t" $line]
+ if {$i < 0} continue
+ set fname [string range $line [expr {$i+1}] end]
+ if {[lsearch -exact $mlist $fname] >= 0} continue
+ incr nr_unmerged
+ if {$cmdline_files eq {} || [path_filter $cmdline_files $fname]} {
+ lappend mlist $fname
+ }
+ }
+ catch {close $fd}
+ if {$mlist eq {}} {
+ if {$nr_unmerged == 0} {
+ show_error {} . "No files selected: --merge specified but\
+ no files are unmerged."
+ } else {
+ show_error {} . "No files selected: --merge specified but\
+ no unmerged files are within file limit."
+ }
+ exit 1
+ }
+ set cmdline_files $mlist
+}
+
set nullid "0000000000000000000000000000000000000000"
set nullid2 "0000000000000000000000000000000000000001"