git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [BUG] You can't have single quote in your username
@ 2019-08-22 12:32 Giuseppe Crinò
  2019-08-22 15:06 ` Pratyush Yadav
                   ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: Giuseppe Crinò @ 2019-08-22 12:32 UTC (permalink / raw)
  To: git

Note how `git log` discards the ending quote character:
```
root@NBR1710R:~# git init repo
Initialized empty Git repository in /root/repo/.git/
root@NBR1710R:~# cd repo/
root@NBR1710R:~/repo# git config user.name Les Actualite\'
root@NBR1710R:~/repo# cat .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[user]
        name = Les
root@NBR1710R:~/repo# git config user.name "Les Actualite\'"
root@NBR1710R:~/repo# cat .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[user]
        name = Les Actualite\\'
root@NBR1710R:~/repo# touch foo
root@NBR1710R:~/repo# git add foo
root@NBR1710R:~/repo# git commit -m 'first'
[master (root-commit) a78e11f] first
 Committer: Les Actualite <root@NBR1710R>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:

    git config --global --edit

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 foo
root@NBR1710R:~/repo# git log
commit a78e11ff0707bd4f1bea195735a7fc8b7ee2b9f8 (HEAD -> master)
Author: Les Actualite <root@NBR1710R>
Date:   Thu Aug 22 14:25:11 2019 +0200

    first
```

I can't test with the development tree right now,
```
root@NBR1710R:~/repo# git --version
git version 2.17.1
```

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

* Re: [BUG] You can't have single quote in your username
  2019-08-22 12:32 [BUG] You can't have single quote in your username Giuseppe Crinò
@ 2019-08-22 15:06 ` Pratyush Yadav
  2019-08-22 16:24   ` Junio C Hamano
  2019-08-22 16:06 ` René Scharfe
  2019-08-22 16:58 ` Bryan Turner
  2 siblings, 1 reply; 26+ messages in thread
From: Pratyush Yadav @ 2019-08-22 15:06 UTC (permalink / raw)
  To: Giuseppe Crinò; +Cc: git

On 22/08/19 02:32PM, Giuseppe Crinò wrote:
> Note how `git log` discards the ending quote character:
> ```
> root@NBR1710R:~# git init repo
> Initialized empty Git repository in /root/repo/.git/
> root@NBR1710R:~# cd repo/
> root@NBR1710R:~/repo# git config user.name Les Actualite\'
> root@NBR1710R:~/repo# cat .git/config
> [core]
>         repositoryformatversion = 0
>         filemode = true
>         bare = false
>         logallrefupdates = true
> [user]
>         name = Les
> root@NBR1710R:~/repo# git config user.name "Les Actualite\'"
> root@NBR1710R:~/repo# cat .git/config
> [core]
>         repositoryformatversion = 0
>         filemode = true
>         bare = false
>         logallrefupdates = true
> [user]
>         name = Les Actualite\\'
> root@NBR1710R:~/repo# touch foo
> root@NBR1710R:~/repo# git add foo
> root@NBR1710R:~/repo# git commit -m 'first'
> [master (root-commit) a78e11f] first
>  Committer: Les Actualite <root@NBR1710R>
> Your name and email address were configured automatically based
> on your username and hostname. Please check that they are accurate.
> You can suppress this message by setting them explicitly. Run the
> following command and follow the instructions in your editor to edit
> your configuration file:
> 
>     git config --global --edit
> 
> After doing this, you may fix the identity used for this commit with:
> 
>     git commit --amend --reset-author
> 
>  1 file changed, 0 insertions(+), 0 deletions(-)
>  create mode 100644 foo
> root@NBR1710R:~/repo# git log
> commit a78e11ff0707bd4f1bea195735a7fc8b7ee2b9f8 (HEAD -> master)
> Author: Les Actualite <root@NBR1710R>
> Date:   Thu Aug 22 14:25:11 2019 +0200
> 
>     first
> ```
> 
> I can't test with the development tree right now,
> ```
> root@NBR1710R:~/repo# git --version
> git version 2.17.1
> ```

Hi,

I took a quick look into this problem. The issue is not with git log, 
but instead with git commit. When you commit, 
builtin/commit.c::author_info() calls ident.c::fmt_ident(), which in 
turn calls ident.c::strbuf_addstr_without_crud(), which in turn calls 
ident.c::crud().

This strbuf_addstr_without_crud() function removes various characters 
from the start and end of the author info, one of which is the single 
quotation. I'm not sure why this is done, the more experienced folk 
where will have the answer.

Anyway, the fix is simple enough. Remove the lines that mark single 
quotes as crud in the crud() function. This will fix the issue for the 
future commits. If you need to fix it for past commits, you need to 
re-write your history with the fix applied.

Below is the quick-and-dirty patch that fixes this. If there is no 
reason for this patch to be dropped, I'll send a proper one once some 
other people have commented.

-- >8 --
diff --git a/ident.c b/ident.c
index e666ee4e59..63cc5e32d3 100644
--- a/ident.c
+++ b/ident.c
@@ -204,9 +204,7 @@ static int crud(unsigned char c)
 		c == ';' ||
 		c == '<' ||
 		c == '>' ||
-		c == '"' ||
-		c == '\\' ||
-		c == '\'';
+		c == '"';
 }
 
 static int has_non_crud(const char *str)

-- 
Regards,
Pratyush Yadav

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

* Re: [BUG] You can't have single quote in your username
  2019-08-22 12:32 [BUG] You can't have single quote in your username Giuseppe Crinò
  2019-08-22 15:06 ` Pratyush Yadav
@ 2019-08-22 16:06 ` René Scharfe
  2019-08-22 16:58 ` Bryan Turner
  2 siblings, 0 replies; 26+ messages in thread
From: René Scharfe @ 2019-08-22 16:06 UTC (permalink / raw)
  To: Giuseppe Crinò; +Cc: git

Am 22.08.19 um 14:32 schrieb Giuseppe Crinò:
>         name = Les Actualite\\'

You can name yourself anything you like, of course, and I don't actually
speak French, but wouldn't it rather be "L'actualité"?

I just reply as a fellow accent-bearer, feel free to ignore me..

René

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

* Re: [BUG] You can't have single quote in your username
  2019-08-22 15:06 ` Pratyush Yadav
@ 2019-08-22 16:24   ` Junio C Hamano
  2019-08-23  7:20     ` Giuseppe Crinò
  0 siblings, 1 reply; 26+ messages in thread
From: Junio C Hamano @ 2019-08-22 16:24 UTC (permalink / raw)
  To: Pratyush Yadav; +Cc: Giuseppe Crinò, git

Pratyush Yadav <me@yadavpratyush.com> writes:

> This strbuf_addstr_without_crud() function removes various characters 
> from the start and end of the author info, one of which is the single 
> quotation. I'm not sure why this is done, the more experienced folk 
> where will have the answer.

The logic there exists in order to remove cruft around the name on a
typical e-mail header (remember, most of the very core-ish part of
the Git was written and got solidified back when the Linux kernel
was the primary client of the system, and many commits were created
via "am"), e.g. sender's mail client may send something like this:

    From: 'Foo bar Baz' <my@name.xz>

and we do not want to take surrounding sq pair as part of the name.

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

* Re: [BUG] You can't have single quote in your username
  2019-08-22 12:32 [BUG] You can't have single quote in your username Giuseppe Crinò
  2019-08-22 15:06 ` Pratyush Yadav
  2019-08-22 16:06 ` René Scharfe
@ 2019-08-22 16:58 ` Bryan Turner
  2019-08-22 17:08   ` Emily Shaffer
  2 siblings, 1 reply; 26+ messages in thread
From: Bryan Turner @ 2019-08-22 16:58 UTC (permalink / raw)
  To: Giuseppe Crinò; +Cc: Git Users

On Thu, Aug 22, 2019 at 5:32 AM Giuseppe Crinò <giuscri@gmail.com> wrote:
>
> Note how `git log` discards the ending quote character:

<snip>

> root@NBR1710R:~/repo# git add foo
> root@NBR1710R:~/repo# git commit -m 'first'
> [master (root-commit) a78e11f] first
>  Committer: Les Actualite <root@NBR1710R>

If you look closely here, in the "git commit" output, you can see
that, as Pratyush indicated, it was actually "git commit" that dropped
the trailing apostrophe, and "git log" is simply presenting the
information as it exists in the repository.

If your goal is an accented "e", wouldn't it be better to set your
name using é, rather than a trailing apostrophe? "git commit" would
likely preserve that without issue.

Best regards,
Bryan Turner

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

* Re: [BUG] You can't have single quote in your username
  2019-08-22 16:58 ` Bryan Turner
@ 2019-08-22 17:08   ` Emily Shaffer
  2019-08-22 18:43     ` Pratyush Yadav
  2019-08-23  8:26     ` SZEDER Gábor
  0 siblings, 2 replies; 26+ messages in thread
From: Emily Shaffer @ 2019-08-22 17:08 UTC (permalink / raw)
  To: Bryan Turner; +Cc: Giuseppe Crinò, Git Users

On Thu, Aug 22, 2019 at 09:58:48AM -0700, Bryan Turner wrote:
> On Thu, Aug 22, 2019 at 5:32 AM Giuseppe Crinò <giuscri@gmail.com> wrote:
> >
> > Note how `git log` discards the ending quote character:
> 
> <snip>
> 
> > root@NBR1710R:~/repo# git add foo
> > root@NBR1710R:~/repo# git commit -m 'first'
> > [master (root-commit) a78e11f] first
> >  Committer: Les Actualite <root@NBR1710R>
> 
> If you look closely here, in the "git commit" output, you can see
> that, as Pratyush indicated, it was actually "git commit" that dropped
> the trailing apostrophe, and "git log" is simply presenting the
> information as it exists in the repository.
> 
> If your goal is an accented "e", wouldn't it be better to set your
> name using é, rather than a trailing apostrophe? "git commit" would
> likely preserve that without issue.

Hmm, I don't think it's a good idea to get into the business of telling
contributors how to write their names. There tends to be an axiom that
"all assumptions developers make about human names are false."

Does it make more sense to replace this strbuf_addstr_without_crud()
setup with something more intelligent (i.e. checking for matching crud
on either end, like ^[$crudchars].*\1$? We already check for matched <>.

- Emily

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

* Re: [BUG] You can't have single quote in your username
  2019-08-22 17:08   ` Emily Shaffer
@ 2019-08-22 18:43     ` Pratyush Yadav
  2019-08-23  8:29       ` SZEDER Gábor
  2019-08-23  8:26     ` SZEDER Gábor
  1 sibling, 1 reply; 26+ messages in thread
From: Pratyush Yadav @ 2019-08-22 18:43 UTC (permalink / raw)
  To: Emily Shaffer; +Cc: Bryan Turner, Giuseppe Crinò, Git Users

On 22/08/19 10:08AM, Emily Shaffer wrote:
> On Thu, Aug 22, 2019 at 09:58:48AM -0700, Bryan Turner wrote:
> > On Thu, Aug 22, 2019 at 5:32 AM Giuseppe Crinò <giuscri@gmail.com> wrote:
> > >
> > > Note how `git log` discards the ending quote character:
> > 
> > <snip>
> > 
> > > root@NBR1710R:~/repo# git add foo
> > > root@NBR1710R:~/repo# git commit -m 'first'
> > > [master (root-commit) a78e11f] first
> > >  Committer: Les Actualite <root@NBR1710R>
> > 
> > If you look closely here, in the "git commit" output, you can see
> > that, as Pratyush indicated, it was actually "git commit" that dropped
> > the trailing apostrophe, and "git log" is simply presenting the
> > information as it exists in the repository.
> > 
> > If your goal is an accented "e", wouldn't it be better to set your
> > name using é, rather than a trailing apostrophe? "git commit" would
> > likely preserve that without issue.
> 
> Hmm, I don't think it's a good idea to get into the business of telling
> contributors how to write their names. There tends to be an axiom that
> "all assumptions developers make about human names are false."
> 
> Does it make more sense to replace this strbuf_addstr_without_crud()
> setup with something more intelligent (i.e. checking for matching crud
> on either end, like ^[$crudchars].*\1$? We already check for matched <>.

Sounds like something easy enough to implement. There are two types of 
characters that crud() removes: there are the ones which _should_ appear 
on both the start and end (', ", <, >), and the ones which don't 
necessarily have to (., ,, :, ;, \).

So we'd need to handle two cases. For the former type, remove a 
character both at the start and at the end. For the latter, remove only 
where they appear.

If this sounds like something reasonable to do, I'll send a patch fixing 
this.

-- 
Regards,
Pratyush Yadav

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

* Re: [BUG] You can't have single quote in your username
  2019-08-22 16:24   ` Junio C Hamano
@ 2019-08-23  7:20     ` Giuseppe Crinò
  2019-08-23  7:29       ` Michal Suchánek
  0 siblings, 1 reply; 26+ messages in thread
From: Giuseppe Crinò @ 2019-08-23  7:20 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Pratyush Yadav, git

On Thu, Aug 22, 2019 at 6:24 PM Junio C Hamano <gitster@pobox.com> wrote:
> The logic there exists in order to remove cruft around the name on a
> typical e-mail header (remember, most of the very core-ish part of
> the Git was written and got solidified back when the Linux kernel
> was the primary client of the system, and many commits were created
> via "am"), e.g. sender's mail client may send something like this:
>
>     From: 'Foo bar Baz' <my@name.xz>
>
> and we do not want to take surrounding sq pair as part of the name.

I see but _standard_ rules to escape characters should apply as I
understand this. 'Foo bar Baz\'s' should be allowed as it should "Foo
bar Baz's". They should resolve to the same name too

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

* Re: [BUG] You can't have single quote in your username
  2019-08-23  7:20     ` Giuseppe Crinò
@ 2019-08-23  7:29       ` Michal Suchánek
  0 siblings, 0 replies; 26+ messages in thread
From: Michal Suchánek @ 2019-08-23  7:29 UTC (permalink / raw)
  To: Giuseppe Crinò; +Cc: Junio C Hamano, Pratyush Yadav, git

On Fri, 23 Aug 2019 09:20:47 +0200
Giuseppe Crinò <giuscri@gmail.com> wrote:

> On Thu, Aug 22, 2019 at 6:24 PM Junio C Hamano <gitster@pobox.com> wrote:
> > The logic there exists in order to remove cruft around the name on a
> > typical e-mail header (remember, most of the very core-ish part of
> > the Git was written and got solidified back when the Linux kernel
> > was the primary client of the system, and many commits were created
> > via "am"), e.g. sender's mail client may send something like this:
> >
> >     From: 'Foo bar Baz' <my@name.xz>
> >
> > and we do not want to take surrounding sq pair as part of the name.  
> 
> I see but _standard_ rules to escape characters should apply as I
> understand this. 'Foo bar Baz\'s' should be allowed as it should "Foo
> bar Baz's". They should resolve to the same name too

It would not be removed in this case regardless of the qouting. It is
neither at the start nor at the end.

Thanks

Michal

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

* Re: [BUG] You can't have single quote in your username
  2019-08-22 17:08   ` Emily Shaffer
  2019-08-22 18:43     ` Pratyush Yadav
@ 2019-08-23  8:26     ` SZEDER Gábor
  1 sibling, 0 replies; 26+ messages in thread
From: SZEDER Gábor @ 2019-08-23  8:26 UTC (permalink / raw)
  To: Emily Shaffer; +Cc: Bryan Turner, Giuseppe Crinò, Git Users

On Thu, Aug 22, 2019 at 10:08:17AM -0700, Emily Shaffer wrote:
> On Thu, Aug 22, 2019 at 09:58:48AM -0700, Bryan Turner wrote:
> > If your goal is an accented "e", wouldn't it be better to set your
> > name using é, rather than a trailing apostrophe? "git commit" would
> > likely preserve that without issue.
> 
> Hmm, I don't think it's a good idea to get into the business of telling
> contributors how to write their names.

Well, maybe the contributor didn't know that Git can cope with
accented characters in user names.


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

* Re: [BUG] You can't have single quote in your username
  2019-08-22 18:43     ` Pratyush Yadav
@ 2019-08-23  8:29       ` SZEDER Gábor
  2019-08-23  9:35         ` Giuseppe Crinò
                           ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: SZEDER Gábor @ 2019-08-23  8:29 UTC (permalink / raw)
  To: Pratyush Yadav
  Cc: Emily Shaffer, Bryan Turner, Giuseppe Crinò, Git Users

On Fri, Aug 23, 2019 at 12:13:12AM +0530, Pratyush Yadav wrote:
> > Does it make more sense to replace this strbuf_addstr_without_crud()
> > setup with something more intelligent (i.e. checking for matching crud
> > on either end, like ^[$crudchars].*\1$? We already check for matched <>.
> 
> Sounds like something easy enough to implement. There are two types of 
> characters that crud() removes: there are the ones which _should_ appear 
> on both the start and end (', ", <, >), and the ones which don't 
> necessarily have to (., ,, :, ;, \).
> 
> So we'd need to handle two cases. For the former type, remove a 
> character both at the start and at the end. For the latter, remove only 
> where they appear.

If we go down this route, then someone might want to write ő as o" or
ű as u", which still supposed to be used in pairs, but what if someone
wants to write ä as a:, ö as o:, ü as u:, ç as "c,", ş as "s,", etc.

What I wonder is whether we really have to remove crud from the user
name if it comes from the configuration.


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

* Re: [BUG] You can't have single quote in your username
  2019-08-23  8:29       ` SZEDER Gábor
@ 2019-08-23  9:35         ` Giuseppe Crinò
  2019-08-23 10:15           ` SZEDER Gábor
  2019-08-24 17:49         ` Giuseppe Crinò
  2019-08-26 19:14         ` Jeff King
  2 siblings, 1 reply; 26+ messages in thread
From: Giuseppe Crinò @ 2019-08-23  9:35 UTC (permalink / raw)
  To: SZEDER Gábor; +Cc: Pratyush Yadav, Emily Shaffer, Bryan Turner, Git Users

On Fri, Aug 23, 2019 at 10:29 AM SZEDER Gábor <szeder.dev@gmail.com> wrote:
> If we go down this route, then someone might want to write ő as o" or
> ű as u", which still supposed to be used in pairs, but what if someone
> wants to write ä as a:, ö as o:, ü as u:, ç as "c,", ş as "s,", etc.

I don't know any language that uses ő or ű so I can't tell but it's
definitely possible. In my country, sometimes the last name ends with
an accented letter (mine ends with an "o grave") and people end up use
a single quote to avoid pissing off computers. That's standard thing.

In my current team I don't know enough of the setup of my colleagues
(they may use CP1252) and that ò may be badly decoded.

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

* Re: [BUG] You can't have single quote in your username
  2019-08-23  9:35         ` Giuseppe Crinò
@ 2019-08-23 10:15           ` SZEDER Gábor
  0 siblings, 0 replies; 26+ messages in thread
From: SZEDER Gábor @ 2019-08-23 10:15 UTC (permalink / raw)
  To: Giuseppe Crinò
  Cc: Pratyush Yadav, Emily Shaffer, Bryan Turner, Git Users

On Fri, Aug 23, 2019 at 11:35:48AM +0200, Giuseppe Crinò wrote:
> On Fri, Aug 23, 2019 at 10:29 AM SZEDER Gábor <szeder.dev@gmail.com> wrote:
> > If we go down this route, then someone might want to write ő as o" or
> > ű as u", which still supposed to be used in pairs, but what if someone
> > wants to write ä as a:, ö as o:, ü as u:, ç as "c,", ş as "s,", etc.
> 
> I don't know any language that uses ő or ű so I can't tell but it's
> definitely possible.

The Hungarian alphabet has both, and I've seen them written like this
on old typewritten documents.  But that was decades ago, nowadays
they are either written properly as ő and ű, or without any accent at
all (banks...).

> In my country, sometimes the last name ends with
> an accented letter (mine ends with an "o grave") and people end up use
> a single quote to avoid pissing off computers. That's standard thing.
> 
> In my current team I don't know enough of the setup of my colleagues
> (they may use CP1252) and that ò may be badly decoded.

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

* Re: [BUG] You can't have single quote in your username
  2019-08-23  8:29       ` SZEDER Gábor
  2019-08-23  9:35         ` Giuseppe Crinò
@ 2019-08-24 17:49         ` Giuseppe Crinò
  2019-08-25  8:09           ` Giuseppe Crinò
  2019-08-26 19:14         ` Jeff King
  2 siblings, 1 reply; 26+ messages in thread
From: Giuseppe Crinò @ 2019-08-24 17:49 UTC (permalink / raw)
  To: SZEDER Gábor
  Cc: Pratyush Yadav, Emily Shaffer, Bryan Turner, Giuseppe Crinò,
	Git Users

On Fri, Aug 23, 2019 at 10:29:00AM +0200, SZEDER Gábor wrote:
> What I wonder is whether we really have to remove crud from the user
> name if it comes from the configuration.

Yes. If the primary use of removing crud is to remove quotes from a
quoted name (as in `From: 'Foo baz Bar'`) why not directly removing
pairs of quotes around the name and leave crud _inside_ the name?

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

* Re: [BUG] You can't have single quote in your username
  2019-08-24 17:49         ` Giuseppe Crinò
@ 2019-08-25  8:09           ` Giuseppe Crinò
  0 siblings, 0 replies; 26+ messages in thread
From: Giuseppe Crinò @ 2019-08-25  8:09 UTC (permalink / raw)
  To: Giuseppe Crinò
  Cc: SZEDER Gábor, Pratyush Yadav, Emily Shaffer, Bryan Turner,
	Git Users

On Sat, Aug 24, 2019 at 05:49:52PM +0000, Giuseppe Crinò wrote:
> On Fri, Aug 23, 2019 at 10:29:00AM +0200, SZEDER Gábor wrote:
> > What I wonder is whether we really have to remove crud from the user
> > name if it comes from the configuration.
> 
> Yes. If the primary use of removing crud is to remove quotes from a
> quoted name (as in `From: 'Foo baz Bar'`) why not directly removing
> pairs of quotes around the name and leave crud _inside_ the name?

I keep forgetting crud is removed *around* the name.

By the way, it's probably more conservative to remove crud (without
removing quotes) and finally remove surrounding quote pairs.

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

* Re: [BUG] You can't have single quote in your username
  2019-08-23  8:29       ` SZEDER Gábor
  2019-08-23  9:35         ` Giuseppe Crinò
  2019-08-24 17:49         ` Giuseppe Crinò
@ 2019-08-26 19:14         ` Jeff King
  2019-08-27 13:51           ` Giuseppe Crino'
                             ` (2 more replies)
  2 siblings, 3 replies; 26+ messages in thread
From: Jeff King @ 2019-08-26 19:14 UTC (permalink / raw)
  To: SZEDER Gábor
  Cc: Pratyush Yadav, Emily Shaffer, Bryan Turner, Giuseppe Crinò,
	Git Users

On Fri, Aug 23, 2019 at 10:29:00AM +0200, SZEDER Gábor wrote:

> On Fri, Aug 23, 2019 at 12:13:12AM +0530, Pratyush Yadav wrote:
> > > Does it make more sense to replace this strbuf_addstr_without_crud()
> > > setup with something more intelligent (i.e. checking for matching crud
> > > on either end, like ^[$crudchars].*\1$? We already check for matched <>.
> > 
> > Sounds like something easy enough to implement. There are two types of 
> > characters that crud() removes: there are the ones which _should_ appear 
> > on both the start and end (', ", <, >), and the ones which don't 
> > necessarily have to (., ,, :, ;, \).
> > 
> > So we'd need to handle two cases. For the former type, remove a 
> > character both at the start and at the end. For the latter, remove only 
> > where they appear.
> 
> If we go down this route, then someone might want to write ő as o" or
> ű as u", which still supposed to be used in pairs, but what if someone
> wants to write ä as a:, ö as o:, ü as u:, ç as "c,", ş as "s,", etc.
> 
> What I wonder is whether we really have to remove crud from the user
> name if it comes from the configuration.

Probably not. I think most of this crud-handling is really about pulling
names out of email. Digging around in the archive, one of the few
entries that actually talks about this crud-removal being helpful is:

  https://public-inbox.org/git/alpine.LFD.2.00.0812010836280.3256@nehalem.linux-foundation.org/

So it might make sense to push these rules into "git mailinfo" instead
of applying them everywhere. But we'd still need something at least for
GECOS, where "Your Name,,,," is common.

Unfortunately since these rules have been in place for ages, we don't
really know how often they're helping. Loosening it just for user.name,
etc is probably the most conservative choice.

We'd still want to keep the low-level removal of "<>\n", since those are
syntactically significant to Git (i.e., if they sneak in you end up with
a broken commit object). There's some discussion in this thread (which
is also about trailing single-quotes!):

  https://public-inbox.org/git/20120629124122.GG1258@camk.edu.pl/

Another real-world case that would be helped is: "Your Name, Jr.":

  https://public-inbox.org/git/CAMP44s2OoxUVFE57e8C2Km7rcGn88KkLXxdaA3s5RE6nZ7TU=A@mail.gmail.com/

-Peff

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

* Re: [BUG] You can't have single quote in your username
  2019-08-26 19:14         ` Jeff King
@ 2019-08-27 13:51           ` Giuseppe Crino'
  2019-08-27 14:33             ` Michal Suchánek
  2019-08-28 14:33           ` Giuseppe Crino'
  2019-08-31 13:17           ` Giuseppe Crinò
  2 siblings, 1 reply; 26+ messages in thread
From: Giuseppe Crino' @ 2019-08-27 13:51 UTC (permalink / raw)
  To: Jeff King
  Cc: SZEDER Gábor, Pratyush Yadav, Emily Shaffer, Bryan Turner,
	Giuseppe Crinò, Git Users

On Mon, Aug 26, 2019 at 03:14:55PM -0400, Jeff King wrote:
> So it might make sense to push these rules into "git mailinfo" instead
> of applying them everywhere. But we'd still need something at least for
> GECOS, where "Your Name,,,," is common.

What's the GECOS you mean?

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

* Re: [BUG] You can't have single quote in your username
  2019-08-27 13:51           ` Giuseppe Crino'
@ 2019-08-27 14:33             ` Michal Suchánek
  0 siblings, 0 replies; 26+ messages in thread
From: Michal Suchánek @ 2019-08-27 14:33 UTC (permalink / raw)
  To: Giuseppe Crino'
  Cc: Jeff King, SZEDER Gábor, Pratyush Yadav, Emily Shaffer,
	Bryan Turner, Git Users

On Tue, 27 Aug 2019 13:51:49 +0000
"Giuseppe Crino'" <giuscri@gmail.com> wrote:

> On Mon, Aug 26, 2019 at 03:14:55PM -0400, Jeff King wrote:
> > So it might make sense to push these rules into "git mailinfo" instead
> > of applying them everywhere. But we'd still need something at least for
> > GECOS, where "Your Name,,,," is common.  
> 
> What's the GECOS you mean?

https://en.wikipedia.org/wiki/Gecos_field

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

* Re: [BUG] You can't have single quote in your username
  2019-08-26 19:14         ` Jeff King
  2019-08-27 13:51           ` Giuseppe Crino'
@ 2019-08-28 14:33           ` Giuseppe Crino'
  2019-08-28 14:56             ` Jeff King
  2019-08-31 13:17           ` Giuseppe Crinò
  2 siblings, 1 reply; 26+ messages in thread
From: Giuseppe Crino' @ 2019-08-28 14:33 UTC (permalink / raw)
  To: Jeff King
  Cc: SZEDER Gábor, Pratyush Yadav, Emily Shaffer, Bryan Turner,
	Giuseppe Crinò, Git Users

On Mon, Aug 26, 2019 at 03:14:55PM -0400, Jeff King wrote:
> But we'd still need something at least for
> GECOS, where "Your Name,,,," is common.

As I understand this, those commas are *not* removed by
strbuf_addstr_without_crud(). Instead they're skipped from /etc/pass
-- see `ident.c/copy_gecos()`.

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

* Re: [BUG] You can't have single quote in your username
  2019-08-28 14:33           ` Giuseppe Crino'
@ 2019-08-28 14:56             ` Jeff King
  0 siblings, 0 replies; 26+ messages in thread
From: Jeff King @ 2019-08-28 14:56 UTC (permalink / raw)
  To: Giuseppe Crino'
  Cc: SZEDER Gábor, Pratyush Yadav, Emily Shaffer, Bryan Turner,
	Git Users

On Wed, Aug 28, 2019 at 02:33:15PM +0000, Giuseppe Crino' wrote:

> On Mon, Aug 26, 2019 at 03:14:55PM -0400, Jeff King wrote:
> > But we'd still need something at least for
> > GECOS, where "Your Name,,,," is common.
> 
> As I understand this, those commas are *not* removed by
> strbuf_addstr_without_crud(). Instead they're skipped from /etc/pass
> -- see `ident.c/copy_gecos()`.

Yeah, you're right. This is a good example of how we are completely
unclear on how often the crud-removal is helping. :)

But I think that does put us one step closer to possibly dropping the
crud-removal, if gecos is already handled (and hopefully "mailinfo" is
already cleaning up the names it parsers).

-Peff

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

* Re: [BUG] You can't have single quote in your username
  2019-08-26 19:14         ` Jeff King
  2019-08-27 13:51           ` Giuseppe Crino'
  2019-08-28 14:33           ` Giuseppe Crino'
@ 2019-08-31 13:17           ` Giuseppe Crinò
  2019-09-02 15:47             ` Jeff King
  2 siblings, 1 reply; 26+ messages in thread
From: Giuseppe Crinò @ 2019-08-31 13:17 UTC (permalink / raw)
  To: Jeff King
  Cc: SZEDER Gábor, Pratyush Yadav, Emily Shaffer, Bryan Turner,
	Git Users

On Mon, Aug 26, 2019 at 03:14:55PM -0400, Jeff King wrote:
> We'd still want to keep the low-level removal of "<>\n", since those are
> syntactically significant to Git (i.e., if they sneak in you end up with
> a broken commit object).

Would it work to change `strbuf_addstr_without_crud()` such that instead of
removing crud from the beginning and *then* crud from the end, it removes crud
as long as it's palindromic? Then the function proceeds to remove "<>\n" from
the string as before.

That would implement the following _mappings_:

'Foo bar' => Foo bar
Micheal Jr. => Micheal Jr.
Mr. McDonalds => Mr. McDonalds
"John Baz" => John Baz
"JJ\x0a" => JJ

What do you think?

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

* Re: [BUG] You can't have single quote in your username
  2019-08-31 13:17           ` Giuseppe Crinò
@ 2019-09-02 15:47             ` Jeff King
  2019-09-02 19:25               ` Junio C Hamano
  0 siblings, 1 reply; 26+ messages in thread
From: Jeff King @ 2019-09-02 15:47 UTC (permalink / raw)
  To: Giuseppe Crinò
  Cc: SZEDER Gábor, Pratyush Yadav, Emily Shaffer, Bryan Turner,
	Git Users

On Sat, Aug 31, 2019 at 01:17:48PM +0000, Giuseppe Crinò wrote:

> On Mon, Aug 26, 2019 at 03:14:55PM -0400, Jeff King wrote:
> > We'd still want to keep the low-level removal of "<>\n", since those are
> > syntactically significant to Git (i.e., if they sneak in you end up with
> > a broken commit object).
> 
> Would it work to change `strbuf_addstr_without_crud()` such that instead of
> removing crud from the beginning and *then* crud from the end, it removes crud
> as long as it's palindromic? Then the function proceeds to remove "<>\n" from
> the string as before.
> 
> That would implement the following _mappings_:
> 
> 'Foo bar' => Foo bar
> Micheal Jr. => Micheal Jr.
> Mr. McDonalds => Mr. McDonalds
> "John Baz" => John Baz
> "JJ\x0a" => JJ
> 
> What do you think?

I think we don't have enough data to really know how much it will help
or hurt. :)

On the plus side, it is less risky than dropping the end-point crud removal
entirely.

But it still risks losing a case where some code path relies on the crud
cleanup for odd cases (mismatched delimiters, or interleaved delimiters,
or non-delimiter crud mixed in with delimiters).

On the one hand, I am actually OK with dropping the crud removal
entirely and seeing what happens, and this is a lesser form of that. On
the other hand, it puts us in a funny in-between situation where tools
can _usually_ get away without cleaning up the names, but occasionally
get bit. It might be easier to just say that we don't do cleanup.

So I dunno. There is no patch to be discussed, and I am not volunteering
to write one.  So I think whoever chooses to do so has a lot of control
over what is proposed. :)

-Peff

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

* Re: [BUG] You can't have single quote in your username
  2019-09-02 15:47             ` Jeff King
@ 2019-09-02 19:25               ` Junio C Hamano
  2019-09-02 19:50                 ` Michal Suchánek
  0 siblings, 1 reply; 26+ messages in thread
From: Junio C Hamano @ 2019-09-02 19:25 UTC (permalink / raw)
  To: Jeff King
  Cc: Giuseppe Crinò, SZEDER Gábor, Pratyush Yadav,
	Emily Shaffer, Bryan Turner, Git Users

Jeff King <peff@peff.net> writes:

> But it still risks losing a case where some code path relies on the crud
> cleanup for odd cases (mismatched delimiters, or interleaved delimiters,
> or non-delimiter crud mixed in with delimiters).
> ...
> So I dunno. There is no patch to be discussed, and I am not volunteering
> to write one.  So I think whoever chooses to do so has a lot of control
> over what is proposed. :)

Rather, they can propose what they want, but they have a lot of
tough defending to do on their choice.  Lack of potential harm is
much harder to prove than coming up with a single example that
harms.

I'd rather leave the sleeping dog lie, if we need to encourage
people to live in 21st century and step outside US-ASCII to do so,
then do that instead.

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

* Re: [BUG] You can't have single quote in your username
  2019-09-02 19:25               ` Junio C Hamano
@ 2019-09-02 19:50                 ` Michal Suchánek
  2019-09-03  7:51                   ` Giuseppe Crinò
  0 siblings, 1 reply; 26+ messages in thread
From: Michal Suchánek @ 2019-09-02 19:50 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Jeff King, Giuseppe Crinò, SZEDER Gábor, Pratyush Yadav,
	Emily Shaffer, Bryan Turner, Git Users

On Mon, 02 Sep 2019 12:25:37 -0700
Junio C Hamano <gitster@pobox.com> wrote:

> Jeff King <peff@peff.net> writes:
> 
> > But it still risks losing a case where some code path relies on the crud
> > cleanup for odd cases (mismatched delimiters, or interleaved delimiters,
> > or non-delimiter crud mixed in with delimiters).
> > ...
> > So I dunno. There is no patch to be discussed, and I am not volunteering
> > to write one.  So I think whoever chooses to do so has a lot of control
> > over what is proposed. :)  
> 
> Rather, they can propose what they want, but they have a lot of
> tough defending to do on their choice.  Lack of potential harm is
> much harder to prove than coming up with a single example that
> harms.
> 
> I'd rather leave the sleeping dog lie, if we need to encourage
> people to live in 21st century and step outside US-ASCII to do so,
> then do that instead.

As much as I would love to agree Windows is dragging us down here. I
don't think there is any other major (or even just not completely
obscure) platform that does not support UTF-8 in the terminal.

Thanks

Michal

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

* Re: [BUG] You can't have single quote in your username
  2019-09-02 19:50                 ` Michal Suchánek
@ 2019-09-03  7:51                   ` Giuseppe Crinò
  2019-09-03  9:03                     ` Michal Suchánek
  0 siblings, 1 reply; 26+ messages in thread
From: Giuseppe Crinò @ 2019-09-03  7:51 UTC (permalink / raw)
  To: Michal Suchánek, Junio C Hamano
  Cc: Jeff King, SZEDER Gábor, Pratyush Yadav, Emily Shaffer,
	Bryan Turner, Git Users

On Mon, Sep 02, 2019 at 12:25:37PM -0700, Junio C Hamano wrote:
> I'd rather leave the sleeping dog lie, if we need to encourage
> people to live in 21st century and step outside US-ASCII to do so,
> then do that instead.

+1 to let the sleeping dog lie. When you say we should encourage people
to step outside US-ASCII what do you mean by that?

On Mon, Sep 02, 2019 at 09:50:48PM +0200, Michal Suchánek wrote:
> As much as I would love to agree Windows is dragging us down here. I
> don't think there is any other major (or even just not completely
> obscure) platform that does not support UTF-8 in the terminal.

Well, I don't know how much Windows is related to that. On my Linux
machine my user.name ends with a single quote: I have a US keyboard but
my name ends with an "o grave" and I can't type it.



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

* Re: [BUG] You can't have single quote in your username
  2019-09-03  7:51                   ` Giuseppe Crinò
@ 2019-09-03  9:03                     ` Michal Suchánek
  0 siblings, 0 replies; 26+ messages in thread
From: Michal Suchánek @ 2019-09-03  9:03 UTC (permalink / raw)
  To: Giuseppe Crinò
  Cc: Junio C Hamano, Jeff King, SZEDER Gábor, Pratyush Yadav,
	Emily Shaffer, Bryan Turner, Git Users

On Tue, 3 Sep 2019 07:51:54 +0000
Giuseppe Crinò <giuscri@gmail.com> wrote:

> On Mon, Sep 02, 2019 at 12:25:37PM -0700, Junio C Hamano wrote:
> > I'd rather leave the sleeping dog lie, if we need to encourage
> > people to live in 21st century and step outside US-ASCII to do so,
> > then do that instead.  
> 
> +1 to let the sleeping dog lie. When you say we should encourage people
> to step outside US-ASCII what do you mean by that?
> 
> On Mon, Sep 02, 2019 at 09:50:48PM +0200, Michal Suchánek wrote:
> > As much as I would love to agree Windows is dragging us down here. I
> > don't think there is any other major (or even just not completely
> > obscure) platform that does not support UTF-8 in the terminal.  
> 
> Well, I don't know how much Windows is related to that. On my Linux
> machine my user.name ends with a single quote: I have a US keyboard but
> my name ends with an "o grave" and I can't type it.

Have you ever heard about XCompose?

Thanks

Michal

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

end of thread, other threads:[~2019-09-03  9:03 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-22 12:32 [BUG] You can't have single quote in your username Giuseppe Crinò
2019-08-22 15:06 ` Pratyush Yadav
2019-08-22 16:24   ` Junio C Hamano
2019-08-23  7:20     ` Giuseppe Crinò
2019-08-23  7:29       ` Michal Suchánek
2019-08-22 16:06 ` René Scharfe
2019-08-22 16:58 ` Bryan Turner
2019-08-22 17:08   ` Emily Shaffer
2019-08-22 18:43     ` Pratyush Yadav
2019-08-23  8:29       ` SZEDER Gábor
2019-08-23  9:35         ` Giuseppe Crinò
2019-08-23 10:15           ` SZEDER Gábor
2019-08-24 17:49         ` Giuseppe Crinò
2019-08-25  8:09           ` Giuseppe Crinò
2019-08-26 19:14         ` Jeff King
2019-08-27 13:51           ` Giuseppe Crino'
2019-08-27 14:33             ` Michal Suchánek
2019-08-28 14:33           ` Giuseppe Crino'
2019-08-28 14:56             ` Jeff King
2019-08-31 13:17           ` Giuseppe Crinò
2019-09-02 15:47             ` Jeff King
2019-09-02 19:25               ` Junio C Hamano
2019-09-02 19:50                 ` Michal Suchánek
2019-09-03  7:51                   ` Giuseppe Crinò
2019-09-03  9:03                     ` Michal Suchánek
2019-08-23  8:26     ` SZEDER Gábor

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).