git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] gitk: read and write a repository specific configuration file

From
Łukasz Stelmach <stlman@poczta.fm>
Date
Dec 2, 2012, 21:29 UTC
Message-ID
<1354483766-13925-1-git-send-email-stlman@poczta.fm>
In-Reply-To
<50BBC760.7030208@poczta.fm>

Enable gitk read and write repository specific configuration file: ".git/k" if the file exists. To make gitk use the local file simply create one, e.g. with the touch(1) command.

This is very useful if one uses different views for different repositories. Now there is no need to store all of them in ~/.gitk and make the views list needlesly long.

Signed-off-by: Łukasz Stelmach <stlman@poczta.fm>
---
 gitk-git/gitk |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/gitk-git/gitk b/gitk-git/gitk
index d93bd99..60cf4cd 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -2696,7 +2696,7 @@ proc doprogupdate {} {
 
 proc savestuff {w} {
     global canv canv2 canv3 mainfont textfont uifont tabstop
-    global stuffsaved findmergefiles maxgraphpct
+    global stuffsaved findmergefiles maxgraphpct gitdir
     global maxwidth showneartags showlocalchanges
     global viewname viewfiles viewargs viewargscmd viewperm nextviewnum
     global cmitmode wrapcomment datetimeformat limitdiffs
@@ -2707,10 +2707,12 @@ proc savestuff {w} {
     if {$stuffsaved} return
     if {![winfo viewable .]} return
     catch {
-	if {[file exists ~/.gitk-new]} {file delete -force ~/.gitk-new}
-	set f [open "~/.gitk-new" w]
+	set fn [expr [file exists [file join $gitdir k]] ? \
+		{[file join $gitdir k-new]} : {"~/.gitk-new"}]
+	if {[file exists $fn]} {file delete -force $fn}
+	set f [open $fn  w]
 	if {$::tcl_platform(platform) eq {windows}} {
-	    file attributes "~/.gitk-new" -hidden true
+	    catch {file attributes "~/.gitk-new" -hidden true}
 	}
 	puts $f [list set mainfont $mainfont]
 	puts $f [list set textfont $textfont]
@@ -2762,7 +2764,7 @@ proc savestuff {w} {
 	}
 	puts $f "}"
 	close $f
-	file rename -force "~/.gitk-new" "~/.gitk"
+	file rename -force $fn [regsub {\-new$} $fn {}]
     }
     set stuffsaved 1
 }
@@ -11663,7 +11665,14 @@ namespace import ::msgcat::mc
 ## And eventually load the actual message catalog
 ::msgcat::mcload $gitk_msgsdir
 
+# check that we can find a .git directory somewhere...
+if {[catch {set gitdir [exec git rev-parse --git-dir]}]} {
+    show_error {} . [mc "Cannot find a git repository here."]
+    exit 1
+}
+
 catch {source ~/.gitk}
+catch {source [file join $gitdir k]}
 
 parsefont mainfont $mainfont
 eval font create mainfont [fontflags mainfont]
@@ -11680,12 +11689,6 @@ setui $uicolor
 
 setoptions
 
-# check that we can find a .git directory somewhere...
-if {[catch {set gitdir [exec git rev-parse --git-dir]}]} {
-    show_error {} . [mc "Cannot find a git repository here."]
-    exit 1
-}
-
 set selecthead {}
 set selectheadid {}
 
-- 
1.7.8.6
Previous: Lukasz StelmachNext: Stefan Haller
Message 4 of 18 in “gitk: add a checkbox to control the visibility of tags”
  1. gitk: add a checkbox to control the visibility of tagsŁukasz Stelmach, Nov 30, 2012
  2. Junio C HamanoDec 2, 2012
  3. Lukasz StelmachDec 2, 2012
  4. gitk: read and write a repository specific configuration fileŁukasz Stelmach, Dec 2, 2012
  5. Stefan HallerDec 3, 2012
  6. Lukasz StelmachDec 4, 2012
  7. gitk: read and write a repository specific configuration fileŁukasz Stelmach, Dec 5, 2012
  8. Marc BranchaudDec 5, 2012
  9. gitk: read and write a repository specific configuration fileŁukasz Stelmach, Dec 8, 2012
  10. Junio C HamanoDec 9, 2012
  11. Paul MackerrasDec 9, 2012
  12. Lukasz StelmachDec 9, 2012
  13. Lukasz StelmachDec 9, 2012
  14. Felipe ContrerasDec 2, 2012
  15. Paul MackerrasJan 2, 2013
  16. Junio C HamanoJan 2, 2013
  17. Lukasz StelmachJan 2, 2013
  18. Junio C HamanoJan 2, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.