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

[PATCH] gitk: avoid mkdtemp on Windows

From
David Aguilar <davvid@gmail.com>
Date
Jun 15, 2014, 22:23 UTC
Message-ID
<1402871036-1389-1-git-send-email-davvid@gmail.com>

105b5d3fbb1c00bb0aeaf9d3e0fbe26a7b1993fc introduced a dependency on mkdtemp, which is not available on Windows.

Restore the original temporary directory behavior for Windows so that gitk creates temporary directories in the current repository.

The Unix code path retains new TMPDIR behavior.
Reported-by: Pat Thoyts <patthoyts@users.sourceforge.net>
Helped-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: David Aguilar <davvid@gmail.com>
---
 gitk | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/gitk b/gitk
index 41e5071..66d8c9e 100755
--- a/gitk
+++ b/gitk
@@ -3496,15 +3496,22 @@ proc gitknewtmpdir {} {
     global diffnum gitktmpdir gitdir env
 
     if {![info exists gitktmpdir]} {
-	if {[info exists env(GITK_TMPDIR)]} {
-	    set tmpdir $env(GITK_TMPDIR)
-	} elseif {[info exists env(TMPDIR)]} {
-	    set tmpdir $env(TMPDIR)
+	if {$::tcl_platform(platform) eq {windows}} {
+	    # Windows does not have mkdtemp so use the current directory
+	    # to avoid using an unsafe pattern in a world-writeable
+	    # temporary directory.
+	    set gitktmpdir [file join $gitdir [format ".gitk-tmp.%s" [pid]]]
 	} else {
-	    set tmpdir $gitdir
+	    if {[info exists env(GITK_TMPDIR)]} {
+		set tmpdir $env(GITK_TMPDIR)
+	    } elseif {[info exists env(TMPDIR)]} {
+		set tmpdir $env(TMPDIR)
+	    } else {
+		set tmpdir $gitdir
+	    }
+	    set gitktmpformat [file join $tmpdir ".gitk-tmp.XXXXXX"]
+	    set gitktmpdir [exec mktemp -d $gitktmpformat]
 	}
-	set gitktmpformat [file join $tmpdir ".gitk-tmp.XXXXXX"]
-	set gitktmpdir [exec mktemp -d $gitktmpformat]
 	if {[catch {file mkdir $gitktmpdir} err]} {
 	    error_popup "[mc "Error creating temporary directory %s:" $gitktmpdir] $err"
 	    unset gitktmpdir
-- 
2.0.0.257.g75cc6c6
Message 1 of 1 in “gitk: avoid mkdtemp on Windows”
  1. gitk: avoid mkdtemp on WindowsDavid Aguilar, Jun 15, 2014

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.