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

Re: Git log --tags isn't working as expected

From
Jeff King <peff@peff.net>
Date
Aug 2, 2017, 08:32 UTC
Message-ID
<20170802083200.3rmnz6mx2wfoarng@sigill.intra.peff.net>
In-Reply-To
<CACq05g+4HH9L_fiFLR8php=w5JkqB0792SzR9EZU-o+QHuoM8A@mail.gmail.com>
On Wed, Aug 02, 2017 at 08:41:41AM +0100, Richard Jones wrote:
Show 7 quoted lines
> I’m trying to locate a commit which takes place after another one,
> matches a certain tag, and is by a specific user. I have the following
> command:
> 
> git log <COMMIT_ID>..HEAD --decorate --author=“<AUTHOR>" --tags=“project-name”
> 
> The tag follows the format: project-name-version

I think you want --tags="project-name-*", as the pattern is a glob. If you omit any wildcards, it does a prefix match, but only at "/" boundaries. That's the implied "/*" from the docs:

  --tags[=<pattern>]
    Pretend as if all the refs in refs/tags are listed on the command
    line as <commit>. If <pattern> is given, limit tags to ones matching
    given shell glob. If pattern lacks ?, *, or [, /* at the end is implied.
> How ever this doesn’t seem to work, as it returns all the commits by
> that user since the commit ID supplied.

Your ref selector "--tags" didn't match anything. So we just showed <COMMIT_ID>..HEAD.

However, I suspect "--tags" still doesn't quite do what you want. It behaves as if each tag was given as a starting point for a traversal. So we'd generally show <COMMIT_ID>..HEAD in _addition_ to any tags we found (and any commits reachable from those tags, down to <COMMIT_ID>). But it sounds like you want to just see tags. For that, I'd do one of:

  1. Ask git-tag to show the interesting bits of your tags, like:
       git tag --format='%(refname:short) %(*authorname) / %(*subject)'
     The "*" there is dereferencing the tag to show the underlying
     commit. See the FIELD NAMES section of git-for-each-ref for more
     details. You can further limit that to tags that contain a
     particular commit with "--contains <COMMIT_ID>".
  2. Feed git-log some ref tips but ask it not to walk:
       git log --no-walk --tags='project-name-*'
     This is similar to (1), but uses the revision machinery, which can
     show more about each commit (e.g., the diff). But I don't think
     there's a good way to ask only for the tips that contain your
     particular commit (a negative endpoint like "<COMMIT_ID>.." doesn't
     play well with --no-walk, I think).
  3. Use --simplify-by-decoration to show a particular range of commits,
     but limit to ones that actually have a ref pointing at them. Like:
       git log <COMMIT_ID>..HEAD --simplify-by-decoration

I think (3) matches what you're trying to do the best. You can't say "just tags" for the decoration, though, so you'll see branch tips as well. There's been some discussion about allowing specific decorations, but nothing merged yet.

-Peff
Previous: Richard JonesNext: Junio C Hamano
Message 2 of 6 in “Git log --tags isn't working as expected”
  1. Richard JonesAug 2, 2017
  2. Jeff KingAug 2, 2017
  3. Junio C HamanoAug 2, 2017
  4. Jeff KingAug 2, 2017
  5. Junio C HamanoAug 2, 2017
  6. Jeff KingAug 2, 2017

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.