git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] builtin/fetch: print hash of deleted tag when updating
@ 2010-09-26 16:10 Knittl
  2010-09-26 21:41 ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Knittl @ 2010-09-26 16:10 UTC (permalink / raw
  To: git

>From b1c2b07aa1f5db25ebdf190aa12ccb66a17f131a Mon Sep 17 00:00:00 2001
From: Daniel Knittl-Frank <knittl89+git@googlemail.com>
Date: Sun, 26 Sep 2010 11:29:16 +0200
Subject: [PATCH] builtin/fetch: print hash of deleted tag when updating

`git fetch --tags` will unconditionally update (and thus overwrite)
existing tags, which is especially annoying for annotated and signed
tags.

Print the hash of the deleted tag so users can manually
recover their tags from such an update.

Signed-off-by: Daniel Knittl-Frank <knittl89+git@googlemail.com>
---
 builtin/fetch.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/builtin/fetch.c b/builtin/fetch.c
index 6fc5047..3c2eac4 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -253,9 +253,10 @@ static int update_local_ref(struct ref *ref,
 	    !prefixcmp(ref->name, "refs/tags/")) {
 		int r;
 		r = s_update_ref("updating tag", ref, 0);
-		sprintf(display, "%c %-*s %-*s -> %s%s", r ? '!' : '-',
+		sprintf(display, "%c %-*s %-*s -> %s%s (was %s)", r ? '!' : '-',
 			TRANSPORT_SUMMARY_WIDTH, "[tag update]", REFCOL_WIDTH, remote,
-			pretty_ref, r ? "  (unable to update local ref)" : "");
+			pretty_ref, r ? "  (unable to update local ref)" : "",
+			find_unique_abbrev(ref->old_sha1, DEFAULT_ABBREV));
 		return r;
 	}

-- 
1.7.3.68.gb1c2b


-- 
typed with http://neo-layout.org
myFtPhp -- visit http://myftphp.sf.net -- v. 0.4.7 released!

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

* Re: [PATCH] builtin/fetch: print hash of deleted tag when updating
  2010-09-26 16:10 [PATCH] builtin/fetch: print hash of deleted tag when updating Knittl
@ 2010-09-26 21:41 ` Junio C Hamano
  2010-09-27  7:09   ` Knittl
  2010-09-27 11:37   ` Peter Kjellerstedt
  0 siblings, 2 replies; 6+ messages in thread
From: Junio C Hamano @ 2010-09-26 21:41 UTC (permalink / raw
  To: Knittl; +Cc: git

Knittl <knittl89@googlemail.com> writes:

> From b1c2b07aa1f5db25ebdf190aa12ccb66a17f131a Mon Sep 17 00:00:00 2001
> From: Daniel Knittl-Frank <knittl89+git@googlemail.com>
> Date: Sun, 26 Sep 2010 11:29:16 +0200
> Subject: [PATCH] builtin/fetch: print hash of deleted tag when updating
>
> `git fetch --tags` will unconditionally update (and thus overwrite)
> existing tags, which is especially annoying for annotated and signed
> tags.

The first question is why s/he is running fetch with --tags if overwriting
is unwelcome/annoying.  "--tags" is meant to be used when the auto-follow
behaviour of normal fetch is not sufficient and the user actively wants to
get the latest (potentially updated) ones; would it be possible that you
are solving a wrong problem?

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

* Re: [PATCH] builtin/fetch: print hash of deleted tag when updating
  2010-09-26 21:41 ` Junio C Hamano
@ 2010-09-27  7:09   ` Knittl
  2010-09-27 11:37   ` Peter Kjellerstedt
  1 sibling, 0 replies; 6+ messages in thread
From: Knittl @ 2010-09-27  7:09 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git

On Sun, Sep 26, 2010 at 11:41 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Knittl <knittl89@googlemail.com> writes:
>
>> From b1c2b07aa1f5db25ebdf190aa12ccb66a17f131a Mon Sep 17 00:00:00 2001
>> From: Daniel Knittl-Frank <knittl89+git@googlemail.com>
>> Date: Sun, 26 Sep 2010 11:29:16 +0200
>> Subject: [PATCH] builtin/fetch: print hash of deleted tag when updating
>>
>> `git fetch --tags` will unconditionally update (and thus overwrite)
>> existing tags, which is especially annoying for annotated and signed
>> tags.
>
> The first question is why s/he is running fetch with --tags if overwriting
> is unwelcome/annoying.  "--tags" is meant to be used when the auto-follow
> behaviour of normal fetch is not sufficient and the user actively wants to
> get the latest (potentially updated) ones; would it be possible that you
> are solving a wrong problem?

yes, i know that tags are only overwritten with `git fetch --tags` and
not during normal fetch operations. nevertheless, manually looking at
tags and find the ones which would be overwritten is cumbersome and
errorprone.

imho this patch doesn't hurt, only adding "(was $HASH)" -- and in case
a user decides, that he suddenly wants to keep one of his (updated)
tags, he can recover them quickly by echoing the hash into
.git/refs/tags/new-name-for-my-tag. otherwise the use would have to
run git fsck and find dangling hashes.

again, i'm not changing behavior of `git fetch --tags`, i'm simply
providing additional output to help you recover your own tags. case:
possibly conflicting tags and you want to 'merge' your tags with
upstream tags.

if you deem it unnecessary, ok, nothing i can do about that ;)

-- 
typed with http://neo-layout.org
myFtPhp -- visit http://myftphp.sf.net -- v. 0.4.7 released!

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

* RE: [PATCH] builtin/fetch: print hash of deleted tag when updating
  2010-09-26 21:41 ` Junio C Hamano
  2010-09-27  7:09   ` Knittl
@ 2010-09-27 11:37   ` Peter Kjellerstedt
  2010-09-27 16:38     ` Junio C Hamano
  1 sibling, 1 reply; 6+ messages in thread
From: Peter Kjellerstedt @ 2010-09-27 11:37 UTC (permalink / raw
  To: Junio C Hamano, Knittl; +Cc: git@vger.kernel.org

> -----Original Message-----
> From: git-owner@vger.kernel.org [mailto:git-owner@vger.kernel.org] On
> Behalf Of Junio C Hamano
> Sent: den 26 september 2010 23:42
> To: Knittl
> Cc: git@vger.kernel.org
> Subject: Re: [PATCH] builtin/fetch: print hash of deleted tag when
> updating
> 
> Knittl <knittl89@googlemail.com> writes:
> 
> > From b1c2b07aa1f5db25ebdf190aa12ccb66a17f131a Mon Sep 17 00:00:00 2001
> > From: Daniel Knittl-Frank <knittl89+git@googlemail.com>
> > Date: Sun, 26 Sep 2010 11:29:16 +0200
> > Subject: [PATCH] builtin/fetch: print hash of deleted tag when updating
> >
> > `git fetch --tags` will unconditionally update (and thus overwrite)
> > existing tags, which is especially annoying for annotated and signed
> > tags.
> 
> The first question is why s/he is running fetch with --tags if overwriting
> is unwelcome/annoying.

Maybe because the user is a git newbie who has just started to 
learn her first git commands and found --tags in the manual page, 
thinking "oh, nice, this will make sure I get all tags". Or because 
she added it to remote.<name>.tagopt without knowing that it would 
overwrite tags in this way.

> "--tags" is meant to be used when the auto-follow
> behaviour of normal fetch is not sufficient and the user actively wants to
> get the latest (potentially updated) ones;

If that (i.e., potentially updated) is the intention, it is not 
mentioned in the manual page for fetch. Further, reading "On 
Re-tagging" in the manual page for git tag, it says "Git does not 
(and it should not) change tags behind users back" (which I agree
with) but it seems contrary to what --tags does...

Shouldn't this behavior of --tags require --force to keep in line 
with what is described in git tag's manual page? If not, a big
warning sign is needed in the manual page description of --tags.

> would it be possible that you are solving a wrong problem?

Since git reflog does not support showing how a tag has changed, 
I think something like Daniel's patch is a good idea, as the 
alternative is to use git fsck and start digging...

//Peter

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

* Re: [PATCH] builtin/fetch: print hash of deleted tag when updating
  2010-09-27 11:37   ` Peter Kjellerstedt
@ 2010-09-27 16:38     ` Junio C Hamano
  2010-10-10 13:17       ` Knittl
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2010-09-27 16:38 UTC (permalink / raw
  To: Peter Kjellerstedt; +Cc: Knittl, git@vger.kernel.org

Peter Kjellerstedt <peter.kjellerstedt@axis.com> writes:

> Shouldn't this behavior of --tags require --force to keep in line 
> with what is described in git tag's manual page?

Sounds sensible, if nobody is already relying on this behaviour.

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

* Re: [PATCH] builtin/fetch: print hash of deleted tag when updating
  2010-09-27 16:38     ` Junio C Hamano
@ 2010-10-10 13:17       ` Knittl
  0 siblings, 0 replies; 6+ messages in thread
From: Knittl @ 2010-10-10 13:17 UTC (permalink / raw
  To: Junio C Hamano; +Cc: Peter Kjellerstedt, git@vger.kernel.org

On Mon, Sep 27, 2010 at 6:38 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Peter Kjellerstedt <peter.kjellerstedt@axis.com> writes:
>
>> Shouldn't this behavior of --tags require --force to keep in line
>> with what is described in git tag's manual page?
>
> Sounds sensible, if nobody is already relying on this behaviour.

any updates on this one?

even if we require the --force option it wouldn't hurt if we displayed
the old hash, does it?


-- 
typed with http://neo-layout.org
myFtPhp -- visit http://myftphp.sf.net -- v. 0.4.7 released!

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

end of thread, other threads:[~2010-10-10 13:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-26 16:10 [PATCH] builtin/fetch: print hash of deleted tag when updating Knittl
2010-09-26 21:41 ` Junio C Hamano
2010-09-27  7:09   ` Knittl
2010-09-27 11:37   ` Peter Kjellerstedt
2010-09-27 16:38     ` Junio C Hamano
2010-10-10 13:17       ` Knittl

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).