git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BugReport] git tag -a / git show
@ 2012-02-24 10:24 Romain Vimont (®om)
  2012-02-24 19:27 ` Zbigniew Jędrzejewski-Szmek
  2012-02-24 19:50 ` [Not A BugReport] " Junio C Hamano
  0 siblings, 2 replies; 9+ messages in thread
From: Romain Vimont (®om) @ 2012-02-24 10:24 UTC (permalink / raw)
  To: git

$ git --version
git version 1.7.5.4

$ git log --pretty=online
0ef41513d0b6d0ad28f21d0ac1da7096ad1dc6ff This is the last commit
a4702c69c28484d357179166cf3b116764da20a4 This is a commit

Now, I edit some files (for example in a config file "mock_data=true"), 
then I want to tag without commiting this change.

$ git tag -a v0.1 -m 'My v0.1 with mock data'

$ git show v0.1
tag v0.1
Tagger: Me <me@me.me>
Date:   Fri Feb 24 11:23:38 2012 +0100

     My v0.1 with mock data

commit 0ef41513d0b6d0ad28f21d0ac1da7096ad1dc6ff
Author: Me <me@me.me>
Date:   Fri Feb 24 11:14:19 2012 +0100

     This is the last commit

diff --git a/myfile b/myfile
index 8430bf6..20feeb6 100644
...


And it shows the diff between a4702c69c28484d357179166cf3b116764da20a4 
and 0ef41513d0b6d0ad28f21d0ac1da7096ad1dc6ff (the two last commits).
Instead, it should show the diff between 
0ef41513d0b6d0ad28f21d0ac1da7096ad1dc6ff (the last commit) and v0.1 (the 
tag).

Best regards,
®om

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

* Re: [BugReport] git tag -a / git show
  2012-02-24 10:24 [BugReport] git tag -a / git show Romain Vimont (®om)
@ 2012-02-24 19:27 ` Zbigniew Jędrzejewski-Szmek
  2012-02-24 19:55   ` Romain Vimont (®om)
  2012-02-24 19:50 ` [Not A BugReport] " Junio C Hamano
  1 sibling, 1 reply; 9+ messages in thread
From: Zbigniew Jędrzejewski-Szmek @ 2012-02-24 19:27 UTC (permalink / raw)
  To: "Romain Vimont (®om)"; +Cc: git

On 02/24/2012 11:24 AM, Romain Vimont (®om) wrote:
> $ git log --pretty=online
> 0ef41513d0b6d0ad28f21d0ac1da7096ad1dc6ff This is the last commit
> a4702c69c28484d357179166cf3b116764da20a4 This is a commit
>
> Now, I edit some files (for example in a config file "mock_data=true"),
> then I want to tag without commiting this change.
>
> $ git tag -a v0.1 -m 'My v0.1 with mock data'

> And it shows the diff between a4702c69c28484d357179166cf3b116764da20a4
> and 0ef41513d0b6d0ad28f21d0ac1da7096ad1dc6ff (the two last commits).

Hi Romain,
git tag attaches the tag to the last commit, 0ef41513 in your case. 
Dirty changes in your tree are ignored by the tag command. You would 
have to commit them first, and attach the tag to this new commit.

zbyszek

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

* Re: [Not A BugReport] git tag -a / git show
  2012-02-24 10:24 [BugReport] git tag -a / git show Romain Vimont (®om)
  2012-02-24 19:27 ` Zbigniew Jędrzejewski-Szmek
@ 2012-02-24 19:50 ` Junio C Hamano
  2012-02-24 19:58   ` Romain Vimont (®om)
  1 sibling, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2012-02-24 19:50 UTC (permalink / raw)
  To: Romain Vimont (®om); +Cc: git

"Romain Vimont (®om)" <rom@rom1v.com> writes:

> Now, I edit some files (for example in a config file
> "mock_data=true"), then I want to tag without commiting this change.

Tag applies to an existing commit [*1*].  Your change in the working tree
is purely ephemeral until it is committed.

In other words, you don't "tag without committing".

> $ git tag -a v0.1 -m 'My v0.1 with mock data'

By omitting the [<head>] part from your command line for a command whose
usage is:

  usage: git tag [-a|-s|-u <key-id>] [-f] [-m <msg>|-F <file>] <tagname> [<head>]

you asked <head> to default to HEAD, the most recent commit, so the tag
points at your 0ef41513d0b6 (This is the last commit).  The tag message
should say "My v0.1" without anything else.

And show naturally shows the patch to bring its parent to that tagged
commit.

If you wanted to keep your mainline pristine without mock data, and want
to have a playpen that uses mock data, a way to do so is to use a separate
branch, e.g.

        $ git checkout -b playpen

Now, you are on your 'playpen' branch that was forked from the tip of
whatever branch you were on, perhaps 'master'.  Then commit that state
with whatever change that is specific to the playpen you want to keep out
of the mainline:

	$ edit config.txt ;# set mock_data=true
        $ git commit -a -m 'With mock data'

You can optionally tag the resulting commit if you want to.  You are still
on the 'playpen' branch, so you probably would want to come back to the
previous branch after you are done.


[Footnote]

*1* technically, tag can apply to any type of object, but it is most
common to apply to a commit.

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

* Re: [BugReport] git tag -a / git show
  2012-02-24 19:27 ` Zbigniew Jędrzejewski-Szmek
@ 2012-02-24 19:55   ` Romain Vimont (®om)
  2012-02-24 20:52     ` Jeff King
  0 siblings, 1 reply; 9+ messages in thread
From: Romain Vimont (®om) @ 2012-02-24 19:55 UTC (permalink / raw)
  To: Zbigniew Jędrzejewski-Szmek; +Cc: git

Thank you for your answer.

After my message this morning, that's what I did: I commited with the
mock data then tag.

Tonight, I just tried something which do exactly what I wanted to do
this morning:

$ git checkout -b temp
$ git commit -a -m 'My config file with mock_data=true'
$ git tag -a v0.1 -m v0.1
$ git checkout master
$ git branch -D temp

With these commands, the tag is associated to a commit which is not in
any branch.

Regards,
©om

Le vendredi 24 février 2012 à 20:27 +0100, Zbigniew Jędrzejewski-Szmek a
écrit :
> On 02/24/2012 11:24 AM, Romain Vimont (®om) wrote:
> > $ git log --pretty=online
> > 0ef41513d0b6d0ad28f21d0ac1da7096ad1dc6ff This is the last commit
> > a4702c69c28484d357179166cf3b116764da20a4 This is a commit
> >
> > Now, I edit some files (for example in a config file "mock_data=true"),
> > then I want to tag without commiting this change.
> >
> > $ git tag -a v0.1 -m 'My v0.1 with mock data'
> 
> > And it shows the diff between a4702c69c28484d357179166cf3b116764da20a4
> > and 0ef41513d0b6d0ad28f21d0ac1da7096ad1dc6ff (the two last commits).
> 
> Hi Romain,
> git tag attaches the tag to the last commit, 0ef41513 in your case. 
> Dirty changes in your tree are ignored by the tag command. You would 
> have to commit them first, and attach the tag to this new commit.
> 
> zbyszek
> 

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

* Re: [Not A BugReport] git tag -a / git show
  2012-02-24 19:50 ` [Not A BugReport] " Junio C Hamano
@ 2012-02-24 19:58   ` Romain Vimont (®om)
  2012-02-24 23:14     ` Andreas Schwab
  0 siblings, 1 reply; 9+ messages in thread
From: Romain Vimont (®om) @ 2012-02-24 19:58 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Thank you for the details.

> *1* technically, tag can apply to any type of object, but it is most
common to apply to a commit.

To what other type of object can you apply a tag ?

Good evening.

Le vendredi 24 février 2012 à 11:50 -0800, Junio C Hamano a écrit :
> "Romain Vimont (®om)" <rom@rom1v.com> writes:
> 
> > Now, I edit some files (for example in a config file
> > "mock_data=true"), then I want to tag without commiting this change.
> 
> Tag applies to an existing commit [*1*].  Your change in the working tree
> is purely ephemeral until it is committed.
> 
> In other words, you don't "tag without committing".
> 
> > $ git tag -a v0.1 -m 'My v0.1 with mock data'
> 
> By omitting the [<head>] part from your command line for a command whose
> usage is:
> 
>   usage: git tag [-a|-s|-u <key-id>] [-f] [-m <msg>|-F <file>] <tagname> [<head>]
> 
> you asked <head> to default to HEAD, the most recent commit, so the tag
> points at your 0ef41513d0b6 (This is the last commit).  The tag message
> should say "My v0.1" without anything else.
> 
> And show naturally shows the patch to bring its parent to that tagged
> commit.
> 
> If you wanted to keep your mainline pristine without mock data, and want
> to have a playpen that uses mock data, a way to do so is to use a separate
> branch, e.g.
> 
>         $ git checkout -b playpen
> 
> Now, you are on your 'playpen' branch that was forked from the tip of
> whatever branch you were on, perhaps 'master'.  Then commit that state
> with whatever change that is specific to the playpen you want to keep out
> of the mainline:
> 
> 	$ edit config.txt ;# set mock_data=true
>         $ git commit -a -m 'With mock data'
> 
> You can optionally tag the resulting commit if you want to.  You are still
> on the 'playpen' branch, so you probably would want to come back to the
> previous branch after you are done.
> 
> 
> [Footnote]
> 
> *1* technically, tag can apply to any type of object, but it is most
> common to apply to a commit.
> 

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

* Re: [BugReport] git tag -a / git show
  2012-02-24 19:55   ` Romain Vimont (®om)
@ 2012-02-24 20:52     ` Jeff King
  2012-02-24 21:42       ` Romain Vimont (®om)
  0 siblings, 1 reply; 9+ messages in thread
From: Jeff King @ 2012-02-24 20:52 UTC (permalink / raw)
  To: Romain Vimont (®om); +Cc: Zbigniew Jędrzejewski-Szmek, git

On Fri, Feb 24, 2012 at 08:55:45PM +0100, Romain Vimont (®om) wrote:

> Tonight, I just tried something which do exactly what I wanted to do
> this morning:
> 
> $ git checkout -b temp
> $ git commit -a -m 'My config file with mock_data=true'
> $ git tag -a v0.1 -m v0.1
> $ git checkout master
> $ git branch -D temp

There is nothing at all wrong with the commands above, but you might be
interested to know that you can do it without the temporary branch:

  $ git commit -a -m 'My config...'
  $ git tag -m v0.1 v0.1
  $ git reset HEAD^

The final reset will rewind your branch tip and the index state to what
it was before the commit, but will leave the files in the working tree
untouched.

-Peff

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

* Re: [BugReport] git tag -a / git show
  2012-02-24 20:52     ` Jeff King
@ 2012-02-24 21:42       ` Romain Vimont (®om)
  2012-02-24 21:44         ` Jeff King
  0 siblings, 1 reply; 9+ messages in thread
From: Romain Vimont (®om) @ 2012-02-24 21:42 UTC (permalink / raw)
  To: Jeff King; +Cc: Zbigniew Jędrzejewski-Szmek, git

Thank you, I didn't know this '^' thing ;-)

Le vendredi 24 février 2012 à 15:52 -0500, Jeff King a écrit :
> On Fri, Feb 24, 2012 at 08:55:45PM +0100, Romain Vimont (®om) wrote:
> 
> > Tonight, I just tried something which do exactly what I wanted to do
> > this morning:
> > 
> > $ git checkout -b temp
> > $ git commit -a -m 'My config file with mock_data=true'
> > $ git tag -a v0.1 -m v0.1
> > $ git checkout master
> > $ git branch -D temp
> 
> There is nothing at all wrong with the commands above, but you might be
> interested to know that you can do it without the temporary branch:
> 
>   $ git commit -a -m 'My config...'
>   $ git tag -m v0.1 v0.1
>   $ git reset HEAD^
> 
> The final reset will rewind your branch tip and the index state to what
> it was before the commit, but will leave the files in the working tree
> untouched.
> 
> -Peff
> 

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

* Re: [BugReport] git tag -a / git show
  2012-02-24 21:42       ` Romain Vimont (®om)
@ 2012-02-24 21:44         ` Jeff King
  0 siblings, 0 replies; 9+ messages in thread
From: Jeff King @ 2012-02-24 21:44 UTC (permalink / raw)
  To: Romain Vimont (®om); +Cc: Zbigniew Jędrzejewski-Szmek, git

On Fri, Feb 24, 2012 at 10:42:43PM +0100, Romain Vimont (®om) wrote:

> Thank you, I didn't know this '^' thing ;-)

You might find the "Specifying Revisions" section of "git help
rev-parse" enlightening. :)

-Peff

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

* Re: [Not A BugReport] git tag -a / git show
  2012-02-24 19:58   ` Romain Vimont (®om)
@ 2012-02-24 23:14     ` Andreas Schwab
  0 siblings, 0 replies; 9+ messages in thread
From: Andreas Schwab @ 2012-02-24 23:14 UTC (permalink / raw)
  To: Romain Vimont (®om); +Cc: Junio C Hamano, git

Romain Vimont "(®om)" <rom@rom1v.com> writes:

> To what other type of object can you apply a tag ?

Any.  Take a look at the junio-gpg-pub tag in git's repository, or the
v2.6.11-tree tag in Linus's kernel repository.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

end of thread, other threads:[~2012-02-24 23:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-24 10:24 [BugReport] git tag -a / git show Romain Vimont (®om)
2012-02-24 19:27 ` Zbigniew Jędrzejewski-Szmek
2012-02-24 19:55   ` Romain Vimont (®om)
2012-02-24 20:52     ` Jeff King
2012-02-24 21:42       ` Romain Vimont (®om)
2012-02-24 21:44         ` Jeff King
2012-02-24 19:50 ` [Not A BugReport] " Junio C Hamano
2012-02-24 19:58   ` Romain Vimont (®om)
2012-02-24 23:14     ` Andreas Schwab

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).