@@ -52,26 +52,8 @@ static void insert_one_record(struct shortlog *log,
52
52
const char * oneline )
53
53
{
54
54
struct string_list_item * item ;
55
- const char * mailbuf , * namebuf ;
56
- size_t namelen , maillen ;
57
- struct strbuf namemailbuf = STRBUF_INIT ;
58
- struct ident_split ident ;
59
55
60
- if (split_ident_line (& ident , author , strlen (author )))
61
- return ;
62
-
63
- namebuf = ident .name_begin ;
64
- mailbuf = ident .mail_begin ;
65
- namelen = ident .name_end - ident .name_begin ;
66
- maillen = ident .mail_end - ident .mail_begin ;
67
-
68
- map_user (& log -> mailmap , & mailbuf , & maillen , & namebuf , & namelen );
69
- strbuf_add (& namemailbuf , namebuf , namelen );
70
-
71
- if (log -> email )
72
- strbuf_addf (& namemailbuf , " <%.*s>" , (int )maillen , mailbuf );
73
-
74
- item = string_list_insert (& log -> list , namemailbuf .buf );
56
+ item = string_list_insert (& log -> list , author );
75
57
76
58
if (log -> summary )
77
59
item -> util = (void * )(UTIL_TO_INT (item ) + 1 );
@@ -114,9 +96,33 @@ static void insert_one_record(struct shortlog *log,
114
96
}
115
97
}
116
98
99
+ static int parse_stdin_author (struct shortlog * log ,
100
+ struct strbuf * out , const char * in )
101
+ {
102
+ const char * mailbuf , * namebuf ;
103
+ size_t namelen , maillen ;
104
+ struct ident_split ident ;
105
+
106
+ if (split_ident_line (& ident , in , strlen (in )))
107
+ return -1 ;
108
+
109
+ namebuf = ident .name_begin ;
110
+ mailbuf = ident .mail_begin ;
111
+ namelen = ident .name_end - ident .name_begin ;
112
+ maillen = ident .mail_end - ident .mail_begin ;
113
+
114
+ map_user (& log -> mailmap , & mailbuf , & maillen , & namebuf , & namelen );
115
+ strbuf_add (out , namebuf , namelen );
116
+ if (log -> email )
117
+ strbuf_addf (out , " <%.*s>" , (int )maillen , mailbuf );
118
+
119
+ return 0 ;
120
+ }
121
+
117
122
static void read_from_stdin (struct shortlog * log )
118
123
{
119
124
struct strbuf author = STRBUF_INIT ;
125
+ struct strbuf mapped_author = STRBUF_INIT ;
120
126
struct strbuf oneline = STRBUF_INIT ;
121
127
static const char * author_match [2 ] = { "Author: " , "author " };
122
128
static const char * committer_match [2 ] = { "Commit: " , "committer " };
@@ -134,9 +140,15 @@ static void read_from_stdin(struct shortlog *log)
134
140
while (strbuf_getline_lf (& oneline , stdin ) != EOF &&
135
141
!oneline .len )
136
142
; /* discard blanks */
137
- insert_one_record (log , v , oneline .buf );
143
+
144
+ strbuf_reset (& mapped_author );
145
+ if (parse_stdin_author (log , & mapped_author , v ) < 0 )
146
+ continue ;
147
+
148
+ insert_one_record (log , mapped_author .buf , oneline .buf );
138
149
}
139
150
strbuf_release (& author );
151
+ strbuf_release (& mapped_author );
140
152
strbuf_release (& oneline );
141
153
}
142
154
@@ -153,7 +165,9 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
153
165
ctx .date_mode .type = DATE_NORMAL ;
154
166
ctx .output_encoding = get_log_output_encoding ();
155
167
156
- fmt = log -> committer ? "%cn <%ce>" : "%an <%ae>" ;
168
+ fmt = log -> committer ?
169
+ (log -> email ? "%cN <%cE>" : "%cN" ) :
170
+ (log -> email ? "%aN <%aE>" : "%aN" );
157
171
158
172
format_commit_message (commit , fmt , & author , & ctx );
159
173
if (!log -> summary ) {
0 commit comments