Replace calls to strbuf_init(&foo, 0) with STRBUF_INIT initializer
Many call sites use strbuf_init(&foo, 0) to initialize local strbuf variable "foo" which has not been accessed since its declaration. These can be replaced with a static initialization using the STRBUF_INIT macro which is just as readable, saves a function call, and takes up fewer lines. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
committed by
Shawn O. Pearce
parent
7e7abea96b
commit
f285a2d7ed
@ -628,10 +628,9 @@ static void gen_message_id(struct rev_info *info, char *base)
|
||||
const char *committer = git_committer_info(IDENT_WARN_ON_NO_NAME);
|
||||
const char *email_start = strrchr(committer, '<');
|
||||
const char *email_end = strrchr(committer, '>');
|
||||
struct strbuf buf;
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
if (!email_start || !email_end || email_start > email_end - 1)
|
||||
die("Could not extract email from committer identity.");
|
||||
strbuf_init(&buf, 0);
|
||||
strbuf_addf(&buf, "%s.%lu.git.%.*s", base,
|
||||
(unsigned long) time(NULL),
|
||||
(int)(email_end - email_start - 1), email_start + 1);
|
||||
@ -650,7 +649,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
|
||||
const char *msg;
|
||||
const char *extra_headers = rev->extra_headers;
|
||||
struct shortlog log;
|
||||
struct strbuf sb;
|
||||
struct strbuf sb = STRBUF_INIT;
|
||||
int i;
|
||||
const char *encoding = "utf-8";
|
||||
struct diff_options opts;
|
||||
@ -671,7 +670,6 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
|
||||
committer = git_committer_info(0);
|
||||
|
||||
msg = body;
|
||||
strbuf_init(&sb, 0);
|
||||
pp_user_info(NULL, CMIT_FMT_EMAIL, &sb, committer, DATE_RFC2822,
|
||||
encoding);
|
||||
pp_title_line(CMIT_FMT_EMAIL, &msg, &sb, subject_start, extra_headers,
|
||||
@ -753,7 +751,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
||||
const char *in_reply_to = NULL;
|
||||
struct patch_ids ids;
|
||||
char *add_signoff = NULL;
|
||||
struct strbuf buf;
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
|
||||
git_config(git_format_config, NULL);
|
||||
init_revisions(&rev, prefix);
|
||||
@ -861,8 +859,6 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
||||
}
|
||||
argc = j;
|
||||
|
||||
strbuf_init(&buf, 0);
|
||||
|
||||
for (i = 0; i < extra_hdr_nr; i++) {
|
||||
strbuf_addstr(&buf, extra_hdr[i]);
|
||||
strbuf_addch(&buf, '\n');
|
||||
@ -1139,8 +1135,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
|
||||
sign = '-';
|
||||
|
||||
if (verbose) {
|
||||
struct strbuf buf;
|
||||
strbuf_init(&buf, 0);
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
pretty_print_commit(CMIT_FMT_ONELINE, commit,
|
||||
&buf, 0, NULL, NULL, 0, 0);
|
||||
printf("%c %s %s\n", sign,
|
||||
|
||||
Reference in New Issue
Block a user