From: Junio C Hamano <junkio@cox.net>
To: git@vger.kernel.org
Subject: [PATCH 2/2] Apply mailmap in git-blame output.
Date: Fri, 27 Apr 2007 00:54:17 -0700 [thread overview]
Message-ID: <117766045855-git-send-email-junkio@cox.net> (raw)
In-Reply-To: <11776604573799-git-send-email-junkio@cox.net>
This makes git-blame to use the same mailmap used by
git-shortlog.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
builtin-blame.c | 42 +++++++++++++++++++++++++++++++++++++++---
1 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/builtin-blame.c b/builtin-blame.c
index c2919b3..3d7590f 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -17,14 +17,17 @@
#include "xdiff-interface.h"
#include "cache-tree.h"
#include "log-tree.h"
+#include "path-list.h"
+#include "mailmap.h"
static char blame_usage[] =
-"git-blame [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-p] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [--contents <filename>] [--incremental] [commit] [--] file\n"
+"git-blame [-c] [-b] [-l] [--root] [-x] [-t] [-f] [-n] [-s] [-p] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [--contents <filename>] [--incremental] [commit] [--] file\n"
" -c Use the same output mode as git-annotate (Default: off)\n"
" -b Show blank SHA-1 for boundary commits (Default: off)\n"
" -l Show long commit SHA1 (Default: off)\n"
" --root Do not treat root commits as boundaries (Default: off)\n"
" -t Show raw timestamp (Default: off)\n"
+" -x Do not use .mailmap file\n"
" -f, --show-name Show original filename (Default: auto)\n"
" -n, --show-number Show original linenumber (Default: off)\n"
" -s Suppress author name and timestamp (Default: off)\n"
@@ -45,7 +48,9 @@ static int show_root;
static int blank_boundary;
static int incremental;
static int cmd_is_annotate;
+static int no_mailmap;
static int log;
+static struct path_list mailmap;
#ifndef DEBUG
#define DEBUG 0
@@ -1386,8 +1391,8 @@ static void get_ac_line(const char *inbuf, const char *what,
int bufsz, char *person, const char **mail,
unsigned long *time, const char **tz)
{
- int len;
- char *tmp, *endp;
+ int len, tzlen, maillen;
+ char *tmp, *endp, *timepos;
tmp = strstr(inbuf, what);
if (!tmp)
@@ -1413,17 +1418,42 @@ static void get_ac_line(const char *inbuf, const char *what,
while (*tmp != ' ')
tmp--;
*tz = tmp+1;
+ tzlen = (person+len)-(tmp+1);
*tmp = 0;
while (*tmp != ' ')
tmp--;
*time = strtoul(tmp, NULL, 10);
+ timepos = tmp;
*tmp = 0;
while (*tmp != ' ')
tmp--;
*mail = tmp + 1;
*tmp = 0;
+ maillen = timepos - tmp;
+
+ if (!mailmap.nr)
+ return;
+
+ /*
+ * mailmap expansion may make the name longer.
+ * make room by pushing stuff down.
+ */
+ tmp = person + bufsz - (tzlen + 1);
+ memmove(tmp, *tz, tzlen);
+ tmp[tzlen] = 0;
+ *tz = tmp;
+
+ tmp = tmp - (maillen + 1);
+ memmove(tmp, *mail, maillen);
+ tmp[maillen] = 0;
+ *mail = tmp;
+
+ /*
+ * Now, convert e-mail using mailmap
+ */
+ map_email(&mailmap, tmp + 1, person, tmp-person-1);
}
static void get_commit_info(struct commit *commit,
@@ -2269,6 +2299,9 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
else if (!strcmp("-p", arg) ||
!strcmp("--porcelain", arg))
output_option |= OUTPUT_PORCELAIN;
+ else if (!strcmp("-x", arg) ||
+ !strcmp("--no-mailmap", arg))
+ no_mailmap = 1;
else if (!strcmp("--", arg)) {
seen_dashdash = 1;
i++;
@@ -2473,6 +2506,9 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
die("reading graft file %s failed: %s",
revs_file, strerror(errno));
+ if (!no_mailmap && !access(".mailmap", R_OK))
+ read_mailmap(&mailmap, ".mailmap", NULL);
+
assign_blame(&sb, &revs, opt);
if (incremental || log)
--
1.5.2.rc0.746.gcf51
prev parent reply other threads:[~2007-04-27 7:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-27 7:54 [PATCH 0/2] Fixing up names in blame output Junio C Hamano
2007-04-27 7:54 ` [PATCH 1/2] Split out mailmap handling out of shortlog Junio C Hamano
2007-04-27 7:54 ` Junio C Hamano [this message]
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=117766045855-git-send-email-junkio@cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.