# git pretty format: "%+b" not working with "%w" in front of it?

2 messages from 2017-03-15 to 2017-03-15. Participants: Robert Dailey, Jeff King.
Thread: https://gitlist.dev/t/45386

## Robert Dailey, 2017-03-15 14:08

Subject: git pretty format: "%+b" not working with "%w" in front of it?
Message-ID: <CAHd499BP-iaXJDNg+4RWB9GaQ1xW8ZnH0oysWSa7u_DCSWFFDg@mail.gmail.com>
URL: https://gitlist.dev/e/CAHd499BP-iaXJDNg%2B4RWB9GaQ1xW8ZnH0oysWSa7u_DCSWFFDg%40mail.gmail.com

```
I have the following log:

$ git log

commit 7ffb909bb8f38607e3d6d9f3504a66ca978f0ac2
Author: Robert Dailey <robert@ziosk.com>
Date:   Mon Dec 12 11:01:00 2016 -0600

    Add initial skeleton files & a few interfaces for new kizi/sc16 stuff

    This is still FAR from complete....


I want to generate changelogs, using github markdown list format. I
tried doing that using this command:

$ git log --pretty=format:"* %s%n%w(100,2,2)%+b"

However, the 2nd newline is not inserted:

* Add initial skeleton files & a few interfaces for new kizi/sc16 stuff
   This is still FAR from complete....

The format I'm expecting is:

* Add initial skeleton files & a few interfaces for new kizi/sc16 stuff

  This is still FAR from complete....

This seems to work, but I do not get the 2-space indentation required
to continue text on the current list item:

$ git log --pretty=format:"* %s%n%+b"

* Add initial skeleton files & a few interfaces for new kizi/sc16 stuff

This is still FAR from complete....

So why isn't it working when I use %w before the %+b? Am I doing
something wrong? Note I'm using git version 2.10 on Windows through
Git Bash.

```

## Jeff King, 2017-03-15 15:18

Subject: Re: git pretty format: "%+b" not working with "%w" in front of it?
Message-ID: <20170315151853.c3mn7xyc5fqmkkn4@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20170315151853.c3mn7xyc5fqmkkn4%40sigill.intra.peff.net
In-Reply-To: <CAHd499BP-iaXJDNg+4RWB9GaQ1xW8ZnH0oysWSa7u_DCSWFFDg@mail.gmail.com>

```
On Wed, Mar 15, 2017 at 09:08:10AM -0500, Robert Dailey wrote:

> $ git log
> 
> commit 7ffb909bb8f38607e3d6d9f3504a66ca978f0ac2
> Author: Robert Dailey <robert@ziosk.com>
> Date:   Mon Dec 12 11:01:00 2016 -0600
> 
>     Add initial skeleton files & a few interfaces for new kizi/sc16 stuff
> 
>     This is still FAR from complete....
> 
> 
> I want to generate changelogs, using github markdown list format. I
> tried doing that using this command:
> 
> $ git log --pretty=format:"* %s%n%w(100,2,2)%+b"
> 
> However, the 2nd newline is not inserted:
> 
> * Add initial skeleton files & a few interfaces for new kizi/sc16 stuff
>    This is still FAR from complete....
> 
> The format I'm expecting is:
> 
> * Add initial skeleton files & a few interfaces for new kizi/sc16 stuff
> 
>   This is still FAR from complete....

Hmm. I think the leading newline is added, but it gets eaten by the
wrapping code. If I run your example in a debugger, we enter
strbuf_add_wrapped_text() with:

  buf = "* the subject line\n"
  text = "\nthe body text"
  indent1=2, indent2=2, width=100

Which looks right.  But the wrapping code seems to treat blank lines
oddly. I can't quite figure out what it's _trying_ to do, but if there's
one blank line, it gets converted into a space (and thus the weird
three-space indent you see). But if there are two, they are both
preserved!

So I think the line-wrapping code is simply buggy, and you are not doing
anything wrong. But maybe I am missing some subtle case.

-Peff

```
