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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 6, 2008, 07:34 UTC
Message-ID
<7vtzkm35d1.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20080206070608.6881.qmail@096465580ae94c.315fe32.mid.smarden.org>
Gerrit Pape <pape@smarden.org> writes:
Show 26 quoted lines
> 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.

Previous: Gerrit PapeNext: Gerrit Pape
Message 2 of 5 in “gitk: properly deal with tag names containing / (slash)”
  1. gitk: properly deal with tag names containing / (slash)Gerrit Pape, Feb 6, 2008
  2. Junio C HamanoFeb 6, 2008
  3. gitk: properly deal with tag names containing / (slash)Gerrit Pape, Feb 7, 2008
  4. gitk: properly deal with tag names containing / (slash)Gerrit Pape, Feb 11, 2008
  5. Paul MackerrasFeb 12, 2008

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.