git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Marius Storm-Olsen <marius@trolltech.com>
Cc: git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH v3 3/4] Add map_user() and clear_mailmap() to mailmap
Date: Tue, 03 Feb 2009 22:50:04 -0800	[thread overview]
Message-ID: <7v3aeu66hv.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <53facc1773745ae477f15103718e08ea6a5ae58d.1233584536.git.marius@trolltech.com> (Marius Storm-Olsen's message of "Mon, 2 Feb 2009 15:32:09 +0100")

Marius Storm-Olsen <marius@trolltech.com> writes:

> map_user() allows to lookup and replace both email and
> name of a user, based on a new style mailmap file.
> The possible mailmap definitions now are:
>   proper_name <commit_email>                             // Old style
>   proper_name <proper_email> <commit_email>              // New style
>   proper_name <proper_email> commit_name <commit_email>  // New style
>
> map_email() operates the same as before, with the
> exception that it also will to try to match on a name
> passed in through the name return buffer.
>
> clear_mailmap() is needed to now clear the more complex
> mailmap structure.

Use of ample paragraph breaks would make it much easier to eyes.

    map_user() allows to lookup and replace both email and name of a user,
    based on a new style mailmap file.

    The possible mailmap definitions now are:

      proper_name <commit_email>                             # Old style
      proper_name <proper_email> <commit_email>              # New style
      proper_name <proper_email> commit_name <commit_email>  # New style

    map_email() operates the same as before, with the exception that it also
    will to try to match on a name passed in through the name return buffer.

    clear_mailmap() is needed to now clear the more complex mailmap structure.

Also, the example shows how lines would look line in a mailmap file.  I
would avoid giving a false impression that the parser should take C++
style comment introducer // by using '#' which is a documented one (I
suspect anything that follows the last angle bracket is simply ignored,
though).

> @@ -86,6 +95,27 @@ Jane Doe <jane@desktop.(none)>
>  Joe R. Developer <joe@random.com>

This context line was updated a few days ago (not a big deal, just in case
you didn't know).

> diff --git a/mailmap.c b/mailmap.c
> index 5aaee91..f593ff0 100644
> --- a/mailmap.c
> +++ b/mailmap.c
> @@ -2,7 +2,87 @@
>  #include "string-list.h"
>  #include "mailmap.h"
>  
> +#define DEBUG_MAILMAP 0
> +#if DEBUG_MAILMAP
> +#define debug_mm(...) fprintf(stderr, __VA_ARGS__)
> +#else
> +inline void debug_mm(const char *format, ...) {}
> +#endif

"static inline void ...";

> @@ -37,25 +117,65 @@ static int read_single_mailmap(struct string_list *map, const char *filename, ch
>...
> +		/* Locate 2nd name and email. Possible mappings in mailmap file are:
> +		 *   proper_name <commit_email>
> +		 *   proper_name <proper_email> <commit_email>
> +		 *   proper_name <proper_email> commit_name <commit_email>
> +		 */

	/*
         * We tend to write a multi line comment block
         * like this.
         */

> +		do {
> +			email2 = name2 = 0;
> +			right_bracket1 += 1;
> +			if ((left_bracket2 = strchr(right_bracket1, '<')) == NULL)
> +				continue;
> +			if ((right_bracket2 = strchr(left_bracket2 + 1, '>')) == NULL)
> +				continue;
> +			if (right_bracket2 == left_bracket2 + 1)
> +				continue;
> +			for (end_of_name = left_bracket2;
> +			     end_of_name != right_bracket1 && isspace(end_of_name[-1]);
> +			     end_of_name--)
> +				; /* keep on looking for name end */
> +			for (;
> +			     end_of_name != right_bracket1 && isspace(right_bracket1[0]);
> +			     right_bracket1++)
> +				; /* keep on looking for name start */
> +			if (end_of_name != right_bracket1) {
> +				name2 = xmalloc(end_of_name - right_bracket1 + 1);
> +				strlcpy(name2, right_bracket1, end_of_name - right_bracket1 + 1);
> +				char *tmp = name1;
> +				name1 = name2;
> +				name2 = tmp;
> +			}
> +			email2 = xmalloc(right_bracket2 - left_bracket2);
> +			for (i = 0; i < right_bracket2 - left_bracket2 - 1; i++)
> +				email2[i] = tolower(left_bracket2[i + 1]);
> +			email2[right_bracket2 - left_bracket2 - 1] = '\0';
> +			char *tmp = email1;
> +			email1 = email2;
> +			email2 = tmp;
> +		} while(0);

Yuck.  Is it just me or is this new codeblock especially denser than existing
code?  I wonder use of a few smaller helper functions (that the compiler
may be able to inline without being told for us) would make this easier to read
without funny-looking "do { ... if (...) continue; } while (0)" trick?

Two "char *tmp" in this scope are both decl-after-statement errors.

  parent reply	other threads:[~2009-02-04  6:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-02 14:32 [PATCH v3 0/4] Extend mailmap functionality Marius Storm-Olsen
2009-02-02 14:32 ` [PATCH v3 1/4] Add log.mailmap as configurational option for mailmap location Marius Storm-Olsen
2009-02-02 14:32   ` [PATCH v3 2/4] Add find_insert_index, insert_at_index and clear_func functions to string_list Marius Storm-Olsen
2009-02-02 14:32     ` [PATCH v3 3/4] Add map_user() and clear_mailmap() to mailmap Marius Storm-Olsen
2009-02-02 14:32       ` [PATCH v3 4/4] Change current mailmap usage to do matching on both name and email of author/committer Marius Storm-Olsen
2009-02-04  6:50       ` Junio C Hamano [this message]
2009-02-04  8:50         ` [PATCH v3 3/4] Add map_user() and clear_mailmap() to mailmap Marius Storm-Olsen
2009-02-04  9:15           ` Nanako Shiraishi
2009-02-04  9:24             ` Marius Storm-Olsen

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=7v3aeu66hv.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=marius@trolltech.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).