DORMANTno replies

[PATCH] gitk: properly deal with tag names containing / (slash)

From: Gerrit Pape <hidden>
Date: 2016-06-15 22:44:10

When creating a tag through gitk, and the tag name includes a slash (or
slashes), gitk errors out in a popup window.  This patch makes gitk create
the necessary subdirectory(s) to successfully create the tag, and also
catches an error if a directory with the tag name to be created already
exists.

The problem was reported by Frédéric Brière through
 http://bugs.debian.org/464104

Signed-off-by: Gerrit Pape <redacted>
---
 gitk-git/gitk |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/gitk-git/gitk b/gitk-git/gitk
index 5560e4d..56a8792 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -6136,9 +6136,16 @@ proc domktag {} {
 	error_popup [mc "Tag \"%s\" already exists" $tag]
 	return
     }
+    set dir [gitdir]
+    set fname [file join $dir "refs/tags" $tag]
+    if {[file isdirectory $fname]} {
+	error_popup [mc "A directory with the name \"%s\" exists in \"refs/tags\"" $tag]
+	return
+    }
     if {[catch {
-	set dir [gitdir]
-	set fname [file join $dir "refs/tags" $tag]
+	if {[file dirname $tag] != "."} {
+	    file mkdir [file dirname $fname]
+	}
 	set f [open $fname w]
 	puts $f $id
 	close $f
-- 
1.5.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help