From ef73896b2b596fe07e86829e26839f37e2d7513a Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 19 Jan 2011 14:46:59 -0500 Subject: gitk: Remove unused $cdate array It was unused since commit 9f1afe05c3 ("gitk: New improved gitk"). Signed-off-by: Anders Kaseorg Signed-off-by: Paul Mackerras diff --git a/gitk b/gitk index 4cde0c4..fec07d3 100755 --- a/gitk +++ b/gitk @@ -1621,7 +1621,7 @@ proc readcommit {id} { } proc parsecommit {id contents listed} { - global commitinfo cdate + global commitinfo set inhdr 1 set comment {} @@ -1671,9 +1671,6 @@ proc parsecommit {id contents listed} { } set comment $newcomment } - if {$comdate != {}} { - set cdate($id) $comdate - } set commitinfo($id) [list $headline $auname $audate \ $comname $comdate $comment] } -- cgit v0.10.2-6-g49f6 From f5974d97af06bca1382c585a515c8e1920333eb7 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 19 Jan 2011 14:47:25 -0500 Subject: gitk: Remember time zones from author and commit timestamps When resolving a conflicted cherry-pick, this lets us pass GIT_AUTHOR_DATE to git citool with the correct timezone. It does this by making elements 2 and 4 of the commitinfo array entries, which store the author and committer dates of the commit, be 2-element lists storing the numerical date and timezone offset, rather than just the numerical date. Signed-off-by: Anders Kaseorg Signed-off-by: Paul Mackerras diff --git a/gitk b/gitk index fec07d3..8e15572 100755 --- a/gitk +++ b/gitk @@ -659,7 +659,7 @@ proc newvarc {view id} { if {![info exists commitinfo($id)]} { parsecommit $id $commitdata($id) 1 } - set cdate [lindex $commitinfo($id) 4] + set cdate [lindex [lindex $commitinfo($id) 4] 0] if {![string is integer -strict $cdate]} { set cdate 0 } @@ -1641,10 +1641,10 @@ proc parsecommit {id contents listed} { set line [split $line " "] set tag [lindex $line 0] if {$tag == "author"} { - set audate [lindex $line end-1] + set audate [lrange $line end-1 end] set auname [join [lrange $line 1 end-2] " "] } elseif {$tag == "committer"} { - set comdate [lindex $line end-1] + set comdate [lrange $line end-1 end] set comname [join [lrange $line 1 end-2] " "] } } @@ -11021,7 +11021,7 @@ proc prefsok {} { proc formatdate {d} { global datetimeformat if {$d ne {}} { - set d [clock format $d -format $datetimeformat] + set d [clock format [lindex $d 0] -format $datetimeformat] } return $d } -- cgit v0.10.2-6-g49f6 From 36242490cd012bcf5148475aaa1a5abb76e4ef66 Mon Sep 17 00:00:00 2001 From: Raphael Zimmerer Date: Tue, 19 Apr 2011 22:37:09 +0200 Subject: gitk: When a commit contains a note, mark it with a yellow box It is desirable to see at a glance which commits do contain notes. Therefore mark them with a yellow rectangle. That can be suppressed with `gitk --no-notes`. Signed-off-by: Raphael Zimmerer Signed-off-by: Paul Mackerras diff --git a/gitk b/gitk index 8e15572..3689c17 100755 --- a/gitk +++ b/gitk @@ -1671,8 +1671,9 @@ proc parsecommit {id contents listed} { } set comment $newcomment } + set hasnote [string first "\nNotes:\n" $contents] set commitinfo($id) [list $headline $auname $audate \ - $comname $comdate $comment] + $comname $comdate $comment $hasnote] } proc getcommit {id} { @@ -5896,6 +5897,9 @@ proc drawcmittext {id row col} { || [info exists idotherrefs($id)]} { set xt [drawtags $id $x $xt $y] } + if {[lindex $commitinfo($id) 6] > 0} { + set xt [drawnotesign $xt $y] + } set headline [lindex $commitinfo($id) 0] set name [lindex $commitinfo($id) 1] set date [lindex $commitinfo($id) 2] @@ -6342,6 +6346,17 @@ proc drawtags {id x xt y1} { return $xt } +proc drawnotesign {xt y} { + global linespc canv fgcolor + + set orad [expr {$linespc / 3}] + set t [$canv create rectangle [expr {$xt - $orad}] [expr {$y - $orad}] \ + [expr {$xt + $orad - 1}] [expr {$y + $orad - 1}] \ + -fill yellow -outline $fgcolor -width 1 -tags circle] + set xt [expr {$xt + $orad * 3}] + return $xt +} + proc xcoord {i level ln} { global canvx0 xspc1 xspc2 -- cgit v0.10.2-6-g49f6 From bb3e86a11946fdd1262e1be7c71065ba6d79d85a Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Sun, 24 Jul 2011 15:34:48 +1000 Subject: gitk: Update copyright Signed-off-by: Paul Mackerras diff --git a/gitk b/gitk index 3689c17..530b4c2 100755 --- a/gitk +++ b/gitk @@ -2,7 +2,7 @@ # Tcl ignores the next line -*- tcl -*- \ exec wish "$0" -- "$@" -# Copyright © 2005-2009 Paul Mackerras. All rights reserved. +# Copyright © 2005-2011 Paul Mackerras. All rights reserved. # This program is free software; it may be used, copied, modified # and distributed under the terms of the GNU General Public Licence, # either version 2, or (at your option) any later version. @@ -2813,7 +2813,7 @@ proc about {} { message $w.m -text [mc " Gitk - a commit viewer for git -Copyright \u00a9 2005-2010 Paul Mackerras +Copyright \u00a9 2005-2011 Paul Mackerras Use and redistribute under the terms of the GNU General Public License"] \ -justify center -aspect 400 -border 2 -bg white -relief groove -- cgit v0.10.2-6-g49f6 From c332f44514375fd8e70da2c347b7bb8f2bd240f4 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Mon, 4 Apr 2011 22:14:12 -0400 Subject: gitk: Fix file highlight when run in subdirectory The "highlight this only" and "highlight this too" commands in gitk add the path relative to $GIT_WORK_TREE to the "Find" input box. When the search (using git-diff-tree) is run, the paths are used unmodified, except for some shell escaping. Since the search is run from gitk's working directory, no commits matching the paths will be found if gitk was started in a subdirectory. Make the paths passed to git-diff-tree relative to gitk's working directory instead of being relative to $GIT_WORK_TREE. If, however, gitk is run outside of the working directory (e.g. with $GIT_WORK_TREE set), we still need to use the path relative to $GIT_WORK_TREE. Signed-off-by: Martin von Zweigbergk Signed-off-by: Paul Mackerras diff --git a/gitk b/gitk index 530b4c2..a1aec62 100755 --- a/gitk +++ b/gitk @@ -4527,12 +4527,17 @@ proc makepatterns {l} { proc do_file_hl {serial} { global highlight_files filehighlight highlight_paths gdttype fhl_list + global cdup if {$gdttype eq [mc "touching paths:"]} { if {[catch {set paths [shellsplit $highlight_files]}]} return set highlight_paths [makepatterns $paths] highlight_filelist - set gdtargs [concat -- $paths] + set relative_paths {} + foreach path $paths { + lappend relative_paths [file join $cdup $path] + } + set gdtargs [concat -- $relative_paths] } elseif {$gdttype eq [mc "adding/removing string:"]} { set gdtargs [list "-S$highlight_files"] } else { @@ -11641,6 +11646,10 @@ set stuffsaved 0 set patchnum 0 set lserial 0 set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == "true"}] +set cdup {} +if {$isworktree} { + set cdup [exec git rev-parse --show-cdup] +} setcoords makewindow catch { -- cgit v0.10.2-6-g49f6 From 9b6adf343350891384fef7252eefb404d0fee090 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Mon, 4 Apr 2011 22:14:13 -0400 Subject: gitk: Fix "show origin of this line" with separate work tree Running "show origin of this line" currently fails when the the work tree is not the parent of the git directory. Fix it by feeding git-blame paths relative to $GIT_WORK_TREE instead of "$GIT_DIR/..". Signed-off-by: Martin von Zweigbergk Signed-off-by: Paul Mackerras diff --git a/gitk b/gitk index a1aec62..4c99dd6 100755 --- a/gitk +++ b/gitk @@ -3589,7 +3589,7 @@ proc external_blame {parent_idx {line {}}} { proc show_line_source {} { global cmitmode currentid parents curview blamestuff blameinst global diff_menu_line diff_menu_filebase flist_menu_file - global nullid nullid2 gitdir + global nullid nullid2 gitdir cdup set from_index {} if {$cmitmode eq "tree"} { @@ -3642,7 +3642,7 @@ proc show_line_source {} { } else { lappend blameargs $id } - lappend blameargs -- [file join [file dirname $gitdir] $flist_menu_file] + lappend blameargs -- [file join $cdup $flist_menu_file] if {[catch { set f [open $blameargs r] } err]} { -- cgit v0.10.2-6-g49f6 From 0a2a979310c1ebc43d460fd8564981c9b3b99f07 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Mon, 4 Apr 2011 22:14:14 -0400 Subject: gitk: Fix "blame parent commit" with separate work tree Running "blame parent commit" currently brings up an empty blame view when the the work tree is not the parent of the git directory. Fix it by feeding git-blame paths relative to $GIT_WORK_TREE instead of "$GIT_DIR/..". Signed-off-by: Martin von Zweigbergk Signed-off-by: Paul Mackerras diff --git a/gitk b/gitk index 4c99dd6..8626467 100755 --- a/gitk +++ b/gitk @@ -3557,7 +3557,7 @@ proc make_relative {f} { } proc external_blame {parent_idx {line {}}} { - global flist_menu_file gitdir + global flist_menu_file cdup global nullid nullid2 global parentlist selectedline currentid @@ -3576,7 +3576,7 @@ proc external_blame {parent_idx {line {}}} { if {$line ne {} && $line > 1} { lappend cmdline "--line=$line" } - set f [file join [file dirname $gitdir] $flist_menu_file] + set f [file join $cdup $flist_menu_file] # Unfortunately it seems git gui blame doesn't like # being given an absolute path... set f [make_relative $f] -- cgit v0.10.2-6-g49f6 From 784b7e2f25ce2a812d6b2dcbe4d3a2ea93484bb4 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Mon, 4 Apr 2011 22:14:15 -0400 Subject: gitk: Fix "External diff" with separate work tree Running "External diff" to compare the index and work tree currently brings up an empty blame view when the work tree is not the parent of the git directory. This is because the file that is taken from the work tree is assumed to be in $GIT_DIR/../. Fix it by feeding the diff tool a path under $GIT_WORK_TREE instead of "$GIT_DIR/..". Signed-off-by: Martin von Zweigbergk Signed-off-by: Paul Mackerras diff --git a/gitk b/gitk index 8626467..5d15005 100755 --- a/gitk +++ b/gitk @@ -3364,10 +3364,10 @@ proc save_file_from_commit {filename output what} { proc external_diff_get_one_file {diffid filename diffdir} { global nullid nullid2 nullfile - global gitdir + global worktree if {$diffid == $nullid} { - set difffile [file join [file dirname $gitdir] $filename] + set difffile [file join $worktree $filename] if {[file exists $difffile]} { return $difffile } @@ -11650,6 +11650,7 @@ set cdup {} if {$isworktree} { set cdup [exec git rev-parse --show-cdup] } +set worktree [exec git rev-parse --show-toplevel] setcoords makewindow catch { -- cgit v0.10.2-6-g49f6 From 929f577e0a648dd1c90b92d8a3f6f1899f2fa0e2 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Mon, 4 Apr 2011 22:14:16 -0400 Subject: gitk: Put temporary directory inside .git When running "External diff" from gitk, the "from" and "to" files will first be copied into a directory that is currently ".git/../.gitk-tmp.$pid". When gitk is closed, the directory is deleted. When the work tree is not at ".git/.." (which is supported since the previous commit), that directory may not even be git-related and it does not seem unlikely that permissions may not allow the temporary directory to be created there. Move the directory inside .git instead. This introduces a regression in the case that the .git directory is readonly, but .git/.. is writeable. Signed-off-by: Martin von Zweigbergk Signed-off-by: Paul Mackerras diff --git a/gitk b/gitk index 5d15005..e263b49 100755 --- a/gitk +++ b/gitk @@ -3331,8 +3331,7 @@ proc gitknewtmpdir {} { global diffnum gitktmpdir gitdir if {![info exists gitktmpdir]} { - set gitktmpdir [file join [file dirname $gitdir] \ - [format ".gitk-tmp.%s" [pid]]] + set gitktmpdir [file join $gitdir [format ".gitk-tmp.%s" [pid]]] if {[catch {file mkdir $gitktmpdir} err]} { error_popup "[mc "Error creating temporary directory %s:" $gitktmpdir] $err" unset gitktmpdir -- cgit v0.10.2-6-g49f6 From da616db5e56a735ab3028c33b19af5136420dcb9 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Mon, 4 Apr 2011 22:14:17 -0400 Subject: gitk: Run 'git rev-parse --git-dir' only once It seems like gitk has been setting the global variable 'gitdir' at startup since aa81d97 (gitk: Fix Update menu item, 2006-02-28). It should therefore no longer be necessary to call the procedure with the same name (more than once to set the global variable). Remove the other call sites and use the global variable instead. Signed-off-by: Martin von Zweigbergk Signed-off-by: Paul Mackerras diff --git a/gitk b/gitk index e263b49..3872b76 100755 --- a/gitk +++ b/gitk @@ -9059,6 +9059,7 @@ proc exec_citool {tool_args {baseid {}}} { proc cherrypick {} { global rowmenuid curview global mainhead mainheadid + global gitdir set oldhead [exec git rev-parse HEAD] set dheads [descheads $rowmenuid] @@ -9087,7 +9088,7 @@ proc cherrypick {} { conflict.\nDo you wish to run git citool to\ resolve it?"]]} { # Force citool to read MERGE_MSG - file delete [file join [gitdir] "GITGUI_MSG"] + file delete [file join $gitdir "GITGUI_MSG"] exec_citool {} $rowmenuid } } else { @@ -9453,6 +9454,7 @@ proc refill_reflist {} { proc getallcommits {} { global allcommits nextarc seeds allccache allcwait cachedarcs allcupdate global idheads idtags idotherrefs allparents tagobjid + global gitdir if {![info exists allcommits]} { set nextarc 0 @@ -9460,7 +9462,7 @@ proc getallcommits {} { set seeds {} set allcwait 0 set cachedarcs 0 - set allccache [file join [gitdir] "gitk.cache"] + set allccache [file join $gitdir "gitk.cache"] if {![catch { set f [open $allccache r] set allcwait 1 -- cgit v0.10.2-6-g49f6 From 86e847bcbf2b7f8700bcb3f3eaf7d08801e0cbab Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Mon, 4 Apr 2011 22:14:18 -0400 Subject: gitk: Simplify calculation of gitdir Since 5024baa ([PATCH] Make gitk work when launched in a subdirectory, 2007-01-09), gitk has used 'git rev-parse --git-dir' to find the .git directory. However, gitk still first checks for the $GIT_DIR environment variable and that the value returned from git-rev-parse does not point to a file. Since git-rev-parse does both of these checks already, the checks can safely be removed from gitk. This makes the gitdir procedure small enough to inline. This cleanup introduces a UI regression in that the error message will now be "Cannot find a git repository here." even in the case where GIT_DIR points to a file, for which the error message was previously "Cannot find the git directory \"%s\".". It should be noted, though, that even before this patch, 'gitk --git-dir=path/to/some/file' would give the former error message. Signed-off-by: Martin von Zweigbergk Signed-off-by: Paul Mackerras diff --git a/gitk b/gitk index 3872b76..facf294 100755 --- a/gitk +++ b/gitk @@ -9,15 +9,6 @@ exec wish "$0" -- "$@" package require Tk -proc gitdir {} { - global env - if {[info exists env(GIT_DIR)]} { - return $env(GIT_DIR) - } else { - return [exec git rev-parse --git-dir] - } -} - # A simple scheduler for compute-intensive stuff. # The aim is to make sure that event handlers for GUI actions can # run at least every 50-100 ms. Unfortunately fileevent handlers are @@ -11523,14 +11514,10 @@ setui $uicolor setoptions # check that we can find a .git directory somewhere... -if {[catch {set gitdir [gitdir]}]} { +if {[catch {set gitdir [exec git rev-parse --git-dir]}]} { show_error {} . [mc "Cannot find a git repository here."] exit 1 } -if {![file isdirectory $gitdir]} { - show_error {} . [mc "Cannot find the git directory \"%s\"." $gitdir] - exit 1 -} set selecthead {} set selectheadid {} -- cgit v0.10.2-6-g49f6 From 74cb884faa2d4214e349879adda8adc73362d692 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Mon, 23 May 2011 22:44:08 -0400 Subject: gitk: Show modified files with separate work tree "git rev-parse --is-inside-work-tree" is currently used to determine whether to show modified files in gitk (the red and green fake commits). This does not work if the current directory is not inside the work tree, as can be the case e.g. if GIT_WORK_TREE is set. Instead, check if the repository is not bare and that we are not inside the .git directory. Signed-off-by: Martin von Zweigbergk Signed-off-by: Paul Mackerras diff --git a/gitk b/gitk index facf294..18e3626 100755 --- a/gitk +++ b/gitk @@ -9,6 +9,11 @@ exec wish "$0" -- "$@" package require Tk +proc hasworktree {} { + return [expr {[exec git rev-parse --is-bare-repository] == "false" && + [exec git rev-parse --is-inside-git-dir] == "false"}] +} + # A simple scheduler for compute-intensive stuff. # The aim is to make sure that event handlers for GUI actions can # run at least every 50-100 ms. Unfortunately fileevent handlers are @@ -459,11 +464,11 @@ proc updatecommits {} { global viewactive viewcomplete tclencoding global startmsecs showneartags showlocalchanges global mainheadid viewmainheadid viewmainheadid_orig pending_select - global isworktree + global hasworktree global varcid vposids vnegids vflags vrevs global show_notes - set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == "true"}] + set hasworktree [hasworktree] rereadrefs set view $curview if {$mainheadid ne $viewmainheadid_orig($view)} { @@ -5024,9 +5029,9 @@ proc dohidelocalchanges {} { # spawn off a process to do git diff-index --cached HEAD proc dodiffindex {} { global lserial showlocalchanges vfilelimit curview - global isworktree + global hasworktree - if {!$showlocalchanges || !$isworktree} return + if {!$showlocalchanges || !$hasworktree} return incr lserial set cmd "|git diff-index --cached HEAD" if {$vfilelimit($curview) ne {}} { @@ -11633,9 +11638,9 @@ set stopped 0 set stuffsaved 0 set patchnum 0 set lserial 0 -set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == "true"}] +set hasworktree [hasworktree] set cdup {} -if {$isworktree} { +if {[expr {[exec git rev-parse --is-inside-work-tree] == "true"}]} { set cdup [exec git rev-parse --show-cdup] } set worktree [exec git rev-parse --show-toplevel] -- cgit v0.10.2-6-g49f6 From de665fd3cfee674a62818246dfb158ecf81b2b76 Mon Sep 17 00:00:00 2001 From: Yggy King Date: Wed, 13 Jul 2011 01:30:26 -0700 Subject: gitk: Make "touching paths" search support backslashes Gitk can search for commits touching a specified path. The search text is always treated as a regular expression, regardless of the matching option selected (Exact, IgnCase, or Regexp). In particular, backslashes escape the next character. This is inconvenient on Windows systems, where backslashes are the norm for path specifiers, for example when copy/pasting from Windows Explorer or a cmd shell -- these copy-pasted paths must be manually modified in the gitk search text edit box before they will work. This change uses the match option "Exact" to mean that a slash is a slash, not part of a regular expression. Backslashes are converted to frontslashes before searching, thus allowing easy copy/pasting of paths on Windows systems. If the previous behaviour of "touching paths" search is desired, simply select the "Regexp" search mode. One potential drawback is that the default setting for the match option ($findtype in the code) is "Exact", and so this change alters the default behaviour, which may confuse users and lead to bug reports. Signed-off-by: Yggy King Signed-off-by: Paul Mackerras diff --git a/gitk b/gitk index 18e3626..a701e0d 100755 --- a/gitk +++ b/gitk @@ -4522,9 +4522,14 @@ proc makepatterns {l} { proc do_file_hl {serial} { global highlight_files filehighlight highlight_paths gdttype fhl_list - global cdup + global cdup findtype if {$gdttype eq [mc "touching paths:"]} { + # If "exact" match then convert backslashes to forward slashes. + # Most useful to support Windows-flavoured file paths. + if {$findtype eq [mc "Exact"]} { + set highlight_files [string map {"\\" "/"} $highlight_files] + } if {[catch {set paths [shellsplit $highlight_files]}]} return set highlight_paths [makepatterns $paths] highlight_filelist -- cgit v0.10.2-6-g49f6 From 811c70fc8369cfeae2f1e843c695c37e3b0c3109 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Mon, 19 Sep 2011 11:49:50 -0500 Subject: gitk: Make vi-style keybindings more vi-like When commit 6e2dda35 (Add new keybindings, 2005-09-22) added vi-style keybindings to gitk (an excellent idea!), instead of adopting the usual "hjkl = left, down, up, right" bindings used by less, vi, rogue, and many other programs, it used "ijkl = up, left, down, right" to mimic the inverted-T formation of the arrow keys on a qwerty keyboard, in the style of Lode runner. So using 'j' and 'k' to scroll through commits produces utterly confusing results to the vi user, as 'k' moves down and 'j' moves to the previous commit. Luckily most non-vi-users are probably using an alternate set of keys (cursor keys or z/x + n/p) anyway. Switch to the expected vi/nethack convention. Requested-by: Josh Triplett Signed-off-by: Jonathan Nieder Signed-off-by: Paul Mackerras diff --git a/gitk b/gitk index a701e0d..64ef3c4 100755 --- a/gitk +++ b/gitk @@ -2431,9 +2431,9 @@ proc makewindow {} { bindkey n "selnextline 1" bindkey z "goback" bindkey x "goforw" - bindkey i "selnextline -1" - bindkey k "selnextline 1" - bindkey j "goback" + bindkey k "selnextline -1" + bindkey j "selnextline 1" + bindkey h "goback" bindkey l "goforw" bindkey b prevfile bindkey d "$ctext yview scroll 18 units" @@ -2844,9 +2844,9 @@ proc keys {} { [mc "<%s-W> Close window" $M1T] [mc " Move to first commit"] [mc " Move to last commit"] -[mc ", p, i Move up one commit"] -[mc ", n, k Move down one commit"] -[mc ", z, j Go back in history list"] +[mc ", p, k Move up one commit"] +[mc ", n, j Move down one commit"] +[mc ", z, h Go back in history list"] [mc ", x, l Go forward in history list"] [mc " Move up one page in commit list"] [mc " Move down one page in commit list"] -- cgit v0.10.2-6-g49f6