git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Josh Rampersad <josh.rampersad@voiceflow.com>
Cc: git@vger.kernel.org
Subject: [PATCH 0/2] log: handle --decorate-ref without explicit --decorate
Date: Thu, 2 Dec 2021 00:30:43 -0500	[thread overview]
Message-ID: <YahaA/ve7W5Y83Iu@coredump.intra.peff.net> (raw)
In-Reply-To: <C29F5770-5092-40A6-9604-DA5F7166575D@voiceflow.com>

On Wed, Dec 01, 2021 at 05:31:03PM -0500, Josh Rampersad wrote:

> 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

  reply	other threads:[~2021-12-02  5:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-01 22:31 Bug Report Josh Rampersad
2021-12-02  5:30 ` Jeff King [this message]
2021-12-02  5:35   ` [PATCH 1/2] log: handle --decorate-refs with userformat "%d" Jeff King
2021-12-02  5:37   ` [PATCH 2/2] log: load decorations with --simplify-by-decoration Jeff King

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=YahaA/ve7W5Y83Iu@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=josh.rampersad@voiceflow.com \
    /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).