git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pratyush Yadav <me@yadavpratyush.com>
To: "Giuseppe Crinò" <giuscri@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [BUG] You can't have single quote in your username
Date: Thu, 22 Aug 2019 20:36:14 +0530	[thread overview]
Message-ID: <20190822150614.o25g37pwfcaos2zn@localhost.localdomain> (raw)
In-Reply-To: <CAGV3M55WAQOAOiZPPgR+6p2EVzakrbz1gYAMh-BqxCVDeLCq9w@mail.gmail.com>

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

  reply	other threads:[~2019-08-22 15:06 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-22 12:32 [BUG] You can't have single quote in your username Giuseppe Crinò
2019-08-22 15:06 ` Pratyush Yadav [this message]
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

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

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

  git send-email \
    --in-reply-to=20190822150614.o25g37pwfcaos2zn@localhost.localdomain \
    --to=me@yadavpratyush.com \
    --cc=git@vger.kernel.org \
    --cc=giuscri@gmail.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.
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 NNTP newsgroup(s).