Git print captures body lines connected in one line

How can I print git to print only the body (commit message without a header), but on one line? Thus, the closing lines of the body are connected, possibly separated by a space and printed as one line for one fixation.

For example, with two commits A and B, the command:

$ git log --format=%b

prints:

Commit A, line A.1
Commit A, line A.2
Commit B, line B.1
Commit B, line B.2

But I would like to:

Commit A, line A.1 Commit A, line A.2
Commit B, line B.1 Commit B, line B.2
+4
source share
1 answer
git rev-list master |
    while read sha1; do
        git show -s --format='%B' $sha1 | tr -d '\n'; echo
    done

Let me explain:

git rev-list master

List the identifiers SHA1 commits in the branch.

    while read sha1; do

Run a loop through each SHA1.

        git show -s --format='%B' $sha1

Show body fixation.

        tr -d '\n'

Delete all line endings.

        echo

Add one new line to the end.

+3
source

Source: https://habr.com/ru/post/1695480/


All Articles