threads / discuss / 18346

.gitk should created hidden in windows

Subject: .gitk should created hidden in windows

## tl;dr

8 messages between Mar 17, 2009 and Apr 17, 2009.

replies: 7people: 5as markdown or json

Steve Wagner· Mar 17, 2009, 13:45 UTC · lore
Hi Paul, i write this to the git mailing list because of the advice from
 Johannes Schindelin in the MSysGit Issue:
http://code.google.com/p/msysgit/issues/detail?id=143

The problem is that windows dose not hides files beginning with a dot as it is in unix. So the .gitk file is created as visible in the windows user profile. Problematic too is that i can no set the hidden attribute to this file, because it is recreated every time i start gitk, so the hidden attribute gets lost.

Can you control this and create the file with the hidden attribute on windows?

Steve
Paul Mackerras· Mar 23, 2009, 10:37 UTC · re: Steve Wagner · lore

Re: .gitk should created hidden in windows

Steve Wagner writes:
Show 8 quoted lines
> The problem is that windows dose not hides files beginning with a dot as
> it is in unix. So the .gitk file is created as visible in the windows
> user profile. Problematic too is that i can no set the hidden attribute
> to this file, because it is recreated every time i start gitk, so the
> hidden attribute gets lost.
> 
> Can you control this and create the file with the hidden attribute on
> windows?
Please try this patch and let me know if it does what you want.
Paul.
diff --git a/gitk b/gitk
index d7de27e..54f3f2b 100755
--- a/gitk
+++ b/gitk
@@ -2487,6 +2487,9 @@ proc savestuff {w} {
     if {![winfo viewable .]} return
     catch {
 	set f [open "~/.gitk-new" w]
+	if {$::tcl_platform(platform) eq {windows}} {
+	    file attributes "~/.gitk-new" -hidden true
+	}
 	puts $f [list set mainfont $mainfont]
 	puts $f [list set textfont $textfont]
 	puts $f [list set uifont $uifont]
Steve Wagner· Mar 23, 2009, 12:18 UTC · re: Paul Mackerras · lore

Re: .gitk should created hidden in windows

Seems to work here. Thanks for fixing it!
Steve
Paul Mackerras schrieb:
Show 30 quoted lines
> Steve Wagner writes:
> 
>> The problem is that windows dose not hides files beginning with a dot as
>> it is in unix. So the .gitk file is created as visible in the windows
>> user profile. Problematic too is that i can no set the hidden attribute
>> to this file, because it is recreated every time i start gitk, so the
>> hidden attribute gets lost.
>>
>> Can you control this and create the file with the hidden attribute on
>> windows?
> 
> Please try this patch and let me know if it does what you want.
> 
> Paul.
> 
> diff --git a/gitk b/gitk
> index d7de27e..54f3f2b 100755
> --- a/gitk
> +++ b/gitk
> @@ -2487,6 +2487,9 @@ proc savestuff {w} {
>      if {![winfo viewable .]} return
>      catch {
>  	set f [open "~/.gitk-new" w]
> +	if {$::tcl_platform(platform) eq {windows}} {
> +	    file attributes "~/.gitk-new" -hidden true
> +	}
>  	puts $f [list set mainfont $mainfont]
>  	puts $f [list set textfont $textfont]
>  	puts $f [list set uifont $uifont]
> 
Pat Thoyts· Mar 24, 2009, 00:04 UTC · re: Paul Mackerras · lore

Re: .gitk should created hidden in windows

Paul Mackerras wrote:
> Please try this patch and let me know if it does what you want.
> 
[snip]

This patch works fine on my Vista installation. The .gitk file is now hidden.

An alternative that was discussed was to move it rather than hide it so that it ends up in the Application Data folder along with settings for other applications. The following patch does this but hits rather more lines of code and ends up needing to check the original location as well.

diff --git a/gitk b/gitk
index a7294a1..5ec6e7b 100755
--- a/gitk
+++ b/gitk
@@ -2509,12 +2509,13 @@ proc savestuff {w} {
     global viewname viewfiles viewargs viewargscmd viewperm nextviewnum
     global cmitmode wrapcomment datetimeformat limitdiffs
     global colors bgcolor fgcolor diffcolors diffcontext selectbgcolor
-    global autoselect extdifftool perfile_attrs markbgcolor
+    global autoselect extdifftool perfile_attrs markbgcolor rcfile

     if {$stuffsaved} return
     if {![winfo viewable .]} return
-    catch {
-	set f [open "~/.gitk-new" w]
+    set tmpfile "${rcfile}-new"
+    if {[catch {
+	set f [open $tmpfile {CREAT WRONLY}]
 	puts $f [list set mainfont $mainfont]
 	puts $f [list set textfont $textfont]
 	puts $f [list set uifont $uifont]
@@ -2555,7 +2556,10 @@ proc savestuff {w} {
 	}
 	puts $f "}"
 	close $f
-	file rename -force "~/.gitk-new" "~/.gitk"
+	file rename -force $tmpfile $rcfile
+    } err]} {
+        tk_messageBox -icon error -message $err \
+            -title "Failed to save preferences"
     }
     set stuffsaved 1
 }
@@ -10790,7 +10794,13 @@ namespace import ::msgcat::mc
 ## And eventually load the actual message catalog
 ::msgcat::mcload $gitk_msgsdir

-catch {source ~/.gitk}
+set rcfile ~/.gitk
+if {$::tcl_platform(platform) eq "windows"} {
+    # Load old settings file if present
+    if {[file exists ~/.gitk]} {catch {source ~/.gitk}}
+    set rcfile [file join $env(APPDATA) gitk.settings]
+}
+catch {source $rcfile}

 font create optionfont -family sans-serif -size -12
Johannes Schindelin· Mar 24, 2009, 01:39 UTC · re: Pat Thoyts · lore

Re: .gitk should created hidden in windows

Hi,
On Tue, 24 Mar 2009, Pat Thoyts wrote:
Show 13 quoted lines
> Paul Mackerras wrote:
> > Please try this patch and let me know if it does what you want.
> > 
> [snip]
> 
> This patch works fine on my Vista installation. The .gitk file is now 
> hidden.
> 
> An alternative that was discussed was to move it rather than hide it so 
> that it ends up in the Application Data folder along with settings for 
> other applications. The following patch does this but hits rather more 
> lines of code and ends up needing to check the original location as 
> well.

While I see your point, keep in mind that this patch would make Git for Windows even more incompatible with Git "In The Rest Of The World"...

Ciao, Dscho

Paul Mackerras· Apr 17, 2009, 10:49 UTC · re: Pat Thoyts · lore

Re: .gitk should created hidden in windows

Pat Thoyts writes:
> An alternative that was discussed was to move it rather than hide it so
> that it ends up in the Application Data folder along with settings for
> other applications. The following patch does this but hits rather more
> lines of code and ends up needing to check the original location as well.

Sounds OK, but wouldn't we want to ignore ~/.gitk if there is a gitk.settings in application data directory?

Paul.
John Tapsell· Mar 24, 2009, 02:08 UTC · re: Paul Mackerras · lore

Re: .gitk should created hidden in windows

2009/3/23 Paul Mackerras <paulus@samba.org>:
Show 29 quoted lines
> Steve Wagner writes:
>
>> The problem is that windows dose not hides files beginning with a dot as
>> it is in unix. So the .gitk file is created as visible in the windows
>> user profile. Problematic too is that i can no set the hidden attribute
>> to this file, because it is recreated every time i start gitk, so the
>> hidden attribute gets lost.
>>
>> Can you control this and create the file with the hidden attribute on
>> windows?
>
> Please try this patch and let me know if it does what you want.
>
> Paul.
>
> diff --git a/gitk b/gitk
> index d7de27e..54f3f2b 100755
> --- a/gitk
> +++ b/gitk
> @@ -2487,6 +2487,9 @@ proc savestuff {w} {
>     if {![winfo viewable .]} return
>     catch {
>        set f [open "~/.gitk-new" w]
> +       if {$::tcl_platform(platform) eq {windows}} {
> +           file attributes "~/.gitk-new" -hidden true
> +       }
>        puts $f [list set mainfont $mainfont]
>        puts $f [list set textfont $textfont]
>        puts $f [list set uifont $uifont]
How about making all files beginning with .  hidden?  .gitignore for example
Johannes Schindelin· Mar 24, 2009, 02:14 UTC · re: John Tapsell · lore

Re: .gitk should created hidden in windows

Hi,
On Tue, 24 Mar 2009, John Tapsell wrote:
> How about making all files beginning with .  hidden?  .gitignore for 
> example
Uhm.
Did you miss that this patch was about gitk, not git.git?

Ciao, Dscho

← back to recent threads