Thread (1 message) 1 message, 1 author, 2021-02-22

Re: noeol when redirect git log output to a file

From: Junio C Hamano <hidden>
Date: 2021-02-22 17:21:20

Wang Yugui [off-list ref] writes:
[root@T640 ~]# git log '--pretty=format:%h: %an: %s' -- hw/ >a.txt
This is an expected behaviour.

Notice that the format string given above does not end in LF by
itself (its final placeholder is the subject string without LF at
the end).  LF you'd see in the output all come from the "log"
machinery and not from the format string.  When the machinery adds
LFs, there are "separator" and "terminator" behaviour, the former of
which adds a separating LF between each item, while the latter adds
a terminating LF after each item.

"--pretty=format" is defined to use a separator semantics that is
suited to show multi-line items, each of which ends in LF on its own
(think of --pretty=format:"by %an%n%b").  Using terminator behaviour
you'd get an useless extra LF at the end for such a format, and
separator behaviour lets you avoid it.

"git log --help" and find "tformat", to learn more.  --format=<fmt>,
instead of --pretty=format:<fmt>, may also help.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help