git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / Atom feed
* noeol when redirect git log output to a file
@ 2021-02-22 15:14 Wang Yugui
  2021-02-22 17:20 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Wang Yugui @ 2021-02-22 15:14 UTC (permalink / raw)
  To: git

Hi,

noeol when redirect git log output to a file.

[root@T640 ~]# git log '--pretty=format:%h: %an: %s' -- hw/ >a.txt
[root@T640 ~]# cat a.txt
c2accaa: wangyugui:
757bec2: wangyugui:
cefb5d4: wangyugui:
2fc0dbe: wangyugui:
6cfe6cf: wangyugui:
e8a94b1: wangyugui:
ba54c6a: wangyugui:
7de214e: wangyugui:
8f2588a: wangyugui:
5834825: wangyugui:
cd30711: wangyugui:
8807c7d: wangyugui:
edd4e92: wangyugui:
0c6f3dd: wangyugui:
38964f4: wangyugui:
4fd21e8: wangyugui:
52fa7b0: wangyugui:
93f5ddb: wangyugui:
47c7aa4: wangyugui:
ab23c1f: wangyugui: OK
8002e69: wangyugui:
da8a6d5: wangyugui:
ed2f4e0: wangyugui: baseline[root@T640 ~]#

but without redirect, it seems OK.
[root@T640 ~]# git log '--pretty=format:%h: %an: %s' -- hw/
c2accaa: wangyugui:
757bec2: wangyugui:
cefb5d4: wangyugui:
2fc0dbe: wangyugui:
6cfe6cf: wangyugui:
e8a94b1: wangyugui:
ba54c6a: wangyugui:
7de214e: wangyugui:
8f2588a: wangyugui:
5834825: wangyugui:
cd30711: wangyugui:
8807c7d: wangyugui:
edd4e92: wangyugui:
0c6f3dd: wangyugui:
38964f4: wangyugui:
4fd21e8: wangyugui:
52fa7b0: wangyugui:
93f5ddb: wangyugui:
47c7aa4: wangyugui:
ab23c1f: wangyugui: OK
8002e69: wangyugui:
da8a6d5: wangyugui:
ed2f4e0: wangyugui: baseline
[root@T640 ~]#


[System Info]
git version:
git version 2.30.1
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Linux 5.10.17-3.el7.x86_64 #1 SMP Mon Feb 22 10:43:13 CST 2021 x86_64
compiler info: gnuc: 4.8
libc info: glibc: 2.17
$SHELL (typically, interactive shell): /bin/bash

[Enabled Hooks]
None

Best Regards
王玉贵
2021/02/22

--------------------------------------
北京京垓科技有限公司
王玉贵	wangyugui@e16-tech.com
电话:+86-136-71123776


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: noeol when redirect git log output to a file
  2021-02-22 15:14 noeol when redirect git log output to a file Wang Yugui
@ 2021-02-22 17:20 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2021-02-22 17:20 UTC (permalink / raw)
  To: Wang Yugui; +Cc: git

Wang Yugui <wangyugui@e16-tech.com> 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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-02-22 17:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-22 15:14 noeol when redirect git log output to a file Wang Yugui
2021-02-22 17:20 ` Junio C Hamano

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git