@matheusbsbs / matheus-bagliano / commits / 45d93eb824
Fork 0

shortlog: change "author" variables to "ident"

We already match "committer", and we're about to start matching more things. Let's use a more neutral variable to avoid confusion. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Sep 25, 2020 at 03:01 UTC 45d93eb82403a35d248d17dd0ea7dc3d690b1323
1 file changed +18 -18
builtin/shortlog.c
+18 -18
@@ -49,12 +49,12 @@ static int compare_by_list(const void *a1, const void *a2)
49 }
50
51 static void insert_one_record(struct shortlog *log,
52 - const char *author,
52 + const char *ident,
53 const char *oneline)
54 {
55 struct string_list_item *item;
56
57 - item = string_list_insert(&log->list, author);
57 + item = string_list_insert(&log->list, ident);
58
59 if (log->summary)
60 item->util = (void *)(UTIL_TO_INT(item) + 1);
@@ -97,8 +97,8 @@ static void insert_one_record(struct shortlog *log,
97 }
98 }
99
100 -static int parse_stdin_author(struct shortlog *log,
101 - struct strbuf *out, const char *in)
100 +static int parse_stdin_ident(struct shortlog *log,
101 + struct strbuf *out, const char *in)
102 {
103 const char *mailbuf, *namebuf;
104 size_t namelen, maillen;
@@ -122,18 +122,18 @@ static int parse_stdin_author(struct shortlog *log,
122
123 static void read_from_stdin(struct shortlog *log)
124 {
125 - struct strbuf author = STRBUF_INIT;
126 - struct strbuf mapped_author = STRBUF_INIT;
125 + struct strbuf ident = STRBUF_INIT;
126 + struct strbuf mapped_ident = STRBUF_INIT;
127 struct strbuf oneline = STRBUF_INIT;
128 static const char *author_match[2] = { "Author: ", "author " };
129 static const char *committer_match[2] = { "Commit: ", "committer " };
130 const char **match;
131
132 match = log->committer ? committer_match : author_match;
133 - while (strbuf_getline_lf(&author, stdin) != EOF) {
133 + while (strbuf_getline_lf(&ident, stdin) != EOF) {
134 const char *v;
135 - if (!skip_prefix(author.buf, match[0], &v) &&
136 - !skip_prefix(author.buf, match[1], &v))
135 + if (!skip_prefix(ident.buf, match[0], &v) &&
136 + !skip_prefix(ident.buf, match[1], &v))
137 continue;
138 while (strbuf_getline_lf(&oneline, stdin) != EOF &&
139 oneline.len)
@@ -142,20 +142,20 @@ static void read_from_stdin(struct shortlog *log)
142 !oneline.len)
143 ; /* discard blanks */
144
145 - strbuf_reset(&mapped_author);
146 - if (parse_stdin_author(log, &mapped_author, v) < 0)
145 + strbuf_reset(&mapped_ident);
146 + if (parse_stdin_ident(log, &mapped_ident, v) < 0)
147 continue;
148
149 - insert_one_record(log, mapped_author.buf, oneline.buf);
149 + insert_one_record(log, mapped_ident.buf, oneline.buf);
150 }
151 - strbuf_release(&author);
152 - strbuf_release(&mapped_author);
151 + strbuf_release(&ident);
152 + strbuf_release(&mapped_ident);
153 strbuf_release(&oneline);
154 }
155
156 void shortlog_add_commit(struct shortlog *log, struct commit *commit)
157 {
158 - struct strbuf author = STRBUF_INIT;
158 + struct strbuf ident = STRBUF_INIT;
159 struct strbuf oneline = STRBUF_INIT;
160 struct pretty_print_context ctx = {0};
161 const char *fmt;
@@ -170,7 +170,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
170 (log->email ? "%cN <%cE>" : "%cN") :
171 (log->email ? "%aN <%aE>" : "%aN");
172
173 - format_commit_message(commit, fmt, &author, &ctx);
173 + format_commit_message(commit, fmt, &ident, &ctx);
174 if (!log->summary) {
175 if (log->user_format)
176 pretty_print_commit(&ctx, commit, &oneline);
@@ -178,9 +178,9 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
178 format_commit_message(commit, "%s", &oneline, &ctx);
179 }
180
181 - insert_one_record(log, author.buf, oneline.len ? oneline.buf : "<none>");
181 + insert_one_record(log, ident.buf, oneline.len ? oneline.buf : "<none>");
182
183 - strbuf_release(&author);
183 + strbuf_release(&ident);
184 strbuf_release(&oneline);
185 }
186