summaryrefslogtreecommitdiff
path: root/builtin-log.c
diff options
context:
space:
mode:
authorBrandon Casey <casey@nrlssc.navy.mil>2008-10-09 14:12:12 -0500
committerShawn O. Pearce <spearce@spearce.org>2008-10-12 12:36:19 -0700
commitf285a2d7ed6548666989406de8f0e7233eb84368 (patch)
tree2e422bd9ceeeb432ca03b61f91165790f0e37146 /builtin-log.c
parent7e7abea96b8140c592a46293f5e33aae0683c7ac (diff)
downloadgit-f285a2d7ed6548666989406de8f0e7233eb84368.tar.gz
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>
Diffstat (limited to 'builtin-log.c')
-rw-r--r--builtin-log.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/builtin-log.c b/builtin-log.c
index fc5e4da822..794821f6bc 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -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,