Skip to contentSkip to conversation

pretty-options.txt: describe supported encoding

PATCH In review Christopher Yeleighton via GitGitGadget 5 participants 7 messages Aug 26, 2021 – Aug 27, 2021 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pretty-options.txt: describe supported encoding

From: Christopher Yeleighton <[email protected]>

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.

Signed-off-by <[email protected]>

---
log: describe supported encoding

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1079%2Fyecril71pl%2Fpatch-1-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1079/yecril71pl/patch-1-v1
Pull-Request: https://github.com/git/git/pull/1079

 Documentation/pretty-options.txt | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
Documentation/pretty-options.txt +7 -3
index 27ddaf84a19..4f8376d681b 100644
@@ -36,9 +36,13 @@ people using 80-column terminals.
 	The commit objects record the encoding used for the log message
 	in their encoding header; this option can be used to tell the
 	command to re-code the commit log message in the encoding
-	preferred by the user.  For non plumbing commands this
-	defaults to UTF-8. Note that if an object claims to be encoded
-	in `X` and we are outputting in `X`, we will output the object
+	preferred by the user.
+	The encoding must be a system encoding supported by iconv(1),
+	otherwise this option will be ignored.
+	POSIX character maps used by iconv(1p) are not supported.
+	For non-plumbing commands this defaults to UTF-8.
+	Note that if an object claims to be encoded in `X`
+	and we are outputting in `X`, we shall output the object
 	verbatim; this means that invalid sequences in the original
 	commit may be copied to the output.
 

base-commit: c4203212e360b25a1c69467b5a8437d45a373cac

Signature · 1 line
gitgitgadget
#1 lore raw
Quoted 8 lines · Christopher Yeleighton via GitGitGadget

From: Christopher Yeleighton <[email protected]>

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.

Signed-off-by <[email protected]>

---

The commit message should be:
"git log recognizes only system encodings supported by iconv(1), but not POSIX character maps used by iconv(1p). Document it.".

Quoted 6 lines

The commit objects record the encoding used for the log message in their encoding header; this option can be used to tell the command to re-code the commit log message in the encoding

Documentation/pretty-options.txt +0 -2
-	preferred by the user.  For non plumbing commands this
-	defaults to UTF-8. Note that if an object claims to be encoded

Documentation/pretty-options.txt people using 80-column terminals. · line 47

Quoted 10 lines
Documentation/pretty-options.txt +7 -1
-	in `X` and we are outputting in `X`, we will output the object
+	preferred by the user.
+	The encoding must be a system encoding supported by iconv(1),
+	otherwise this option will be ignored.
+	POSIX character maps used by iconv(1p) are not supported.
+	For non-plumbing commands this defaults to UTF-8.
+	Note that if an object claims to be encoded in `X`
+	and we are outputting in `X`, we shall output the object
  	verbatim; this means that invalid sequences in the original
  	commit may be copied to the output.

I think POSIX character maps and encoding are the same, what are their differences? Reading iconv(1p) [1] doesn't give definition of the former.

[1]: https://man7.org/linux/man-pages/man1/iconv.1p.html

Signature · 1 line
An old man doll... just what I always wanted! - Clara
#2 lore raw

Dnia piątek, 27 sierpnia 2021 12:46:22 CEST Bagas Sanjaya pisze:

Quoted 4 lines

I think POSIX character maps and encoding are the same, what are their differences? Reading iconv(1p) [1] doesn't give definition of the former.

[1]: https://man7.org/linux/man-pages/man1/iconv.1p.html

System encoding providers are code, POSIX character maps are data.

Chris

#3 lore raw

PATCH v2 1/1 pretty-options.txt: describe supported encoding

In reply to Bagas Sanjaya

git log recognises only system encodings supported by iconv(1), but not POSIX character maps used by iconv(1p). Document it.

Signed-off-by <[email protected]>
Documentation/pretty- renamed from Documentation/pretty-options.txt +0 -0

options.txt
index 27ddaf84a19..4f8376d681b 100644

Documentation/pretty-options.txt +7 -3
@@ -36,9 +36,13 @@ people using 80-column terminals.
        The commit objects record the encoding used for the log message
        in their encoding header; this option can be used to tell the
        command to re-code the commit log message in the encoding
-       preferred by the user.  For non plumbing commands this
-       defaults to UTF-8. Note that if an object claims to be encoded
-       in `X` and we are outputting in `X`, we will output the object
+       preferred by the user.
+       The encoding must be a system encoding supported by iconv(1),
+       otherwise this option will be ignored.
+       POSIX character maps used by iconv(1p) are not supported.
+       For non-plumbing commands this defaults to UTF-8.
+       Note that if an object claims to be encoded in `X`
+       and we are outputting in `X`, we shall output the object
        verbatim; this means that invalid sequences in the original
        commit may be copied to the output.
 
#4 lore raw
Quoted 4 lines · Krzysztof Żelechowski

git log recognises only system encodings supported by iconv(1), but not POSIX character maps used by iconv(1p). Document it.

Signed-off-by <[email protected]>

The "Human Readable Name <[email protected]>" on this line must match the one on the "From: " line that records the author of the patch.

If you are forwarding somebody else's patch (with or without improvement), we also need your sign off.

Quoted 8 lines
Documentation/pretty- renamed from Documentation/pretty-options.txt +0 -0

options.txt
index 27ddaf84a19..4f8376d681b 100644

Documentation/pretty-options.txt +0 -0
@@ -36,9 +36,13 @@ people using 80-column terminals.
        The commit objects record the encoding used for the log message
        in their encoding header; this option can be used to tell the

Documentation/pretty-options.txt people using 80-column terminals. · line 44

Quoted 10 lines
Documentation/pretty-options.txt +4 -3
        command to re-code the commit log message in the encoding
-       preferred by the user.  For non plumbing commands this
-       defaults to UTF-8. Note that if an object claims to be encoded
-       in `X` and we are outputting in `X`, we will output the object
+       preferred by the user.
 
 
+       The encoding must be a system encoding supported by iconv(1),
+       otherwise this option will be ignored.
+       POSIX character maps used by iconv(1p) are not supported.

This paragraph is a bit hard to grok.

I think it is saying that the "-f frommap -t tomap" form in [*1*] that can use arbitrary character set description file is not supported, but "-f fromcode -t tocode" form, which also is what iconv_open() takes [*2*], is supported. Am I reading it correctly?

Is there an easier-to-read way to explain the distinction to our average reader?

What I am getting at is this. Imagine average users who need to see their commits recoded to iso-8859-2. They see "git log" has "--encoding=<encoding>" option, read the above paragraph and wonder if they are on the supported side or unsupported side of the above paragraph. I want to make it easy for them to stop wondering.

For that purpose, "iconv(1) vs iconv(1p)" would not help them very much, especially considering that not all Git users are UNIX users (they probably do not even know what (1) and (1p) means).

Documentation/pretty-options.txt people using 80-column terminals. · line 43

Quoted 1 line
Documentation/pretty-options.txt +1 -0
+       For non-plumbing commands this defaults to UTF-8.

I think I can guess why the patch wants to change "non plumbing" to "non-plumbing" (I do not strongly care either way, so I'd take the patch without complaint about that particular change). It would have been nicer to mention this change in the proposed commit log message, though, but that is minor.

Quoted 4 lines
Documentation/pretty-options.txt +2 -0
+       Note that if an object claims to be encoded in `X`
+       and we are outputting in `X`, we shall output the object
        verbatim; this means that invalid sequences in the original

commit may be copied to the output.

I probably wouldn't have noticed this if a new manual page used "shall" consistently, but since the original deliberately used "will" and the patch changes it to "shall", I have to ask: why?

I think our end-user facing manual pages tend to avoid the latter. We do use "shall" in the RFC2119/BCP14 sense on the technical side of our documentation where we give requirements to the third-party implementations so that they can interoperate with us, but this is not such a description.

Thanks.

[References]

*1* https://pubs.opengroup.org/onlinepubs/9699919799/utilities/iconv.html
*2* https://pubs.opengroup.org/onlinepubs/9699919799/functions/iconv_open.html

#5 lore raw
Quoted 20 lines · Junio C Hamano

Documentation/pretty-options.txt people using 80-column terminals. · line 42

Quoted 3 lines
Documentation/pretty-options.txt +3 -0
+       The encoding must be a system encoding supported by iconv(1),
+       otherwise this option will be ignored.
+       POSIX character maps used by iconv(1p) are not supported.

This paragraph is a bit hard to grok.

I think it is saying that the "-f frommap -t tomap" form in [*1*] that can use arbitrary character set description file is not supported, but "-f fromcode -t tocode" form, which also is what iconv_open() takes [*2*], is supported. Am I reading it correctly?

Is there an easier-to-read way to explain the distinction to our average reader?

What I am getting at is this. Imagine average users who need to see their commits recoded to iso-8859-2. They see "git log" has "--encoding=<encoding>" option, read the above paragraph and wonder if they are on the supported side or unsupported side of the above paragraph. I want to make it easy for them to stop wondering.

Quoted 3 lines

For that purpose, "iconv(1) vs iconv(1p)" would not help them very much, especially considering that not all Git users are UNIX users (they probably do not even know what (1) and (1p) means).

I likewise found the mention of character maps confusing. If we were to refer to anything, it would be iconv(3) or iconv_open(3). But really, all of the discussion that led to this patch seemed to be about the distinction between "character set conversion" (or "character encoding", or "codeset conversion", all terms used by the POSIX pages) and the syntactic encoding of HTML.

Is there any version of iconv that would convert "<" to "&lt;"?

I guess that _conceptually_ one could think of that as a multi-byte character conversion, but it seems to me that it is generally considered a layer above (after all, the original "<" and characters in the HTML entity have to be in some character encoding; generally ASCII, but I think you could have UTF-16 HTML, too).

What I'm getting it is that maybe we just need to use a less generic word than "encoding". Perhaps just s/encoding/character &/ or something? And maybe add something like:

Conversions are done using the system iconv(3) function. The set of available encodings will depend on your system.

You _can_ use "iconv -l" to get such a list on many systems, but it is not even necessarily the same list.

I also wonder if other mentions of encoding would want to use the same term (e.g., gitattributes working-tree-encoding), and of course i18n.commitEncoding (though peeking at the latter, it seems to already say "Character encoding", so maybe that is sufficient).

-Peff

#6 lore raw
In reply to Junio C Hamano

Dnia piątek, 27 sierpnia 2021 19:03:56 CEST Junio C Hamano pisze:

Quoted 10 lines

Documentation/pretty-options.txt people using 80-column terminals. · line 42

Quoted 3 lines
Documentation/pretty-options.txt +3 -0
+       The encoding must be a system encoding supported by iconv(1),
+       otherwise this option will be ignored.
+       POSIX character maps used by iconv(1p) are not supported.

This paragraph is a bit hard to grok.

I think it is saying that the "-f frommap -t tomap" form in [*1*] that can use arbitrary character set description file is not supported, but "-f fromcode -t tocode" form, which also is what iconv_open() takes [*2*], is supported. Am I reading it correctly?

Yes

Quoted 3 lines

Is there an easier-to-read way to explain the distinction to our average reader?

It is not our job to explain what POSIX character maps are. The takeaway is they are unsupported; if you do not know what they are, why should you bother?

Quoted 10 lines

What I am getting at is this. Imagine average users who need to see their commits recoded to iso-8859-2. They see "git log" has "--encoding=<encoding>" option, read the above paragraph and wonder if they are on the supported side or unsupported side of the above paragraph. I want to make it easy for them to stop wondering.

For that purpose, "iconv(1) vs iconv(1p)" would not help them very much, especially considering that not all Git users are UNIX users (they probably do not even know what (1) and (1p) means).

I am sorry, as a UNIX user I have no idea what iconv, being part of the GNU C library, means and how it works on a non-UNIX system that does not contain one. If you know, could you enlighten us please?

Quoted 7 lines

I think our end-user facing manual pages tend to avoid the latter. We do use "shall" in the RFC2119/BCP14 sense on the technical side of our documentation where we give requirements to the third-party implementations so that they can interoperate with us, but this is not such a description.

Thanks.

I shall revert it after we have come to an agreement about the POSIX stuff.

BR,
Chris