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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux