Merge branch 'ap/log-mailmap'
authorJunio C Hamano <gitster@pobox.com>
Mon, 21 Jan 2013 01:06:52 +0000 (17:06 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 21 Jan 2013 01:06:53 +0000 (17:06 -0800)
Teach commands in the "log" family to optionally pay attention to
the mailmap.

* ap/log-mailmap:
  log --use-mailmap: optimize for cases without --author/--committer search
  log: add log.mailmap configuration option
  log: grep author/committer using mailmap
  test: add test for --use-mailmap option
  log: add --use-mailmap option
  pretty: use mailmap to display username and email
  mailmap: add mailmap structure to rev_info and pp
  mailmap: simplify map_user() interface
  mailmap: remove email copy and length limitation
  Use split_ident_line to parse author and committer
  string-list: allow case-insensitive string list

13 files changed:
1  2 
Documentation/config.txt
Documentation/git-log.txt
builtin/blame.c
builtin/log.c
builtin/shortlog.c
commit.h
log-tree.c
mailmap.c
pretty.c
revision.h
string-list.c
string-list.h
t/t4203-mailmap.sh

Simple merge
Simple merge
diff --cc builtin/blame.c
Simple merge
diff --cc builtin/log.c
Simple merge
Simple merge
diff --cc commit.h
index 0f469e507db7b8517e4f37107d855b7877176085,7f8f9878d8e10a425da3241f75655cc1213debe1..c16c8a75349f2ef4dba1f3c05528d04750a925da
+++ b/commit.h
@@@ -89,7 -89,7 +89,8 @@@ struct pretty_print_context 
        char *notes_message;
        struct reflog_walk_info *reflog_info;
        const char *output_encoding;
+       struct string_list *mailmap;
 +      int color;
  };
  
  struct userformat_want {
diff --cc log-tree.c
index f8487f8a8a7694ce09f1b079c701bceabf688b20,92254fd493e38a7d806e147b85853360b5ccff96..5dc45c4812bdfd0d7a6b71d529eaa37df8178186
@@@ -681,7 -671,7 +681,8 @@@ void show_log(struct rev_info *opt
        ctx.preserve_subject = opt->preserve_subject;
        ctx.reflog_info = opt->reflog_info;
        ctx.fmt = opt->commit_format;
+       ctx.mailmap = opt->mailmap;
 +      ctx.color = opt->diffopt.use_color;
        pretty_print_commit(&ctx, commit, &msgbuf);
  
        if (opt->add_signoff)
diff --cc mailmap.c
index b16542febec14ed86fd7ef21ba19899d08c95a64,743dbdae2f358665029d025faa7304f5d79dbbf6..2a7b36628cb5623eb0ffb95bfb54e52a6dd300f4
+++ b/mailmap.c
@@@ -187,62 -171,13 +187,63 @@@ static int read_mailmap_file(struct str
        return 0;
  }
  
 +static void read_mailmap_buf(struct string_list *map,
 +                           const char *buf, unsigned long len,
 +                           char **repo_abbrev)
 +{
 +      while (len) {
 +              const char *end = strchrnul(buf, '\n');
 +              unsigned long linelen = end - buf + 1;
 +              char *line = xmemdupz(buf, linelen);
 +
 +              read_mailmap_line(map, line, repo_abbrev);
 +
 +              free(line);
 +              buf += linelen;
 +              len -= linelen;
 +      }
 +}
 +
 +static int read_mailmap_blob(struct string_list *map,
 +                           const char *name,
 +                           char **repo_abbrev)
 +{
 +      unsigned char sha1[20];
 +      char *buf;
 +      unsigned long size;
 +      enum object_type type;
 +
 +      if (!name)
 +              return 0;
 +      if (get_sha1(name, sha1) < 0)
 +              return 0;
 +
 +      buf = read_sha1_file(sha1, &type, &size);
 +      if (!buf)
 +              return error("unable to read mailmap object at %s", name);
 +      if (type != OBJ_BLOB)
 +              return error("mailmap is not a blob: %s", name);
 +
 +      read_mailmap_buf(map, buf, size, repo_abbrev);
 +
 +      free(buf);
 +      return 0;
 +}
 +
  int read_mailmap(struct string_list *map, char **repo_abbrev)
  {
 +      int err = 0;
 +
        map->strdup_strings = 1;
 -      /* each failure returns 1, so >1 means both calls failed */
 -      return read_single_mailmap(map, ".mailmap", repo_abbrev) +
 -             read_single_mailmap(map, git_mailmap_file, repo_abbrev) > 1;
+       map->cmp = strcasecmp;
 +
 +      if (!git_mailmap_blob && is_bare_repository())
 +              git_mailmap_blob = "HEAD:.mailmap";
 +
 +      err |= read_mailmap_file(map, ".mailmap", repo_abbrev);
 +      err |= read_mailmap_blob(map, git_mailmap_blob, repo_abbrev);
 +      err |= read_mailmap_file(map, git_mailmap_file, repo_abbrev);
 +      return err;
  }
  
  void clear_mailmap(struct string_list *map)
diff --cc pretty.c
Simple merge
diff --cc revision.h
Simple merge
diff --cc string-list.c
Simple merge
diff --cc string-list.h
Simple merge
Simple merge