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

[PATCH 0/2] log: handle --decorate-ref without explicit --decorate

From
Jeff King <peff@peff.net>
Date
Dec 2, 2021, 05:30 UTC
Message-ID
<YahaA/ve7W5Y83Iu@coredump.intra.peff.net>
In-Reply-To
<C29F5770-5092-40A6-9604-DA5F7166575D@voiceflow.com>
On Wed, Dec 01, 2021 at 05:31:03PM -0500, Josh Rampersad wrote:
Show 5 quoted lines
> Ran the command: `git log origin/master --no-walk --grep='my-package' --tags='*my-package*' --decorate-refs='*my-package*'  --format='format:%ct %H %D'`
> The output was as expected with the tags not relating to my-package being filtered out from the output by the decorate-refs option.
> I then, wanted to pipe this output to a separate program.
> [...]
> The filtering I got from the decorate-refs flag was no longer being applied. Thus giving me a bunch of tags I did not want

Thanks for a clear description. As a quick reproduction in git.git, you can see this with:

  $ git log --no-walk --format='%s%d' --decorate-refs=*/v2.0.0 v2.1.0 v2.0.0
  Git 2.1
  Git 2.0 (tag: v2.0.0)
  $ git log --no-walk --format='%s%d' --decorate-refs=*/v2.0.0 v2.1.0 v2.0.0 | cat
  Git 2.1 (tag: v2.1.0)
  Git 2.0 (tag: v2.0.0)

The problem is that without an explicit --decorate, git-log doesn't realize it needs to initialize the decorations with the --decorate-refs argument. Later code realizes that "%d" requires decorations, so we load them then, but fail to pay attention to the extra arguments.

The reason it's different with a pipe is that the default is --decorate=auto, so it behaves as if --decorate is given depending on whether stdout is a terminal.

Here are two patches. The first fixes the bug you saw, and the second is a similar bug with --simplify-by-decoration. In the meantime, a workaround is to specify --decorate along with --decorate-refs.

  [1/2]: log: handle --decorate-refs with userformat "%d"
  [2/2]: log: load decorations with --simplify-by-decoration
 builtin/log.c  | 23 +++++++++++++++++++----
 t/t4202-log.sh | 37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 4 deletions(-)
-Peff
Previous: Josh RampersadNext: Jeff King
Message 2 of 4 in “Bug Report”
  1. Josh RampersadDec 1, 2021
  2. 0/2 log: handle --decorate-ref without explicit --decorateJeff King, Dec 2, 2021
  3. 1/2 log: handle --decorate-refs with userformat "%d"Jeff King, Dec 2, 2021
  4. 2/2 log: load decorations with --simplify-by-decorationJeff King, Dec 2, 2021

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.