Subject: Re: git log --encoding=HTML is not supported

From: Junio C Hamano <[email-masked]>
Date: Thu, 26 Aug 2021 08:37:40 -0700

Bryan Turner <[email-masked]> writes:

> On Wed, Aug 25, 2021 at 4:29 PM Krzysztof Żelechowski
> <[email-masked]> wrote:
>>
>> Dnia środa, 25 sierpnia 2021 02:57:47 CEST Jeff King pisze:
>> > diff --git a/pretty.c b/pretty.c
>>
>> Please fix the manual for git log.  It should say what encoding is recognised
>> (namely if supported by iconv(1), except that POSIX character maps of
>> iconv(1p) are not supported), and that an unrecognised encoding is ignored.
>>
>> I would also like to see the HTML encoding supported independently of iconv,
>> which seems like a pretty easy thing to do.  Dream on, I guess?
>
> I suspect the answer is less "Dream on" and more "Patches welcome."

Patches are welcomed but not before a proposed design is freshed
out.  I am sure people do welcome the design discussion.

Pieces taken from the contents stored in Git (like "the title of the
commit", "the name of the author of the commit") may need quoting
and/or escaping when they are incorporated into a string to become
parts of "output", and the way the quoting/escaping must be done
would depend on the "host" language/format.  HTML has its own
requirements for how these pieces coming from Git contents are
quoted, but it will not be the only "host" language that needs
quoting.

The requirement for the feature we are "Dreaming on" may be much
closer to the "host language" options (e.g. --tcl, --perl ...) the
"git for-each-ref" command has.  These options tells us to format
each piece of information (e.g. "%(subject)") taken from Git as a
natural 'string' constant in the host language, so that

	git for-each-ref --shell \
	    --format='do_something %(authorname) %(authoremail)'

would write a shell script that calls "do_something" command with
two arguments for each ref enumerated by the command, without having
to worry about whitespaces and quote characters that may appear in
the interpolated pieces.  It is immediately obvious that within the
context of the for-each-ref command, the follwoing would equally be
useful (note: this is already "dreaming on" and does not exist yet):

	echo "<ul>"
	git for-each-ref --html \
		--format='<li>%(authoremail)</li>'
	echo "</ul>"

As we have been seeing efforts to port features around the --format
option between the for-each-ref family of commands and the log
family of commands, I would also imagine that it would be natural
future direction to extend it to the latter and eventually allow

	git log --html \
		--format='<tr><td>%h</td><td>%s</td>...</tr>'

to format each commit into a single row in HTML table, and things
like that.