git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Wang Yugui <wangyugui@e16-tech.com>
Cc: git@vger.kernel.org
Subject: Re: noeol when redirect git log output to a file
Date: Mon, 22 Feb 2021 09:20:32 -0800	[thread overview]
Message-ID: <xmqqk0r081en.fsf@gitster.g> (raw)
In-Reply-To: <20210222231406.CE72.409509F4@e16-tech.com> (Wang Yugui's message of "Mon, 22 Feb 2021 23:14:07 +0800")

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.

      reply	other threads:[~2021-02-22 17:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-22 15:14 noeol when redirect git log output to a file Wang Yugui
2021-02-22 17:20 ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqk0r081en.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=wangyugui@e16-tech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).