Fork me on GitHub
#off-topic
<
2018-03-30
>
vemv18:03:28

How is one supposed to know whether a git commit message spans more than one line? With either CLI or GUI, I normally am shown just the first line:

vemv18:03:11

so, a given commit may or may not include extensive rationale, but I cannot know that in a glance. Any known solution?

vemv18:03:39

(that's why I generally don't write multi-line messages / respect a column limit ;p)

sundarj19:03:04

the first line of a commit message is just the subject

vemv19:03:32

@sundarj That's the behavior I currently get

vemv19:03:41

it's fine but I cannot know if there are more lines

vemv19:03:18

ideally if there are more lines, the message would end with (+) in red

sundarj19:03:04

right, I see. that's not how the Git CLI expects commit messages to be used. you can read the subject lines at a glance, then if you need further context you open up a specific commit

sundarj19:03:32

it's up to the committers to add that context, naturally

sundarj19:03:42

GitHub does have a ... button

vemv19:03:19

oh didn't know about ... neat!

vemv19:03:46

maybe I can write a script that adds the desired (+) for me

vemv19:03:58

i.e. git log | sed whatever

vemv19:03:15

or if anyone can suggest an alternative, I welcome it

dominicm19:03:23

@vemv git log does show multi-line messages, including the extra lines. I think you have some customization going on.

vemv19:03:09

@dominicm I want the customization so I'm able to quickly find relevant commits. At the same time I care about extended info

vemv19:03:22

I seek bit of a 'best of both worlds' approach

vemv19:03:56

there seems to be no formatting option for this particular thing

sundarj19:03:20

yeah, seems like you'd have to put git log --format="%h %s %b" through awk or perl, detecting if the third column exists

vemv19:03:59

ah very nice! thanks for the hint

4
vemv23:03:24

multi-line search-and-replace appears to be a tricky problem, or at least my attempts failed miserably!

vemv23:03:58

my idea was to emit git log --format="%h %s XXX%bXXX" and then do a s/XXX.+XXX//. But multi-lines replacing seems to work differently, as I see no replacement being performed

sundarj23:03:14

yeah I think sed can do multi-line editing, but is really optimised for single-line editing

sundarj23:03:45

s'why I recommended awk/perl instead 😛

vemv23:03:54

tried some stuff. thanks anyway!

sundarj23:03:09

no worries

vemv23:03:10

seems like bit of a rabbit hole, since the XXX delimiter will be repeated many times, so a 'good' replacement may swallow N commits

sundarj23:03:47

oh yeah, good point

vemv23:03:45

got it! it was a matter of "greedy" vs "lazy". Didn't know about the concept really http://ruby-doc.org/core-2.5.0/Regexp.html

sundarj23:03:50

nice! i haven't done any regex stuff for yonks, tho i vaguely remember about greedy/lazy. glad you got it sorted 🙂

🙌 4
Alex Miller (Clojure team)19:03:51

not really an answer for this specifically but it reminded me I stole these from someone (add to your [alias] block in ~/.gitconfig):

lol = log --graph --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white)— %an%C(reset)%C(bold yellow)%d%C(reset)' --abbrev-commit --date=relative
lola = log --graph --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white)— %an%C(reset)%C(bold yellow)%d%C(reset)' --abbrev-commit --date=relative --all
lolas = log --graph --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white)— %an%C(reset)%C(bold yellow)%d%C(reset)' --abbrev-commit --date=relative --all --stat

Alex Miller (Clojure team)19:03:53

I use git lol all the day long

bronsa19:03:49

haha, neat

vemv23:03:39

Working command: git log --no-merges --pretty=format:'%Cred%h%Creset -%Creset %sXXX%bXXX %Cgreen(%cr) %C(bold blue)%an%Creset' --abbrev-commit | ruby -e 'puts STDIN.read.to_s.gsub("XXXXXX", "").gsub(/XXX.+?XXX/m, " (+)") rescue nil' | less bit hacky 😇

4