threads / discuss / 17091

Lightweight tag ?

Subject: Lightweight tag ?

## tl;dr

8 messages between Jan 11, 2009 and Jan 12, 2009.

replies: 7people: 3as markdown or json

Francis Moreau· Jan 11, 2009, 18:44 UTC · lore
Hello,
I'm puzzling about the lightweight.
My problem is that I don't see their point !

They behave the same way like the annotated tags: when pushing to a repo the lightweight tags are pushed as well, and pulling from a repo with lightweight tags give the same results (all of this with the --tags switch).

I would have thought that these kind of tags are local to a repository but it doesn't look so.

So could anybody give me a useful use case for lightweight tags ?
And how can I create local tags ?
Thanks
-- 
Francis
Junio C Hamano· Jan 11, 2009, 21:04 UTC · re: Francis Moreau · lore

Re: Lightweight tag ?

"Francis Moreau" <francis.moro@gmail.com> writes:
Show 6 quoted lines
> My problem is that I don't see their point !
>
> They behave the same way like the annotated tags: when pushing to a
> repo the lightweight tags are pushed as well, and pulling from a repo
> with lightweight tags give the same results (all of this with the
> --tags switch).

Don't use explicit --tags blindly. It says "no matter what kind of tag, transfer everything under refs/tags". Otherwise you won't see a difference.

Francis Moreau· Jan 12, 2009, 09:17 UTC · re: Junio C Hamano · lore

Re: Lightweight tag ?

Hello,
Junio C Hamano <gitster@pobox.com> writes:
> Don't use explicit --tags blindly.  It says "no matter what kind of tag,
> transfer everything under refs/tags".  Otherwise you won't see a
> difference.
Well:
	$ git --version
	git version 1.6.0.4
	$ mkdir test-tag
	$ cd test-tag/
	$ date > A
	$ git init
	Initialized empty Git repository in
	/home/fmoreau/tmp/git/test-tag/.git/
	$ git add .
	$ git commit -a -s -m "Init"
	Created initial commit be8750e: Init
	 1 files changed, 1 insertions(+), 0 deletions(-)
	 create mode 100644 A
	$ cd ..
	$ git clone --bare test-tag test-tag.git
	Initialized empty Git repository in /home/fmoreau/tmp/git/test-tag.git/
	$ cd test-tag
	$ git tag light
	
	$ git tag -a -m "Annoted tag" annoted
	$ git push ../test-tag.git
	Everything up-to-date
	$ git push --tags ../test-tag.git
	Counting objects: 1, done.
	Writing objects: 100% (1/1), 166 bytes, done.
	Total 1 (delta 0), reused 0 (delta 0)
	Unpacking objects: 100% (1/1), done.
	To ../test-tag.git
	 * [new tag]         annoted -> annoted
	 * [new tag]         light -> light
It looks like they're no difference for git-push...
That said the documentation about this is rather cryptic IMHO:
,----[ man git-push ]
| 	--tags
| 	    All refs under $GIT_DIR/refs/tags are pushed, in
| 	    addition to refspecs explicitly listed on the command
| 	    line.
`----
>From a user point of view, the word lightweight is missing here. Why
not simply saying:
,----
| All kind of tags are pushed with this option _otherwise_ only annoted
| tags are pushed
`----
thanks
-- 
Francis
Michael J Gruber· Jan 12, 2009, 12:55 UTC · re: Francis Moreau · lore

Re: Lightweight tag ?

Francis Moreau venit, vidit, dixit 01/12/09 10:17:
Show 59 quoted lines
> Hello,
> 
> Junio C Hamano <gitster@pobox.com> writes:
> 
>> Don't use explicit --tags blindly.  It says "no matter what kind of tag,
>> transfer everything under refs/tags".  Otherwise you won't see a
>> difference.
> 
> Well:
> 
> 	$ git --version
> 	git version 1.6.0.4
> 	$ mkdir test-tag
> 	$ cd test-tag/
> 	$ date > A
> 	$ git init
> 	Initialized empty Git repository in
> 	/home/fmoreau/tmp/git/test-tag/.git/
> 	$ git add .
> 	$ git commit -a -s -m "Init"
> 	Created initial commit be8750e: Init
> 	 1 files changed, 1 insertions(+), 0 deletions(-)
> 	 create mode 100644 A
> 	$ cd ..
> 	$ git clone --bare test-tag test-tag.git
> 	Initialized empty Git repository in /home/fmoreau/tmp/git/test-tag.git/
> 	$ cd test-tag
> 	$ git tag light
> 	
> 	$ git tag -a -m "Annoted tag" annoted
> 	$ git push ../test-tag.git
> 	Everything up-to-date
> 	$ git push --tags ../test-tag.git
> 	Counting objects: 1, done.
> 	Writing objects: 100% (1/1), 166 bytes, done.
> 	Total 1 (delta 0), reused 0 (delta 0)
> 	Unpacking objects: 100% (1/1), done.
> 	To ../test-tag.git
> 	 * [new tag]         annoted -> annoted
> 	 * [new tag]         light -> light
> 
> It looks like they're no difference for git-push...
> 
> That said the documentation about this is rather cryptic IMHO:
> 
> ,----[ man git-push ]
> | 	--tags
> | 	    All refs under $GIT_DIR/refs/tags are pushed, in
> | 	    addition to refspecs explicitly listed on the command
> | 	    line.
> `----
> 
> From a user point of view, the word lightweight is missing here. Why
> not simply saying:
> 
> ,----
> | All kind of tags are pushed with this option _otherwise_ only annoted
> | tags are pushed
> `----

Your test above confirms that the description is correct and nothing is missing. "git push" pushes explicitly listed refspecs (or : as a default). It pushes tags (light and heavy) when asked to.

"git pull" pulls tags if they can be reached from heads which are pulled. It pulls all tags only when asked to.

In fact, the automatic following of tags (if they can be reached...) depends on the transport, because typically you want to clone everything if you clone locally but don't want all tags if you clone/pull from a remote. There is also a config "tagopt" for overriding this. It's mentioned but not really explained in "git tag"'s man page.

So, "non-local" tags are the ones which can be reached from heads which you pull, and local ones are the others. I don't think lightweight tags are more local than tag objects (please correct me if I'm wrong; I think this needs more doc). It's just that the latter reside in the object db store whereas the former are simple refs under refs/tags.

Michael
Francis Moreau· Jan 12, 2009, 13:56 UTC · re: Michael J Gruber · lore

Re: Lightweight tag ?

On Mon, Jan 12, 2009 at 1:55 PM, Michael J Gruber <git@drmicha.warpmail.net> wrote:

> Your test above confirms that the description is correct and nothing is
> missing. "git push" pushes explicitly listed refspecs (or : as a
> default). It pushes tags (light and heavy) when asked to.
>

So do you mean that the only way I have for pushing annoted tags only is to do:

   $ git push origin refs/tags/annoted
That's not what Junio said:
   Don't use explicit --tags blindly.  It says "no matter what kind of tag,
   transfer everything under refs/tags".  Otherwise you won't see a
   difference.

So I interpret this like don't use --tags otherwise lightweight and annoted tags are the same.

> "git pull" pulls tags if they can be reached from heads which are
> pulled. It pulls all tags only when asked to.
>
[...]
> So, "non-local" tags are the ones which can be reached from heads which
> you pull, and local ones are the others.

So I can't create a local tag on public heads (the ones I'm pushing out), can I ?

> I don't think lightweight tags are more local than tag objects
> (please correct me if I'm wrong; I think this needs more doc)

Perhaps it needs documents which are more user friendly: I don't know where the 'lightweight' word is coming from (perhaps from the implementation) but I would expect that the _local_ term appears in the git-tag manual.

> It's just that the latter reside in the object db
> store whereas the former are simple refs under refs/tags.
That's implementation detail...

I just need to create a local tag where I'm sure it won't be seen by others whatever the git operations I'm doing, normally a simple "git tag" switch should be enough...

thanks.
-- 
Francis
Michael J Gruber· Jan 12, 2009, 14:54 UTC · re: Francis Moreau · lore

Re: Lightweight tag ?

Francis Moreau venit, vidit, dixit 01/12/09 14:56:
Show 11 quoted lines
> On Mon, Jan 12, 2009 at 1:55 PM, Michael J Gruber
> <git@drmicha.warpmail.net> wrote:
>> Your test above confirms that the description is correct and nothing is
>> missing. "git push" pushes explicitly listed refspecs (or : as a
>> default). It pushes tags (light and heavy) when asked to.
>>
> 
> So do you mean that the only way I have for pushing annoted tags only is
> to do:
> 
>    $ git push origin refs/tags/annoted

You could use the equivalent, more user friendly "git push origin tag annoted".

Show 8 quoted lines
> That's not what Junio said:
> 
>    Don't use explicit --tags blindly.  It says "no matter what kind of tag,
>    transfer everything under refs/tags".  Otherwise you won't see a
>    difference.
> 
> So I interpret this like don't use --tags otherwise lightweight and annoted tags
> are the same.

I don't see a difference between lightweight tags and tag objects regarding the question of automatic tag following, see my parenthetical request for correction (below) in case I'm wrong.

Show 18 quoted lines
>> "git pull" pulls tags if they can be reached from heads which are
>> pulled. It pulls all tags only when asked to.
>>
> 
> [...]
> 
>> So, "non-local" tags are the ones which can be reached from heads which
>> you pull, and local ones are the others.
> 
> So I can't create a local tag on public heads (the ones I'm pushing
> out), can I ?
> 
>> I don't think lightweight tags are more local than tag objects
>> (please correct me if I'm wrong; I think this needs more doc)
> 
> Perhaps it needs documents which are more user friendly: I don't know where
> the 'lightweight' word is coming from (perhaps from the implementation) but
> I would expect that the _local_ term appears in the git-tag manual.

It's the other way round. "lightweight" is in the first few lines of the man, "local" nowhere. In fact I don't see it anywhere in the docs.

Show 8 quoted lines
>> It's just that the latter reside in the object db
>> store whereas the former are simple refs under refs/tags.
> 
> That's implementation detail...
> 
> I just need to create a local tag where I'm sure it won't be seen by others
> whatever the git operations I'm doing, normally a simple "git tag" switch
> should be enough...
Taking "whatever" literally this is impossible, of course.

Taking it /cum grano salis/ it's still impossible within the same repo: If others have read access they can "ls-remote" and "fetch" happily what they want. The sane and easy way is to use a private repo for your local work and all your "local tags", then to push to a public (i.e. publically readable) repo those branches and tags which you want to be seen.

Are you a Mercurial user by any chance? "hg tag -l" creates local tags which are stored in an unversioned, private file, whereas "hg tag" creates (and commits) a tag entry in a versioned file, which is the source of some confusion and problems with hg tags ("hg co sometag" does not contain sometag etc.). Maybe you want the behaviour of "hg tag -l"?

Cheers, Michael

Junio C Hamano· Jan 12, 2009, 19:52 UTC · re: Michael J Gruber · lore

Re: Lightweight tag ?

Michael J Gruber <git@drmicha.warpmail.net> writes:
Show 12 quoted lines
>> That's not what Junio said:
>> 
>>    Don't use explicit --tags blindly.  It says "no matter what kind of tag,
>>    transfer everything under refs/tags".  Otherwise you won't see a
>>    difference.
>> 
>> So I interpret this like don't use --tags otherwise lightweight and annoted tags
>> are the same.
>
> I don't see a difference between lightweight tags and tag objects
> regarding the question of automatic tag following, see my parenthetical
> request for correction (below) in case I'm wrong.
It was me who was confused on two points.
 (1) push does not do autofollow and you always have to be explicit
     (including saying "--tags" which is to push all refs/tags/*); I
     somehow thought the question was about fetch;
 (2) if you explicitly ask to fetch tags, there won't be any difference
     (which was my "don't say --tags explicitly because you won't see a
     difference if you did so").
     On the other hand, the autofollowing during the fetch originally
     followed only annotated tags (it was partly by design, so that people
     can use lightweight tags for local stuff without worrying about
     contaminating others' tag namespace with many of them) and I somehow
     thought this was still the case.
     But it is not the case anymore since 6c96c0f (git-fetch: follow
     lightweight tags as well, 2006-11-18).
So, sorry for the noise.
Francis Moreau· Jan 12, 2009, 20:50 UTC · re: Michael J Gruber · lore

Re: Lightweight tag ?

Michael J Gruber <git@drmicha.warpmail.net> writes:
Show 6 quoted lines
>> Perhaps it needs documents which are more user friendly: I don't know where
>> the 'lightweight' word is coming from (perhaps from the implementation) but
>> I would expect that the _local_ term appears in the git-tag manual.
>
> It's the other way round. "lightweight" is in the first few lines of the
> man, "local" nowhere. In fact I don't see it anywhere in the docs.

Sorry my previous reply wasn't clear, I meant that the word 'lightweight' appears in the man page of git-tag but I don't see why such term is used, well now I can see but it's implementation detail so useless (or worth: confusing) for a dumb user (me).

In contrary I would have expected to find the 'local' word if git support local tags.

Show 13 quoted lines
>> I just need to create a local tag where I'm sure it won't be seen by others
>> whatever the git operations I'm doing, normally a simple "git tag" switch
>> should be enough...
>
> Taking "whatever" literally this is impossible, of course.
> 
>
> Taking it /cum grano salis/ it's still impossible within the same repo:
> If others have read access they can "ls-remote" and "fetch" happily what
> they want. The sane and easy way is to use a private repo for your local
> work and all your "local tags", then to push to a public (i.e.
> publically readable) repo those branches and tags which you want to be seen.
>

This is how things are currently implemented but if lightweight is really useless and local tags are somehow missing in Git then I'm pretty sure it's possible to create such tags that are not seen by git-{pull,push,fetch] operations.

>
> Are you a Mercurial user by any chance?
Nope.
Show 5 quoted lines
> "hg tag -l" creates local tags which are stored in an unversioned,
> private file, whereas "hg tag" creates (and commits) a tag entry in
> a versioned file, which is the source of some confusion and problems
> with hg tags ("hg co sometag" does not contain sometag etc.). Maybe
> you want the behaviour of "hg tag -l"?
Yes, It sounds that 'hg tag -l' is what I'm looking for in git...
Thanks
-- 
Francis

← back to recent threads