git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Jeff King" <peff@peff.net>,
	"Jonathan Nieder" <jrnieder@gmail.com>,
	git@vger.kernel.org, "SZEDER Gábor" <szeder@ira.uka.de>
Subject: Re: [bug] blame duplicates trailing ">" in mailmapped emails
Date: Mon, 6 Feb 2012 14:14:56 +0200	[thread overview]
Message-ID: <CAMP44s1RN+_UK9rAk_m9Z=YaJJtwHLyiCu2stMMDEWqZN9260g@mail.gmail.com> (raw)
In-Reply-To: <7vy5sgaby1.fsf@alter.siamese.dyndns.org>

On Mon, Feb 6, 2012 at 5:16 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Jeff King <peff@peff.net> writes:
>
>> Ugh, yeah. I was thinking about how it would improve this call site, but
>> I don't want to get into auditing the others. Let's drop it and go with
>> your patch.
>
> In any case, here is what I queued for tonight.
>
> -- >8 --
> Subject: [PATCH] mailmap: do not leave '>' in the output when answering "we did something"

This subject doesn't explain the *purpose* of the patch: always return
a plain mail address from map_user()

That would be enough for most readers.

I think the immediate problem should be here:

Currently 'git blame -e' would add an extra '>' if map_user() returns
true, which would end up as '<foo@bar.com>>'. This is because
map_user() sometimes modifies, the mail string, but sometimes not. So
let's always modify it.

At this point a lot of readers can skip the rest of the explanation.

> The callers of map_user() give email and name to it, and expect to get an
> up-to-date versions of email and/or name to be used in their output. The
> function rewrites the given buffers in place. To optimize the majority of
> cases, the function returns 0 when it did not do anything, and it returns
> 1 when the caller should use the updated contents.
>
> The 'email' input to the function is terminated by '>' or a NUL (whichever
> comes first) for historical reasons, but when a rewrite happens, the value
> is replaced with the mailbox inside the <> pair.  However, it failed to
> meet this expectation when it only rewrote the name part without rewriting
> the email part, and the email in the input was terminated by '>'.

With the above explanation I suggested, I think this can be summarized as:

As of right now most of the callers of map_user() give a plan address,
and expect a plain address, however, 'git blame -e' passes along a
mail address that ends with >, and uses the return value to determine
if a transformation was made, and adds the missing '>'. This is
because when map_user() does the transformation, it returns a plan
address.

This might have worked in previous versions of map_user(), but now not
only does it transforms mail addresses, but also the name (phrase). So
now callers can't use the return value to know if they need to add an
extra '>', or not. So lets always remove the '>', so they can.

> This causes an extra '>' to appear in the output of "blame -e", because the
> caller does send in '>'-terminated email, and when the function returned 1
> to tell it that rewriting happened, it appends '>' that is necessary when
> the email part was rewritten.

It took too long to reach the problem. As a reader, that's the first
thing I would expect.

> The patch looks bigger than it actually is, because this change makes a
> variable that points at the end of the email part in the input 'p' live
> much longer than it used to, deserving a more descriptive name.

This is a *separate* logically independent patch. And you yourself
mention, makes the review of the patch more difficult, as of right now
it's difficult to spot the functional change, because it's mixed with
non-functional changes.

I find it peculiar how patches in the Linux kernel are truly logically
independent, but Git has a tendency to squash many things: cleanups,
fixes, documentation, tests, extra tests, remove unused code, etc.

Cheers.

-- 
Felipe Contreras

  parent reply	other threads:[~2012-02-06 12:15 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-02  1:15 [PATCH v3 0/4] completion: couple of cleanups Felipe Contreras
     [not found] ` <1328145320-14071-2-git-send-email-felipe.contreras@gmail.com>
2012-02-02  8:16   ` [PATCH v3 1/4] completion: be nicer with zsh Jonathan Nieder
2012-02-02  8:34     ` Felipe Contreras
2012-02-02  9:10       ` Jonathan Nieder
2012-02-02  9:38         ` Felipe Contreras
2012-02-02  9:46           ` Jonathan Nieder
2012-02-02 10:18             ` Felipe Contreras
2012-02-02  8:48 ` Jonathan Nieder
2012-02-02 10:12   ` Felipe Contreras
2012-02-02 10:35     ` Thomas Rast
2012-02-02 10:50       ` Jonathan Nieder
2012-02-02 10:55         ` Jonathan Nieder
2012-02-02 11:00       ` Felipe Contreras
2012-02-02 19:27   ` Junio C Hamano
2012-02-02 20:45     ` Felipe Contreras
2012-02-03  0:17       ` Junio C Hamano
2012-02-03 10:38         ` Felipe Contreras
2012-02-03 20:28           ` Junio C Hamano
2012-02-04 15:46             ` Felipe Contreras
2012-02-04 18:26               ` [bug] blame duplicates trailing ">" in mailmapped emails Jeff King
2012-02-04 19:30                 ` Felipe Contreras
2012-02-04 23:20                   ` Jeff King
2012-02-05 21:11                     ` Felipe Contreras
2012-02-05 23:50                       ` Jeff King
2012-02-05 20:16                 ` Junio C Hamano
2012-02-05 21:38                   ` Junio C Hamano
2012-02-05 23:47                     ` Jeff King
2012-02-06  0:39                       ` Junio C Hamano
2012-02-06  3:03                         ` Jeff King
2012-02-06  3:13                           ` Junio C Hamano
2012-02-06  3:16                           ` Junio C Hamano
2012-02-06  4:01                             ` Jeff King
2012-02-06 12:14                             ` Felipe Contreras [this message]
2012-02-06 22:04                               ` Junio C Hamano
2012-02-06 23:11                                 ` Felipe Contreras
2012-02-05 20:49               ` [PATCH v3 1/4] completion: be nicer with zsh Junio C Hamano
2012-02-02  9:05 ` [PATCH v3 2/4] completion: simplify __git_remotes Jonathan Nieder
2012-02-02 19:48 ` [PATCH v3 0/4] completion: couple of cleanups Junio C Hamano

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='CAMP44s1RN+_UK9rAk_m9Z=YaJJtwHLyiCu2stMMDEWqZN9260g@mail.gmail.com' \
    --to=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    --cc=peff@peff.net \
    --cc=szeder@ira.uka.de \
    /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).