git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gitk: properly deal with tag names containing / (slash)
@ 2008-02-06  7:06 Gerrit Pape
  2008-02-06  7:34 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Gerrit Pape @ 2008-02-06  7:06 UTC (permalink / raw)
  To: git, Paul Mackerras

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=unknown-8bit, Size: 1208 bytes --]

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 <pape@smarden.org>
---
 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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] gitk: properly deal with tag names containing / (slash)
  2008-02-06  7:06 [PATCH] gitk: properly deal with tag names containing / (slash) Gerrit Pape
@ 2008-02-06  7:34 ` Junio C Hamano
  2008-02-07  9:34   ` Gerrit Pape
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2008-02-06  7:34 UTC (permalink / raw)
  To: Gerrit Pape; +Cc: git, Paul Mackerras

Gerrit Pape <pape@smarden.org> writes:

> 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.
> ...
> 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]
> +	}

That's wrong.  If your refs are packed and you have an existing
tag 'foo', you should error out on a request to create 'foo/bar'
(and vice versa --- existing foo/bar should prevent foo from
being created).

You should be calling out "git tag" instead of futzing with
files under gitdir by hand.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] gitk: properly deal with tag names containing / (slash)
  2008-02-06  7:34 ` Junio C Hamano
@ 2008-02-07  9:34   ` Gerrit Pape
  2008-02-11 10:57     ` [PATCH/UTF-8] " Gerrit Pape
  0 siblings, 1 reply; 5+ messages in thread
From: Gerrit Pape @ 2008-02-07  9:34 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Paul Mackerras

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=unknown-8bit, Size: 1354 bytes --]

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 use
'git tag' to create the tag instead of modifying files in refs/tags/,
which fixes the issue; if 'git tag' throws an error, gitk pops up with
the error message.

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

Signed-off-by: Gerrit Pape <pape@smarden.org>
---

On Tue, Feb 05, 2008 at 11:34:50PM -0800, Junio C Hamano wrote:
> That's wrong.  If your refs are packed and you have an existing
> tag 'foo', you should error out on a request to create 'foo/bar'
> (and vice versa --- existing foo/bar should prevent foo from
> being created).
>
> You should be calling out "git tag" instead of futzing with
> files under gitdir by hand.
Done so.

 gitk-git/gitk |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index 5560e4d..00d791f 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -6137,11 +6137,7 @@ proc domktag {} {
 	return
     }
     if {[catch {
-	set dir [gitdir]
-	set fname [file join $dir "refs/tags" $tag]
-	set f [open $fname w]
-	puts $f $id
-	close $f
+	exec git tag $tag $id
     } err]} {
 	error_popup "[mc "Error creating tag:"] $err"
 	return
-- 
1.5.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH/UTF-8] gitk: properly deal with tag names containing / (slash)
  2008-02-07  9:34   ` Gerrit Pape
@ 2008-02-11 10:57     ` Gerrit Pape
  2008-02-12  2:21       ` Paul Mackerras
  0 siblings, 1 reply; 5+ messages in thread
From: Gerrit Pape @ 2008-02-11 10:57 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Paul Mackerras

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=utf-8, Size: 960 bytes --]

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 use
'git tag' to create the tag instead of modifying files in refs/tags/,
which fixes the issue; if 'git tag' throws an error, gitk pops up with
the error message.

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

Signed-off-by: Gerrit Pape <pape@smarden.org>
---
 gitk-git/gitk |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index 5560e4d..00d791f 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -6137,11 +6137,7 @@ proc domktag {} {
 	return
     }
     if {[catch {
-	set dir [gitdir]
-	set fname [file join $dir "refs/tags" $tag]
-	set f [open $fname w]
-	puts $f $id
-	close $f
+	exec git tag $tag $id
     } err]} {
 	error_popup "[mc "Error creating tag:"] $err"
 	return
-- 
1.5.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH/UTF-8] gitk: properly deal with tag names containing / (slash)
  2008-02-11 10:57     ` [PATCH/UTF-8] " Gerrit Pape
@ 2008-02-12  2:21       ` Paul Mackerras
  0 siblings, 0 replies; 5+ messages in thread
From: Paul Mackerras @ 2008-02-12  2:21 UTC (permalink / raw)
  To: Gerrit Pape; +Cc: Junio C Hamano, git

Gerrit Pape writes:

> 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 use
> 'git tag' to create the tag instead of modifying files in refs/tags/,
> which fixes the issue; if 'git tag' throws an error, gitk pops up with
> the error message.

Thanks, applied.

Paul.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-02-12  2:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-06  7:06 [PATCH] gitk: properly deal with tag names containing / (slash) Gerrit Pape
2008-02-06  7:34 ` Junio C Hamano
2008-02-07  9:34   ` Gerrit Pape
2008-02-11 10:57     ` [PATCH/UTF-8] " Gerrit Pape
2008-02-12  2:21       ` Paul Mackerras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).