Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'builtin-blame.c')
-rw-r--r--builtin-blame.c53
1 files changed, 46 insertions, 7 deletions
diff --git a/builtin-blame.c b/builtin-blame.c
index 65d029a773..35471fc261 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -16,9 +16,11 @@
#include "quote.h"
#include "xdiff-interface.h"
#include "cache-tree.h"
+#include "path-list.h"
+#include "mailmap.h"
static char blame_usage[] =
-"git-blame [-c] [-l] [-t] [-f] [-n] [-p] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [--contents <filename>] [--incremental] [commit] [--] file\n"
+"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"
" -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"
@@ -26,6 +28,7 @@ static char blame_usage[] =
" -t Show raw timestamp (Default: off)\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"
" -p, --porcelain Show in a format designed for machine consumption\n"
" -L n,m Process only line range n,m, counting from 1\n"
" -M, -C Find line movements within and across files\n"
@@ -42,6 +45,7 @@ static int show_root;
static int blank_boundary;
static int incremental;
static int cmd_is_annotate;
+static struct path_list mailmap;
#ifndef DEBUG
#define DEBUG 0
@@ -1294,8 +1298,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)
@@ -1321,17 +1325,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,
@@ -1513,6 +1542,7 @@ static const char *format_time(unsigned long time, const char *tz_str,
#define OUTPUT_SHOW_NAME 020
#define OUTPUT_SHOW_NUMBER 040
#define OUTPUT_SHOW_SCORE 0100
+#define OUTPUT_NO_AUTHOR 0200
static void emit_porcelain(struct scoreboard *sb, struct blame_entry *ent)
{
@@ -1607,10 +1637,15 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)
if (opt & OUTPUT_SHOW_NUMBER)
printf(" %*d", max_orig_digits,
ent->s_lno + 1 + cnt);
- printf(" (%-*.*s %10s %*d) ",
- longest_author, longest_author, ci.author,
- format_time(ci.author_time, ci.author_tz,
- show_raw_time),
+
+ if (!(opt & OUTPUT_NO_AUTHOR))
+ printf(" (%-*.*s %10s",
+ longest_author, longest_author,
+ ci.author,
+ format_time(ci.author_time,
+ ci.author_tz,
+ show_raw_time));
+ printf(" %*d) ",
max_digits, ent->lno + 1 + cnt);
}
do {
@@ -2122,6 +2157,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
output_option |= OUTPUT_RAW_TIMESTAMP;
else if (!strcmp("-l", arg))
output_option |= OUTPUT_LONG_OBJECT_NAME;
+ else if (!strcmp("-s", arg))
+ output_option |= OUTPUT_NO_AUTHOR;
else if (!strcmp("-S", arg) && ++i < argc)
revs_file = argv[i];
else if (!prefixcmp(arg, "-M")) {
@@ -2372,6 +2409,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
die("reading graft file %s failed: %s",
revs_file, strerror(errno));
+ read_mailmap(&mailmap, ".mailmap", NULL);
+
assign_blame(&sb, &revs, opt);
if (incremental)