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

Re: [PATCH] fetch: show reference pointed by new tags

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 7, 2016, 00:18 UTC
Message-ID
<xmqq60wzta2s.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1457303694-16153-1-git-send-email-eric@engestrom.ch>
Eric Engestrom <eric@engestrom.ch> writes:
Show 7 quoted lines
> Before, new tags had their names shown twice:
>  * [new tag]         v4.5-rc6   -> v4.5-rc6
>
> Instead, show the hash of the commit pointed to:
>  * [new tag]         v4.5-rc6   -> fc77dbd
>
> Signed-off-by: Eric Engestrom <eric@engestrom.ch>

The report from update-local-refs is meant to show what "local" names the updated ref has, i.e. what names you can refer the result as. If you fetched v4.5-rc6, the output tells you that you can refer to it as v4.5-rc6 in your local repository.

Technically, you can also refer to the tag as fc77dbd, but I do not see why a user would want to.

In addition, if I did:
    $ git fetch $his_repository 'refs/tags/*:refs/tags/his/*'

I'd see his 'v1.0' tag locally stored as 'his/v1.0', and that is what is shown in the output as

  * [new tag] v1.0 -> his/v1.0

so that I know I can refer to his v1.0 as "his/v1.0", to differenticate from the tag I happen to have created as v1.0 in my local repository.

So, why is this change an improvement?
Show 27 quoted lines
> ---
>
> This is my first dive into git's code, so it's likely I'm not doing things
> right. The first candidate for that is the literal `7`, which should probably
> be a variable, but I couldn't find what I should use instead.
>
> I'd be happy to fix this for a v2 :]
>
> Cheers,
>   Eric
>
>
>  builtin/fetch.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index e4639d8..93b2145 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
> @@ -515,6 +515,7 @@ static int update_local_ref(struct ref *ref,
>  		if (starts_with(name, "refs/tags/")) {
>  			msg = "storing tag";
>  			what = _("[new tag]");
> +			pretty_ref = find_unique_abbrev(ref->new_oid.hash, 7);
>  		} else if (starts_with(name, "refs/heads/")) {
>  			msg = "storing head";
>  			what = _("[new branch]");
Previous: Eric EngestromNext: Junio C Hamano
Message 2 of 5 in “fetch: show reference pointed by new tags”
  1. fetch: show reference pointed by new tagsEric Engestrom, Mar 6, 2016
  2. Junio C HamanoMar 7, 2016
  3. Junio C HamanoMar 7, 2016
  4. Junio C HamanoMar 8, 2016
  5. Eric EngestromMar 13, 2016

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.