2

I have been playing around with what customizations you can do with Git logs and I think I have determined the right log for me. However, I am not sure how to tab the entire git message. I can do it on the first line and I am assuming that the entire git message is one long string.

Also, is it possible to output the entire git commit message similarly to how Git log default does? That is, 1 line per line of the message.

The default Git log:

commit 3246e9dfcf80d8edada9a559684b528658b8ccf5
Author: Reid
Date:   Thu Jun 9 16:30:35 2016 -0400

    Refactored Loading Indicators

commit 219a67a34036b40d18091ea3a1df6417c5feb245
Author: Reid
Date:   Fri Jun 3 14:50:59 2016 -0400

    Filter out Promotions < 0
    Submission of Promo Code working with error messages
    Refactored Loading Indicators
    Limit 1 promo code per order via Mini Cart
    Cart stays open if they change quantity of item
    Migrated Drawer Animation to an Extension
    Hooked into hideAllNavigation()
    Dynamically Set Items Container Height
    Implement the Mini Cart Experience Flag

My custom git log format:

3246e9d 2016-06-09 [Reid]

        Refactored Loading Indicators

219a67a 2016-06-03 [Reid]

        Filter out Promotions < 0 Submission of Promo Code working with error messages Refactored Loading Indicators Limit 1 promo code per order via Mini Cart Cart stays open if they change quantity of item Migrated Drawer Animation to an Extension Hooked into hideAllNavigation() Dynamically Set Items Container Height Implement the Mini Cart Experience Flag

My custom git log alias in git config:

[alias]
    logg = log --pretty=format:'%C(197)%h%Creset %C(039)%ad%Creset %C(177)[%an <%ae>]%Creset%n%n\t%s%n' --date=short
Bob Gilmore
  • 12,608
  • 13
  • 46
  • 53
reid
  • 546
  • 6
  • 21
  • Why not inserting multiple spaces instead of \t? – mid_kid Jun 15 '16 at 17:00
  • The character does not matter to me, I said tab but just a certain amount of space however its done. I just am looking to break up the sentence wrap into individual lines. – reid Jun 15 '16 at 18:38

3 Answers3

12

According to the manpage of git-log, one of the format characters is:

%x00: print a byte from a hex code

As x09 is the hex code for \t, you can insert %x09, and it will represent a tab character.

Jeff Puckett
  • 37,464
  • 17
  • 118
  • 167
mid_kid
  • 1,460
  • 2
  • 13
  • 15
  • Now what if I wanted to break that long line into seperate individual lines such as the default git log? – reid Jun 15 '16 at 18:37
  • Ah, I forgot that was part of the question. I have looked into the man page, but I can't figure out how to do that. I think it's something with `%w`. If someone else knows, please do tell. – mid_kid Jun 16 '16 at 14:03
  • 1
    I found it, Just append %w(80,9,9) in front of the selection of text you want to format. The width is the first #, the second is the first line indent, the third is the indent for every other line. https://git-scm.com/docs/git-shortlog – reid Jun 16 '16 at 14:42
4

I found it, Just append ex. %w(80,9,9) in front of the selection of text you want to format. The width is the first #, the second is the first line indent, the third is the indent for every other line.

Link to help describe the solution.

https://git-scm.com/docs/git-shortlog

reid
  • 546
  • 6
  • 21
1

The most accurate way to reproduce the default behavior of git log is to use %w with line wrap = 0, which indents the lines without wrapping them (per git shortlog), and %B to get the raw commit text, even when it doesn't conform to Git's ideal "subject line LF body" standard.

%w(0,4,4)%B

Here is a full "medium" log format in English:

%C(yellow)commit%C(auto) %H%d%nAuthor: %aN <%aE>%nDate:   %ad%n%n%w(0,4,4)%B

Sample output:

commit f7c28ecb35b64970f1af8f05fd644fb4bf663e2a (HEAD -> main, origin/main)
Author: Joel Spolsky
Date:   Wed Oct 08 19:45:20 2003 -0500

    The Absolute Minimum Every Software Developer 
    Absolutely, Positively Must Know About Unicode
    and Character Sets (No Excuses!)

    IT’S NOT THAT HARD.

(Note: This format omits merge parents, for which there is no specific format code.)

emclain
  • 96
  • 7