git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Matheus Tavares Bernardino <matheus.bernardino@usp.br>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jeff King <peff@peff.net>, git <git@vger.kernel.org>,
	Roland Hieber <rhi@pengutronix.de>
Subject: Re: [PATCH] describe: output tag's ref instead of embedded name
Date: Thu, 20 Feb 2020 19:19:20 -0300	[thread overview]
Message-ID: <CAHd-oW7HJb2d10U_dcbB6G-UdopQ7HKyghAji=9VhmAgn3Dw_Q@mail.gmail.com> (raw)
In-Reply-To: <xmqq4kvlcgcz.fsf@gitster-ct.c.googlers.com>

On Thu, Feb 20, 2020 at 2:34 PM Junio C Hamano <gitster@pobox.com> wrote:
>
[...]
> Another thing that is not satisfying is what should happen in "all"
> mode.  We add "tags/" prefix so in the case we've been discussing,
> the output would be "tags/v1.0-0-g0123456", but the whole reason why
> we add the prefix is to say that the early part of the name, "v1.0",
> is a tag, and it would be natural to associate it with refs/tags/v1.0
> that is *not* Bob's tag.

Yeah, that is not very satisfying, but at least the emitted warning
would make the user think twice before wrongly associating
refs/tags/v1.0 with Bob's tag?

> Having said all that, here is what I have at this moment.
>
> -- >8 --
> Subject: describe: force long format for a name based on a mislocated tag
[...]
>
> The output from "git describe", at least in the modern Git, should
> be usable as an object name to name the exact commit given to the
> "git describe" command.  Using the tagname, when two names differ,
> breaks this property, when describing a commit that is directly
> pointed at by such a tag.  An annotated tag Bob made as "v1.0" may
> sit at "refs/tags/v1.0-bob" in the ref hierarchy, and output from
> "git describe v1.0-bob^0" would say "v1.0", but there may not be
> any tag at "refs/tags/v1.0" locally or there may be another tag that
> points at a different object.
>
> Note that this won't be a problem if a commit being described is not
> directly pointed at by such a mislocated tag.  In the example in the
> previous paragraph, "git describe v1.0-bob~1" would result in "v1.0"
> (i.e. the tagname taken from the tag object) followed by "-1-gXXXXX"

I now this is just an illustration, but shouldn't this example be "git
describe --contains v1.0-bob~1"? Otherwise, I think the tag wouldn't
be found as it comes after the given commit. Testing here without
--contains I get the error "fatal: No tags can describe <sha1 hash>"

However, when using --contains, the output is also not what I
expected. It doesn't fail, but I get "v1.0-bob~1". I.e., it not only
prints the refname instead of the tagname but also don't print any
warnings... This is not what we want, right?

> Show the name in the long format, i.e. with "-0-gXXXXX" suffix, when
> the name we give is based on a mislocated annotated tag to ensure
> that the output can be used as the object name for the object
> originally given to the command to fix the issue.

Another case that came to my mind is when the user runs `git describe
--abrev=0 HEAD` and v1.0-bob points to HEAD~. In this case, v1.0 will
be displayed without suffix, so it is not usable at get_oid(). Should
we, perhaps, also force the long output in this case?

And talking about the forced long output, using `--abbrev=0` in HEAD
(i.e. tag: v1.0-bob), after the patch, will make the complete hash be
displayed. This might be an unnecessary cosmetic nitpick, but we might
want to follow the default behavior when --long is given and use just
as many digits as necessary?

  reply	other threads:[~2020-02-20 22:19 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-05 14:13 git-describe --tags warning: 'X' is really 'Y' here Roland Hieber
2020-02-05 17:15 ` Matheus Tavares Bernardino
2020-02-14  6:53   ` Jeff King
2020-02-14 16:57     ` Junio C Hamano
2020-02-15 21:34       ` [PATCH] describe: output tag's ref instead of embedded name Matheus Tavares
2020-02-16  6:51         ` Jeff King
2020-02-18 19:31           ` Junio C Hamano
2020-02-18 19:54             ` Jeff King
2020-02-18 23:05               ` Junio C Hamano
2020-02-18 23:28                 ` Junio C Hamano
2020-02-19  1:57                   ` Jeff King
2020-02-19  3:22                     ` Junio C Hamano
2020-02-19  3:56                       ` Jeff King
2020-02-19 11:14                         ` Junio C Hamano
2020-02-20 11:25                           ` Jeff King
2020-02-20 17:34                             ` Junio C Hamano
2020-02-20 22:19                               ` Matheus Tavares Bernardino [this message]
2020-02-20 22:59                                 ` Junio C Hamano
2020-02-21  1:33                                   ` Matheus Tavares
2020-02-21  2:05                                     ` Junio C Hamano
2020-02-21  6:00                                       ` Jeff King
2020-02-21  5:58                               ` Jeff King
2020-02-19 10:08                       ` Roland Hieber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHd-oW7HJb2d10U_dcbB6G-UdopQ7HKyghAji=9VhmAgn3Dw_Q@mail.gmail.com' \
    --to=matheus.bernardino@usp.br \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=rhi@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).