summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7e7abea)
raw | patch | inline | side by side (parent: 7e7abea)
author | Brandon Casey <casey@nrlssc.navy.mil> | |
Thu, 9 Oct 2008 19:12:12 +0000 (14:12 -0500) | ||
committer | Shawn O. Pearce <spearce@spearce.org> | |
Sun, 12 Oct 2008 19:36:19 +0000 (12:36 -0700) |
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>
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>
46 files changed:
diff --git a/archive-tar.c b/archive-tar.c
index 13029619e5ec34bac4ba61a6fc08800ab36f4a1b..ba890ebdecd8672aeb32757605c8a2976fa21161 100644 (file)
--- a/archive-tar.c
+++ b/archive-tar.c
unsigned int mode, void *buffer, unsigned long size)
{
struct ustar_header header;
- struct strbuf ext_header;
+ struct strbuf ext_header = STRBUF_INIT;
int err = 0;
memset(&header, 0, sizeof(header));
- strbuf_init(&ext_header, 0);
if (!sha1) {
*header.typeflag = TYPEFLAG_GLOBAL_HEADER;
static int write_global_extended_header(struct archiver_args *args)
{
const unsigned char *sha1 = args->commit_sha1;
- struct strbuf ext_header;
+ struct strbuf ext_header = STRBUF_INIT;
int err;
- strbuf_init(&ext_header, 0);
strbuf_append_ext_header(&ext_header, "comment", sha1_to_hex(sha1), 40);
err = write_tar_entry(args, NULL, NULL, 0, 0, ext_header.buf,
ext_header.len);
diff --git a/archive.c b/archive.c
index 44ab008039854b7c585adf53bee195b81f4e18c7..849eed553e9d6455c021664135a01b322eef9a31 100644 (file)
--- a/archive.c
+++ b/archive.c
struct strbuf *buf)
{
char *to_free = NULL;
- struct strbuf fmt;
+ struct strbuf fmt = STRBUF_INIT;
if (src == buf->buf)
to_free = strbuf_detach(buf, NULL);
- strbuf_init(&fmt, 0);
for (;;) {
const char *b, *c;
buffer = read_sha1_file(sha1, type, sizep);
if (buffer && S_ISREG(mode)) {
- struct strbuf buf;
+ struct strbuf buf = STRBUF_INIT;
size_t size = 0;
- strbuf_init(&buf, 0);
strbuf_attach(&buf, buffer, *sizep, *sizep + 1);
convert_to_working_tree(path, buf.buf, buf.len, &buf);
if (commit)
diff --git a/builtin-apply.c b/builtin-apply.c
index bf806105062caa47ca168720e0e987ac8957c8af..f1f675819f22ec1b47fb7b25ed050dc4ddcad378 100644 (file)
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -321,13 +321,12 @@ static char *find_name(const char *line, char *def, int p_value, int terminate)
const char *start = line;
if (*line == '"') {
- struct strbuf name;
+ struct strbuf name = STRBUF_INIT;
/*
* Proposed "new-style" GNU patch/diff format; see
* http://marc.theaimsgroup.com/?l=git&m=112927316408690&w=2
*/
- strbuf_init(&name, 0);
if (!unquote_c_style(&name, line, NULL)) {
char *cp;
if (*line == '"') {
const char *cp;
- struct strbuf first;
- struct strbuf sp;
-
- strbuf_init(&first, 0);
- strbuf_init(&sp, 0);
+ struct strbuf first = STRBUF_INIT;
+ struct strbuf sp = STRBUF_INIT;
if (unquote_c_style(&first, line, &second))
goto free_and_fail1;
*/
for (second = name; second < line + llen; second++) {
if (*second == '"') {
- struct strbuf sp;
+ struct strbuf sp = STRBUF_INIT;
const char *np;
- strbuf_init(&sp, 0);
if (unquote_c_style(&sp, second, NULL))
goto free_and_fail2;
static void show_stats(struct patch *patch)
{
- struct strbuf qname;
+ struct strbuf qname = STRBUF_INIT;
char *cp = patch->new_name ? patch->new_name : patch->old_name;
int max, add, del;
- strbuf_init(&qname, 0);
quote_c_style(cp, &qname, NULL, 0);
/*
static int apply_data(struct patch *patch, struct stat *st, struct cache_entry *ce)
{
- struct strbuf buf;
+ struct strbuf buf = STRBUF_INIT;
struct image image;
size_t len;
char *img;
struct patch *tpatch;
- strbuf_init(&buf, 0);
-
if (!(patch->is_copy || patch->is_rename) &&
((tpatch = in_fn_table(patch->old_name)) != NULL)) {
if (tpatch == (struct patch *) -1) {
@@ -2779,7 +2771,7 @@ static void add_index_file(const char *path, unsigned mode, void *buf, unsigned
static int try_create_file(const char *path, unsigned int mode, const char *buf, unsigned long size)
{
int fd;
- struct strbuf nbuf;
+ struct strbuf nbuf = STRBUF_INIT;
if (S_ISGITLINK(mode)) {
struct stat st;
@@ -2798,7 +2790,6 @@ static int try_create_file(const char *path, unsigned int mode, const char *buf,
if (fd < 0)
return -1;
- strbuf_init(&nbuf, 0);
if (convert_to_working_tree(path, buf, size, &nbuf)) {
size = nbuf.len;
buf = nbuf.buf;
static int apply_patch(int fd, const char *filename, int options)
{
size_t offset;
- struct strbuf buf;
+ struct strbuf buf = STRBUF_INIT;
struct patch *list = NULL, **listp = &list;
int skipped_patch = 0;
/* FIXME - memory leak when using multiple patch files as inputs */
memset(&fn_table, 0, sizeof(struct string_list));
- strbuf_init(&buf, 0);
patch_input_file = filename;
read_patch_file(&buf, fd);
offset = 0;
diff --git a/builtin-blame.c b/builtin-blame.c
index df537593d052f0b4d705eb1d0d19ed296f76a39d..48cc0c175d52446266658d785de0311daaaf4776 100644 (file)
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -2062,7 +2062,7 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con
struct commit *commit;
struct origin *origin;
unsigned char head_sha1[20];
- struct strbuf buf;
+ struct strbuf buf = STRBUF_INIT;
const char *ident;
time_t now;
int size, len;
@@ -2082,7 +2082,6 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con
origin = make_origin(commit, path);
- strbuf_init(&buf, 0);
if (!contents_from || strcmp("-", contents_from)) {
struct stat st;
const char *read_from;
diff --git a/builtin-branch.c b/builtin-branch.c
index b1a2ad7a6b3b150cda8d031a87352a4daedc40ea..8d634ff571ce34ce21a5519628d6f66a7e52aa93 100644 (file)
--- a/builtin-branch.c
+++ b/builtin-branch.c
}
if (verbose) {
- struct strbuf subject;
+ struct strbuf subject = STRBUF_INIT;
const char *sub = " **** invalid ref ****";
char stat[128];
- strbuf_init(&subject, 0);
stat[0] = '\0';
commit = item->commit;
diff --git a/builtin-cat-file.c b/builtin-cat-file.c
index 3fba6b9e743545868368a0e554466fca3814316a..30d00a66649f749c8cf6e657734045382bc29e13 100644 (file)
--- a/builtin-cat-file.c
+++ b/builtin-cat-file.c
static int batch_objects(int print_contents)
{
- struct strbuf buf;
+ struct strbuf buf = STRBUF_INIT;
- strbuf_init(&buf, 0);
while (strbuf_getline(&buf, stdin, '\n') != EOF) {
int error = batch_one_object(buf.buf, print_contents);
if (error)
index 55b7aafe06680fa51729ddb7fa97f9cd319a470e..4ba27024c53ca1b67e9b6d6f4a62aa7548b7b96d 100644 (file)
--- a/builtin-checkout-index.c
+++ b/builtin-checkout-index.c
}
if (read_from_stdin) {
- struct strbuf buf, nbuf;
+ struct strbuf buf = STRBUF_INIT, nbuf = STRBUF_INIT;
if (all)
die("git checkout-index: don't mix '--all' and '--stdin'");
- strbuf_init(&buf, 0);
- strbuf_init(&nbuf, 0);
while (strbuf_getline(&buf, stdin, line_termination) != EOF) {
const char *p;
if (line_termination && buf.buf[0] == '"') {
diff --git a/builtin-checkout.c b/builtin-checkout.c
index 3762f71aaeae623b37d38c5c03b7a0d10973efc4..ad04a184a28b7cdbb5278cda9c467a2e37b0add8 100644 (file)
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
static void describe_detached_head(char *msg, struct commit *commit)
{
- struct strbuf sb;
- strbuf_init(&sb, 0);
+ struct strbuf sb = STRBUF_INIT;
parse_commit(commit);
pretty_print_commit(CMIT_FMT_ONELINE, commit, &sb, 0, NULL, NULL, 0, 0);
fprintf(stderr, "%s %s... %s\n", msg,
static void setup_branch_path(struct branch_info *branch)
{
- struct strbuf buf;
- strbuf_init(&buf, 0);
+ struct strbuf buf = STRBUF_INIT;
strbuf_addstr(&buf, "refs/heads/");
strbuf_addstr(&buf, branch->name);
branch->path = strbuf_detach(&buf, NULL);
struct branch_info *old,
struct branch_info *new)
{
- struct strbuf msg;
+ struct strbuf msg = STRBUF_INIT;
const char *old_desc;
if (opts->new_branch) {
create_branch(old->name, opts->new_branch, new->name, 0,
setup_branch_path(new);
}
- strbuf_init(&msg, 0);
old_desc = old->name;
if (!old_desc)
old_desc = sha1_to_hex(old->commit->object.sha1);
}
if (opts.new_branch) {
- struct strbuf buf;
- strbuf_init(&buf, 0);
+ struct strbuf buf = STRBUF_INIT;
strbuf_addstr(&buf, "refs/heads/");
strbuf_addstr(&buf, opts.new_branch);
if (!get_sha1(buf.buf, rev))
diff --git a/builtin-clean.c b/builtin-clean.c
index 48bf29f40a5e06fd588b34c468535e04abcf206b..f78c2fb108bc667079290f9b2fa82f47da5eb34c 100644 (file)
--- a/builtin-clean.c
+++ b/builtin-clean.c
int i;
int show_only = 0, remove_directories = 0, quiet = 0, ignored = 0;
int ignored_only = 0, baselen = 0, config_set = 0, errors = 0;
- struct strbuf directory;
+ struct strbuf directory = STRBUF_INIT;
struct dir_struct dir;
const char *path, *base;
static const char **pathspec;
- struct strbuf buf;
+ struct strbuf buf = STRBUF_INIT;
const char *qname;
char *seen = NULL;
struct option options[] = {
argc = parse_options(argc, argv, options, builtin_clean_usage, 0);
- strbuf_init(&buf, 0);
memset(&dir, 0, sizeof(dir));
if (ignored_only)
dir.show_ignored = 1;
if (baselen)
path = base = xmemdupz(*pathspec, baselen);
read_directory(&dir, path, base, baselen, pathspec);
- strbuf_init(&directory, 0);
if (pathspec)
seen = xmalloc(argc > 0 ? argc : 1);
diff --git a/builtin-clone.c b/builtin-clone.c
index 49d2eb9c2ba574f2c1484717f0755208e7ed8147..1ddc14b9c70b3318ab5e1cad779c8af029e56ce3 100644 (file)
--- a/builtin-clone.c
+++ b/builtin-clone.c
static void remove_junk(void)
{
- struct strbuf sb;
+ struct strbuf sb = STRBUF_INIT;
if (getpid() != junk_pid)
return;
- strbuf_init(&sb, 0);
if (junk_git_dir) {
strbuf_addstr(&sb, junk_git_dir);
remove_dir_recursively(&sb, 0);
char *path, *dir;
const struct ref *refs, *head_points_at, *remote_head, *mapped_refs;
char branch_top[256], key[256], value[256];
- struct strbuf reflog_msg;
+ struct strbuf reflog_msg = STRBUF_INIT;
struct transport *transport = NULL;
char *src_ref_prefix = "refs/heads/";
if (!stat(dir, &buf))
die("destination directory '%s' already exists.", dir);
- strbuf_init(&reflog_msg, 0);
strbuf_addf(&reflog_msg, "clone: from %s", repo);
if (option_bare)
create_symref("HEAD", head_points_at->name, NULL);
if (!option_bare) {
- struct strbuf head_ref;
+ struct strbuf head_ref = STRBUF_INIT;
const char *head = head_points_at->name;
if (!prefixcmp(head, "refs/heads/"))
head_points_at->old_sha1,
NULL, 0, DIE_ON_ERR);
- strbuf_init(&head_ref, 0);
strbuf_addstr(&head_ref, branch_top);
strbuf_addstr(&head_ref, "HEAD");
diff --git a/builtin-commit.c b/builtin-commit.c
index b920257524850ea04bc940411d342e9a622e7094..a2755dc3befeb5ed768f692ee58e5147ad933e26 100644 (file)
--- a/builtin-commit.c
+++ b/builtin-commit.c
{
struct stat statbuf;
int commitable, saved_color_setting;
- struct strbuf sb;
+ struct strbuf sb = STRBUF_INIT;
char *buffer;
FILE *fp;
const char *hook_arg1 = NULL;
if (!no_verify && run_hook(index_file, "pre-commit", NULL))
return 0;
- strbuf_init(&sb, 0);
if (message.len) {
strbuf_addbuf(&sb, &message);
hook_arg1 = "message";
stripspace(&sb, 0);
if (signoff) {
- struct strbuf sob;
+ struct strbuf sob = STRBUF_INIT;
int i;
- strbuf_init(&sob, 0);
strbuf_addstr(&sob, sign_off_header);
strbuf_addstr(&sob, fmt_name(getenv("GIT_COMMITTER_NAME"),
getenv("GIT_COMMITTER_EMAIL")));
*/
static int message_is_empty(struct strbuf *sb)
{
- struct strbuf tmpl;
+ struct strbuf tmpl = STRBUF_INIT;
const char *nl;
int eol, i, start = 0;
return 0;
/* See if the template is just a prefix of the message. */
- strbuf_init(&tmpl, 0);
if (template_file && strbuf_read_file(&tmpl, template_file, 0) > 0) {
stripspace(&tmpl, cleanup_mode == CLEANUP_ALL);
if (start + tmpl.len <= sb->len &&
int cmd_commit(int argc, const char **argv, const char *prefix)
{
- struct strbuf sb;
+ struct strbuf sb = STRBUF_INIT;
const char *index_file, *reflog_msg;
char *nl, *p;
unsigned char commit_sha1[20];
for (c = commit->parents; c; c = c->next)
pptr = &commit_list_insert(c->item, pptr)->next;
} else if (in_merge) {
- struct strbuf m;
+ struct strbuf m = STRBUF_INIT;
FILE *fp;
reflog_msg = "commit (merge)";
pptr = &commit_list_insert(lookup_commit(head_sha1), pptr)->next;
- strbuf_init(&m, 0);
fp = fopen(git_path("MERGE_HEAD"), "r");
if (fp == NULL)
die("could not open %s for reading: %s",
parents = reduce_heads(parents);
/* Finally, get the commit message */
- strbuf_init(&sb, 0);
if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) {
rollback_index_files();
die("could not read commit message");
diff --git a/builtin-fetch--tool.c b/builtin-fetch--tool.c
index 7460ab7fce2a4e6a7e014f448819140e2204ccb7..469b07e240953aa21fd67eb2563e094a7f0f3d42 100644 (file)
--- a/builtin-fetch--tool.c
+++ b/builtin-fetch--tool.c
static char *get_stdin(void)
{
- struct strbuf buf;
- strbuf_init(&buf, 0);
+ struct strbuf buf = STRBUF_INIT;
if (strbuf_read(&buf, 0, 1024) < 0) {
die("error reading standard input: %s", strerror(errno));
}
index c6324dc795bfd778470fbbe7b0720ce9ff83a34e..df18f4070f3877ed907476f2179590001ec972b7 100644 (file)
--- a/builtin-fmt-merge-msg.c
+++ b/builtin-fmt-merge-msg.c
};
FILE *in = stdin;
- struct strbuf input, output;
+ struct strbuf input = STRBUF_INIT, output = STRBUF_INIT;
int ret;
git_config(fmt_merge_msg_config, NULL);
die("cannot open %s", inpath);
}
- strbuf_init(&input, 0);
if (strbuf_read(&input, fileno(in), 0) < 0)
die("could not read input file %s", strerror(errno));
- strbuf_init(&output, 0);
ret = fmt_merge_msg(merge_summary, &input, &output);
if (ret)
diff --git a/builtin-help.c b/builtin-help.c
index 64207cbfe909d17ea9698d3ff680203eee9f5c01..f076efa9211ddcffdc81ffd7c0c56fdb197a11b0 100644 (file)
--- a/builtin-help.c
+++ b/builtin-help.c
static void setup_man_path(void)
{
- struct strbuf new_path;
+ struct strbuf new_path = STRBUF_INIT;
const char *old_path = getenv("MANPATH");
- strbuf_init(&new_path, 0);
-
/* We should always put ':' after our path. If there is no
* old_path, the ':' at the end will let 'man' to try
* system-wide paths after ours to find the manual page. If
diff --git a/builtin-log.c b/builtin-log.c
index fc5e4da822c470fdb2fb4738874a56e0103a2013..794821f6bca6500cbb040403c1350932ae7126fb 100644 (file)
--- a/builtin-log.c
+++ b/builtin-log.c
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);
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;
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,
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);
}
argc = j;
- strbuf_init(&buf, 0);
-
for (i = 0; i < extra_hdr_nr; i++) {
strbuf_addstr(&buf, extra_hdr[i]);
strbuf_addch(&buf, '\n');
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,
diff --git a/builtin-merge.c b/builtin-merge.c
index 38266baf5fe9f54a0006baaae205b55f12ed15fc..5e2b7f12c35ab1bfebda66f7ee9180c68e7f23c4 100644 (file)
--- a/builtin-merge.c
+++ b/builtin-merge.c
static void restore_state(void)
{
- struct strbuf sb;
+ struct strbuf sb = STRBUF_INIT;
const char *args[] = { "stash", "apply", NULL, NULL };
if (is_null_sha1(stash))
reset_hard(head, 1);
- strbuf_init(&sb, 0);
args[2] = sha1_to_hex(stash);
/*
{
struct rev_info rev;
struct commit *commit;
- struct strbuf out;
+ struct strbuf out = STRBUF_INIT;
struct commit_list *j;
int fd;
if (prepare_revision_walk(&rev))
die("revision walk setup failed");
- strbuf_init(&out, 0);
strbuf_addstr(&out, "Squashed commit of the following:\n");
while ((commit = get_revision(&rev)) != NULL) {
strbuf_addch(&out, '\n');
static void finish(const unsigned char *new_head, const char *msg)
{
- struct strbuf reflog_message;
+ struct strbuf reflog_message = STRBUF_INIT;
- strbuf_init(&reflog_message, 0);
if (!msg)
strbuf_addstr(&reflog_message, getenv("GIT_REFLOG_ACTION"));
else {
{
struct object *remote_head;
unsigned char branch_head[20], buf_sha[20];
- struct strbuf buf;
+ struct strbuf buf = STRBUF_INIT;
const char *ptr;
int len, early;
if (!remote_head)
die("'%s' does not point to a commit", remote);
- strbuf_init(&buf, 0);
strbuf_addstr(&buf, "refs/heads/");
strbuf_addstr(&buf, remote);
resolve_ref(buf.buf, branch_head, 0, 0);
if (!strcmp(remote, "FETCH_HEAD") &&
!access(git_path("FETCH_HEAD"), R_OK)) {
FILE *fp;
- struct strbuf line;
+ struct strbuf line = STRBUF_INIT;
char *ptr;
- strbuf_init(&line, 0);
fp = fopen(git_path("FETCH_HEAD"), "r");
if (!fp)
die("could not open %s for reading: %s",
const char **args;
int i = 0, ret;
struct commit_list *j;
- struct strbuf buf;
+ struct strbuf buf = STRBUF_INIT;
int index_fd;
struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
} else {
args = xmalloc((4 + commit_list_count(common) +
commit_list_count(remoteheads)) * sizeof(char *));
- strbuf_init(&buf, 0);
strbuf_addf(&buf, "merge-%s", strategy);
args[i++] = buf.buf;
for (j = common; j; j = j->next)
int cmd_merge(int argc, const char **argv, const char *prefix)
{
unsigned char result_tree[20];
- struct strbuf buf;
+ struct strbuf buf = STRBUF_INIT;
const char *head_arg;
int flag, head_invalid = 0, i;
int best_cnt = -1, merge_was_ok = 0, automerge_was_ok = 0;
* Traditional format never would have "-m" so it is an
* additional safety measure to check for it.
*/
- strbuf_init(&buf, 0);
if (!have_message && is_old_style_invocation(argc, argv)) {
strbuf_addstr(&merge_msg, argv[0]);
reset_hard(remote_head->sha1, 0);
return 0;
} else {
- struct strbuf msg;
+ struct strbuf msg = STRBUF_INIT;
/* We are invoked directly as the first-class UI. */
head_arg = "HEAD";
* codepath so we discard the error in this
* loop.
*/
- strbuf_init(&msg, 0);
for (i = 0; i < argc; i++)
merge_name(argv[i], &msg);
fmt_merge_msg(option_log, &msg, &merge_msg);
!common->next &&
!hashcmp(common->item->object.sha1, head)) {
/* Again the most common case of merging one remote. */
- struct strbuf msg;
+ struct strbuf msg = STRBUF_INIT;
struct object *o;
char hex[41];
hex,
find_unique_abbrev(remoteheads->item->object.sha1,
DEFAULT_ABBREV));
- strbuf_init(&msg, 0);
strbuf_addstr(&msg, "Fast forward");
if (have_message)
strbuf_addstr(&msg,
diff --git a/builtin-remote.c b/builtin-remote.c
index 90a4e35828697f349a38ba3486c40813db32cee0..6b3325dfa9e0aa52d806d1c28692a05cf549abe4 100644 (file)
--- a/builtin-remote.c
+++ b/builtin-remote.c
struct string_list track = { NULL, 0, 0 };
const char *master = NULL;
struct remote *remote;
- struct strbuf buf, buf2;
+ struct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT;
const char *name, *url;
int i;
remote->fetch_refspec_nr))
die("remote %s already exists.", name);
- strbuf_init(&buf, 0);
- strbuf_init(&buf2, 0);
-
strbuf_addf(&buf2, "refs/heads/test:refs/remotes/%s/test", name);
if (!valid_fetch_refspec(buf2.buf))
die("'%s' is not a valid remote name", name);
OPT_END()
};
struct remote *remote;
- struct strbuf buf;
+ struct strbuf buf = STRBUF_INIT;
struct known_remotes known_remotes = { NULL, NULL };
struct string_list branches = { NULL, 0, 0, 1 };
struct branches_for_remote cb_data = { NULL, &branches, &known_remotes };
known_remotes.to_delete = remote;
for_each_remote(add_known_remote, &known_remotes);
- strbuf_init(&buf, 0);
strbuf_addf(&buf, "remote.%s", remote->name);
if (git_config_rename_section(buf.buf, NULL) < 1)
return error("Could not remove config section '%s'", buf.buf);
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index facaff288dba2789f0637c4554bd130440e2a3da..06cdeb7ebe7468911a7bee670bf5ec539185ba54 100644 (file)
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
putchar('\n');
if (revs.verbose_header && commit->buffer) {
- struct strbuf buf;
- strbuf_init(&buf, 0);
+ struct strbuf buf = STRBUF_INIT;
pretty_print_commit(revs.commit_format, commit,
&buf, revs.abbrev, NULL, NULL,
revs.date_mode, 0);
diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index 9aa049ec170b0125fddde29adda3c720c8a7b8ee..81d5a6ffc9ff1c149bfb68f976a9e66c307cae1d 100644 (file)
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
OPT_END(),
};
- struct strbuf sb, parsed;
+ struct strbuf sb = STRBUF_INIT, parsed = STRBUF_INIT;
const char **usage = NULL;
struct option *opts = NULL;
int onb = 0, osz = 0, unb = 0, usz = 0;
- strbuf_init(&parsed, 0);
strbuf_addstr(&parsed, "set --");
argc = parse_options(argc, argv, parseopt_opts, parseopt_usage,
PARSE_OPT_KEEP_DASHDASH);
if (argc < 1 || strcmp(argv[0], "--"))
usage_with_options(parseopt_usage, parseopt_opts);
- strbuf_init(&sb, 0);
/* get the usage up to the first line with a -- on it */
for (;;) {
if (strbuf_getline(&sb, stdin, '\n') == EOF)
diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index 233eed499d0b8790781326ff0455bdc7f09fe4d4..306b850c720ecef7030bd7139f7c7d2758125ac4 100644 (file)
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
static void show_one_commit(struct commit *commit, int no_name)
{
- struct strbuf pretty;
+ struct strbuf pretty = STRBUF_INIT;
const char *pretty_str = "(unavailable)";
struct commit_name *name = commit->util;
- strbuf_init(&pretty, 0);
if (commit->object.parsed) {
pretty_print_commit(CMIT_FMT_ONELINE, commit,
&pretty, 0, NULL, NULL, 0, 0);
diff --git a/builtin-stripspace.c b/builtin-stripspace.c
index c0b21301ba4c126a49ed38b6983756b99a25aae0..d6e3896c006796ccca12c00de45e36583387f05b 100644 (file)
--- a/builtin-stripspace.c
+++ b/builtin-stripspace.c
int cmd_stripspace(int argc, const char **argv, const char *prefix)
{
- struct strbuf buf;
+ struct strbuf buf = STRBUF_INIT;
int strip_comments = 0;
if (argc > 1 && (!strcmp(argv[1], "-s") ||
!strcmp(argv[1], "--strip-comments")))
strip_comments = 1;
- strbuf_init(&buf, 0);
if (strbuf_read(&buf, 0, 1024) < 0)
die("could not read the input");
diff --git a/builtin-tag.c b/builtin-tag.c
index f2853d08c77368b37b40c7ea51f5a124208d385f..b13fa34d8c59a9226599ba10b4d679f41ad230b0 100644 (file)
--- a/builtin-tag.c
+++ b/builtin-tag.c
int cmd_tag(int argc, const char **argv, const char *prefix)
{
- struct strbuf buf;
+ struct strbuf buf = STRBUF_INIT;
unsigned char object[20], prev[20];
char ref[PATH_MAX];
const char *object_ref, *tag;
if (verify)
return for_each_tag_name(argv, verify_tag);
- strbuf_init(&buf, 0);
if (msg.given || msgfile) {
if (msg.given && msgfile)
die("only one -F or -m option is allowed.");
diff --git a/builtin-update-index.c b/builtin-update-index.c
index 3a2291b03e23fbcf6b8dc6fffedd4d7dcf072aaa..65d5775107f9013526cc5b288a80a00b449e8814 100644 (file)
--- a/builtin-update-index.c
+++ b/builtin-update-index.c
@@ -297,11 +297,9 @@ static void update_one(const char *path, const char *prefix, int prefix_length)
static void read_index_info(int line_termination)
{
- struct strbuf buf;
- struct strbuf uq;
+ struct strbuf buf = STRBUF_INIT;
+ struct strbuf uq = STRBUF_INIT;
- strbuf_init(&buf, 0);
- strbuf_init(&uq, 0);
while (strbuf_getline(&buf, stdin, line_termination) != EOF) {
char *ptr, *tab;
char *path_name;
free((char*)p);
}
if (read_from_stdin) {
- struct strbuf buf, nbuf;
+ struct strbuf buf = STRBUF_INIT, nbuf = STRBUF_INIT;
- strbuf_init(&buf, 0);
- strbuf_init(&nbuf, 0);
setup_work_tree();
while (strbuf_getline(&buf, stdin, line_termination) != EOF) {
const char *p;
diff --git a/combine-diff.c b/combine-diff.c
index de83c6972e9dffbd634e5cc09b5e455ec22c6c48..5aa1104d3480f8057dd71c49bcf300eccabe2f9d 100644 (file)
--- a/combine-diff.c
+++ b/combine-diff.c
/* If not a fake symlink, apply filters, e.g. autocrlf */
if (is_file) {
- struct strbuf buf;
+ struct strbuf buf = STRBUF_INIT;
- strbuf_init(&buf, 0);
if (convert_to_git(elem->path, result, len, &buf, safe_crlf)) {
free(result);
result = strbuf_detach(&buf, &len);
diff --git a/config.c b/config.c
index 18d305c890d3f4ba00962cfa4033ff9ed68cf95b..b8d289d21789b5017579d90b7894db8ebee4c47a 100644 (file)
--- a/config.c
+++ b/config.c
{
const char *dot;
int i, success;
- struct strbuf sb;
+ struct strbuf sb = STRBUF_INIT;
- strbuf_init(&sb, 0);
dot = memchr(key, '.', store.baselen);
if (dot) {
strbuf_addf(&sb, "[%.*s \"", (int)(dot - key), key);
int i, success;
int length = strlen(key + store.baselen + 1);
const char *quote = "";
- struct strbuf sb;
+ struct strbuf sb = STRBUF_INIT;
/*
* Check to see if the value needs to be surrounded with a dq pair.
if (i && value[i - 1] == ' ')
quote = "\"";
- strbuf_init(&sb, 0);
strbuf_addf(&sb, "\t%.*s = %s",
length, key + store.baselen + 1, quote);
diff --git a/convert.c b/convert.c
index 78efed800d4d64898d438d9590b01be008cfcd36..1816e977b7b13782003fc78a9de9b47cd3554a32 100644 (file)
--- a/convert.c
+++ b/convert.c
* (child --> cmd) --> us
*/
int ret = 1;
- struct strbuf nbuf;
+ struct strbuf nbuf = STRBUF_INIT;
struct async async;
struct filter_params params;
if (start_async(&async))
return 0; /* error was already reported */
- strbuf_init(&nbuf, 0);
if (strbuf_read(&nbuf, async.out, len) < 0) {
error("read from external filter %s failed", cmd);
ret = 0;
index 2af3a974872e3bafeead339503a0d1eab051779d..1c6be897b2c95fc481c02834e4fe022b6bd405ae 100644 (file)
--- a/diff.c
+++ b/diff.c
{
int need_one = quote_c_style(one, NULL, NULL, 1);
int need_two = quote_c_style(two, NULL, NULL, 1);
- struct strbuf res;
+ struct strbuf res = STRBUF_INIT;
- strbuf_init(&res, 0);
if (need_one + need_two) {
strbuf_addch(&res, '"');
quote_c_style(one, &res, NULL, 1);
{
const char *old = a;
const char *new = b;
- struct strbuf name;
+ struct strbuf name = STRBUF_INIT;
int pfx_length, sfx_length;
int len_a = strlen(a);
int len_b = strlen(b);
int qlen_a = quote_c_style(a, NULL, NULL, 0);
int qlen_b = quote_c_style(b, NULL, NULL, 0);
- strbuf_init(&name, 0);
if (qlen_a || qlen_b) {
quote_c_style(a, &name, NULL, 0);
strbuf_addstr(&name, " => ");
return;
if (!file->is_renamed) {
- struct strbuf buf;
- strbuf_init(&buf, 0);
+ struct strbuf buf = STRBUF_INIT;
if (quote_c_style(file->name, &buf, NULL, 0)) {
pname = strbuf_detach(&buf, NULL);
} else {
@@ -1820,10 +1817,9 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
static int populate_from_stdin(struct diff_filespec *s)
{
- struct strbuf buf;
+ struct strbuf buf = STRBUF_INIT;
size_t size = 0;
- strbuf_init(&buf, 0);
if (strbuf_read(&buf, 0, 0) < 0)
return error("error while reading from stdin %s",
strerror(errno));
if (!s->sha1_valid ||
reuse_worktree_file(s->path, s->sha1, 0)) {
- struct strbuf buf;
+ struct strbuf buf = STRBUF_INIT;
struct stat st;
int fd;
/*
* Convert from working tree format to canonical git format
*/
- strbuf_init(&buf, 0);
if (convert_to_git(s->path, s->data, s->size, &buf, safe_crlf)) {
size_t size = 0;
munmap(s->data, s->size);
diff --git a/editor.c b/editor.c
index eebc3e95fe0c7e61f7c29fa5412ea9d4a5900f92..4d469d076bcd58df3af16d98adc9120e34765944 100644 (file)
--- a/editor.c
+++ b/editor.c
int i = 0;
int failed;
const char *args[6];
- struct strbuf arg0;
+ struct strbuf arg0 = STRBUF_INIT;
- strbuf_init(&arg0, 0);
if (strcspn(editor, "$ \t'") != len) {
/* there are specials */
strbuf_addf(&arg0, "%s \"$@\"", editor);
diff --git a/exec_cmd.c b/exec_cmd.c
index ce6741eb682b59ad638c7bee6ca31e2fcd53f281..cdd35f91954bdc751455e1083a0612a21eeadc67 100644 (file)
--- a/exec_cmd.c
+++ b/exec_cmd.c
void setup_path(void)
{
const char *old_path = getenv("PATH");
- struct strbuf new_path;
-
- strbuf_init(&new_path, 0);
+ struct strbuf new_path = STRBUF_INIT;
add_path(&new_path, argv_exec_path);
add_path(&new_path, getenv(EXEC_PATH_ENVIRONMENT));
index 797e3178ae279f444d2efa7e3758652ad0898dd7..0cf5f012bdfa876fae4e15ed9cb94ed304314bf6 100644 (file)
--- a/fsck.c
+++ b/fsck.c
{
va_list ap;
int len;
- struct strbuf sb;
+ struct strbuf sb = STRBUF_INIT;
- strbuf_init(&sb, 0);
strbuf_addf(&sb, "object %s:", obj->sha1?sha1_to_hex(obj->sha1):"(null)");
va_start(ap, fmt);
index f4b0cf611b8a281d51970fa088c7271f0aacf21c..89feb0b6dc9c34902aa7c3c4ac526c646c0e0d84 100644 (file)
--- a/git.c
+++ b/git.c
static void execv_dashed_external(const char **argv)
{
- struct strbuf cmd;
+ struct strbuf cmd = STRBUF_INIT;
const char *tmp;
- strbuf_init(&cmd, 0);
strbuf_addf(&cmd, "git-%s", argv[0]);
/*
index 5f821706c63778e8b6b53a10894edfc2fb21a8b0..162a516ee15cca1f8ab118dd41b803a5d76e42ff 100644 (file)
--- a/graph.c
+++ b/graph.c
void graph_show_commit(struct git_graph *graph)
{
- struct strbuf msgbuf;
+ struct strbuf msgbuf = STRBUF_INIT;
int shown_commit_line = 0;
if (!graph)
return;
- strbuf_init(&msgbuf, 0);
-
while (!shown_commit_line) {
shown_commit_line = graph_next_line(graph, &msgbuf);
fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
void graph_show_oneline(struct git_graph *graph)
{
- struct strbuf msgbuf;
+ struct strbuf msgbuf = STRBUF_INIT;
if (!graph)
return;
- strbuf_init(&msgbuf, 0);
graph_next_line(graph, &msgbuf);
fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
strbuf_release(&msgbuf);
void graph_show_padding(struct git_graph *graph)
{
- struct strbuf msgbuf;
+ struct strbuf msgbuf = STRBUF_INIT;
if (!graph)
return;
- strbuf_init(&msgbuf, 0);
graph_padding_line(graph, &msgbuf);
fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
strbuf_release(&msgbuf);
int graph_show_remainder(struct git_graph *graph)
{
- struct strbuf msgbuf;
+ struct strbuf msgbuf = STRBUF_INIT;
int shown = 0;
if (!graph)
if (graph_is_commit_finished(graph))
return 0;
- strbuf_init(&msgbuf, 0);
for (;;) {
graph_next_line(graph, &msgbuf);
fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
diff --git a/hash-object.c b/hash-object.c
index a4d127cf78013ca43339c5493b7f7ef90b2145a8..20937ff94c1ce6ab7984d7b6b1903307e303eb60 100644 (file)
--- a/hash-object.c
+++ b/hash-object.c
static void hash_stdin_paths(const char *type, int write_objects)
{
- struct strbuf buf, nbuf;
+ struct strbuf buf = STRBUF_INIT, nbuf = STRBUF_INIT;
- strbuf_init(&buf, 0);
- strbuf_init(&nbuf, 0);
while (strbuf_getline(&buf, stdin, '\n') != EOF) {
if (buf.buf[0] == '"') {
strbuf_reset(&nbuf);
diff --git a/imap-send.c b/imap-send.c
index af7e08c0943ada9a650f80fd5b5fc1df23c04b88..3703dbd1af65c30806a98f0d2d3dc14b8b0e9798 100644 (file)
--- a/imap-send.c
+++ b/imap-send.c
@@ -1266,10 +1266,9 @@ static int imap_store_msg(struct store *gctx, struct msg_data *data, int *uid)
static int read_message(FILE *f, struct msg_data *msg)
{
- struct strbuf buf;
+ struct strbuf buf = STRBUF_INIT;
memset(msg, 0, sizeof(*msg));
- strbuf_init(&buf, 0);
do {
if (strbuf_fread(&buf, CHUNKSIZE, f) <= 0)
diff --git a/log-tree.c b/log-tree.c
index 2c1f3e673ae7c9441cb171244d3fb91a8dd9fb1b..cec3c061360e9d33068fdb6c2555b69cc11f6771 100644 (file)
--- a/log-tree.c
+++ b/log-tree.c
void show_log(struct rev_info *opt)
{
- struct strbuf msgbuf;
+ struct strbuf msgbuf = STRBUF_INIT;
struct log_info *log = opt->loginfo;
struct commit *commit = log->commit, *parent = log->parent;
int abbrev = opt->diffopt.abbrev;
/*
* And then the pretty-printed message itself
*/
- strbuf_init(&msgbuf, 0);
if (need_8bit_cte >= 0)
need_8bit_cte = has_non_ascii(opt->add_signoff);
pretty_print_commit(opt->commit_format, commit, &msgbuf,
diff --git a/merge-recursive.c b/merge-recursive.c
index 6bc3eac85c46700b1ed7ab93bce6ecf859fa13f9..245232a4083bbd8cdadf3b32a0a20db559941f8a 100644 (file)
--- a/merge-recursive.c
+++ b/merge-recursive.c
if (type != OBJ_BLOB)
die("blob expected for %s '%s'", sha1_to_hex(sha), path);
if (S_ISREG(mode)) {
- struct strbuf strbuf;
- strbuf_init(&strbuf, 0);
+ struct strbuf strbuf = STRBUF_INIT;
if (convert_to_working_tree(path, buf, size, &strbuf)) {
free(buf);
size = strbuf.len;
index 0b34341f711a903d4a12fe96dc6ef63e55fb2f5b..ba3d495e0715d83ffab3103e4d340a3b9ac4f4e7 100644 (file)
--- a/mktag.c
+++ b/mktag.c
int main(int argc, char **argv)
{
- struct strbuf buf;
+ struct strbuf buf = STRBUF_INIT;
unsigned char result_sha1[20];
if (argc != 1)
setup_git_directory();
- strbuf_init(&buf, 0);
if (strbuf_read(&buf, 0, 4096) < 0) {
die("could not read from stdin");
}
diff --git a/mktree.c b/mktree.c
index e0da110a98d3a7376dc78df71fabc10fc5664296..514fd9b15a6680389bf2c1274d29c55d2c1034f7 100644 (file)
--- a/mktree.c
+++ b/mktree.c
int main(int ac, char **av)
{
- struct strbuf sb;
- struct strbuf p_uq;
+ struct strbuf sb = STRBUF_INIT;
+ struct strbuf p_uq = STRBUF_INIT;
unsigned char sha1[20];
int line_termination = '\n';
av++;
}
- strbuf_init(&sb, 0);
- strbuf_init(&p_uq, 0);
while (strbuf_getline(&sb, stdin, line_termination) != EOF) {
char *ptr, *ntr;
unsigned mode;
diff --git a/pretty.c b/pretty.c
index 8beafa08d3927e943a94279f5d776d6a45c673c5..1e799433395afa935b5ac1454c299ae873873893 100644 (file)
--- a/pretty.c
+++ b/pretty.c
static char *replace_encoding_header(char *buf, const char *encoding)
{
- struct strbuf tmp;
+ struct strbuf tmp = STRBUF_INIT;
size_t start, len;
char *cp = buf;
return buf; /* should not happen but be defensive */
len = cp + 1 - (buf + start);
- strbuf_init(&tmp, 0);
strbuf_attach(&tmp, buf, strlen(buf), strlen(buf) + 1);
if (is_encoding_utf8(encoding)) {
/* we have re-coded to UTF-8; drop the header */
diff --git a/read-cache.c b/read-cache.c
index 6f344f345d09b36e379cbc8beb2c3992c6d5809c..c229fd4d0da68b204e81e1e8127f8529abe06336 100644 (file)
--- a/read-cache.c
+++ b/read-cache.c
/* Write extension data here */
if (istate->cache_tree) {
- struct strbuf sb;
+ struct strbuf sb = STRBUF_INIT;
- strbuf_init(&sb, 0);
cache_tree_write(&sb, istate->cache_tree);
err = write_index_ext_header(&c, newfd, CACHE_EXT_TREE, sb.len) < 0
|| ce_write(&c, newfd, sb.buf, sb.len) < 0;
diff --git a/remote.c b/remote.c
index a2d7ab146ed6627cae5c845ef4801963635bf395..d5efadd93d63b2c39176763eb325ecddb6c1215a 100644 (file)
--- a/remote.c
+++ b/remote.c
{
const char *slash = strchr(remote->name, '/');
char *frag;
- struct strbuf branch;
+ struct strbuf branch = STRBUF_INIT;
int n = slash ? slash - remote->name : 1000;
FILE *f = fopen(git_path("branches/%.*s", n, remote->name), "r");
char *s, *p;
* #branch specified. The "master" (or specified) branch is
* fetched and stored in the local branch of the same name.
*/
- strbuf_init(&branch, 0);
frag = strchr(p, '#');
if (frag) {
*(frag++) = '\0';
diff --git a/rerere.c b/rerere.c
index 121f9114140708efd36bd4bd1b375f5ad0c558bc..5bb5316cdae16154fd4aaffe996710c0bcfc0b94 100644 (file)
--- a/rerere.c
+++ b/rerere.c
enum {
RR_CONTEXT = 0, RR_SIDE_1, RR_SIDE_2, RR_ORIGINAL,
} hunk = RR_CONTEXT;
- struct strbuf one, two;
+ struct strbuf one = STRBUF_INIT, two = STRBUF_INIT;
FILE *f = fopen(path, "r");
FILE *out = NULL;
if (sha1)
git_SHA1_Init(&ctx);
- strbuf_init(&one, 0);
- strbuf_init(&two, 0);
while (fgets(buf, sizeof(buf), f)) {
if (!prefixcmp(buf, "<<<<<<< ")) {
if (hunk != RR_CONTEXT)
diff --git a/sha1_file.c b/sha1_file.c
index ea6bd996b2953e876a02fcf972229c97cb7d590a..3fbb0820a0e01faa1d9786d5fbeb8b4d1b6e591d 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
* Convert blobs to git internal format
*/
if ((type == OBJ_BLOB) && path) {
- struct strbuf nbuf;
- strbuf_init(&nbuf, 0);
+ struct strbuf nbuf = STRBUF_INIT;
if (convert_to_git(path, buf, size, &nbuf,
write_object ? safe_crlf : 0)) {
buf = strbuf_detach(&nbuf, &size);
size_t size = xsize_t(st->st_size);
if (!S_ISREG(st->st_mode)) {
- struct strbuf sbuf;
- strbuf_init(&sbuf, 0);
+ struct strbuf sbuf = STRBUF_INIT;
if (strbuf_read(&sbuf, fd, 4096) >= 0)
ret = index_mem(sha1, sbuf.buf, sbuf.len, write_object,
type, path);
diff --git a/walker.c b/walker.c
index 0e68ee6d2e2fb1b866ecec00c5f6446af366a62e..6b4cf70c6af1289501f72cbde78cd04da57293f3 100644 (file)
--- a/walker.c
+++ b/walker.c
int walker_targets_stdin(char ***target, const char ***write_ref)
{
int targets = 0, targets_alloc = 0;
- struct strbuf buf;
+ struct strbuf buf = STRBUF_INIT;
*target = NULL; *write_ref = NULL;
- strbuf_init(&buf, 0);
while (1) {
char *rf_one = NULL;
char *tg_one;
index 7a7ff130a34942506e6068105ac5946c9404bf18..b1efcd9d753a29d295702b36fb1beba58fb16995 100644 (file)
--- a/ws.c
+++ b/ws.c
/* The returned string should be freed by the caller. */
char *whitespace_error_string(unsigned ws)
{
- struct strbuf err;
- strbuf_init(&err, 0);
+ struct strbuf err = STRBUF_INIT;
if (ws & WS_TRAILING_SPACE)
strbuf_addstr(&err, "trailing whitespace");
if (ws & WS_SPACE_BEFORE_TAB) {
diff --git a/wt-status.c b/wt-status.c
index 7cf890f2433bf622fe8c18faa0b0c89be60ef1db..d2eac36aeaafab2800b4f0802c7db9656c44cdeb 100644 (file)
--- a/wt-status.c
+++ b/wt-status.c
{
const char *c = color(t);
const char *one, *two;
- struct strbuf onebuf, twobuf;
+ struct strbuf onebuf = STRBUF_INIT, twobuf = STRBUF_INIT;
- strbuf_init(&onebuf, 0);
- strbuf_init(&twobuf, 0);
one = quote_path(p->one->path, -1, &onebuf, s->prefix);
two = quote_path(p->two->path, -1, &twobuf, s->prefix);
static void wt_status_print_initial(struct wt_status *s)
{
int i;
- struct strbuf buf;
+ struct strbuf buf = STRBUF_INIT;
- strbuf_init(&buf, 0);
if (active_nr) {
s->commitable = 1;
wt_status_print_cached_header(s);
struct dir_struct dir;
int i;
int shown_header = 0;
- struct strbuf buf;
+ struct strbuf buf = STRBUF_INIT;
- strbuf_init(&buf, 0);
memset(&dir, 0, sizeof(dir));
if (!s->untracked) {