summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-10-05 13:48:19 +0900
committerJunio C Hamano <gitster@pobox.com>2017-10-05 13:48:19 +0900
commite46ebc27547e3d09385a76ade7ab11dc794f7595 (patch)
tree30cb7479169551ea70b0efaf87881d1a0001b6d1
parentefe9d6ce33ed817150f4ff63ebfc14a3f7667eb4 (diff)
parent38bdf62b738bb93f7e1a6af8058dc31f27c91d4e (diff)
downloadgit-e46ebc27547e3d09385a76ade7ab11dc794f7595.tar.gz
Merge branch 'rs/cleanup-strbuf-users'
Code clean-up. * rs/cleanup-strbuf-users: graph: use strbuf_addchars() to add spaces use strbuf_addstr() for adding strings to strbufs path: use strbuf_add_real_path()
-rw-r--r--builtin/branch.c2
-rw-r--r--graph.c10
-rw-r--r--path.c2
-rw-r--r--refs/packed-backend.c4
-rw-r--r--sequencer.c2
5 files changed, 8 insertions, 12 deletions
diff --git a/builtin/branch.c b/builtin/branch.c
index b998e16d0c..89e34e9ceb 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -353,7 +353,7 @@ static char *build_format(struct ref_filter *filter, int maxwidth, const char *r
strbuf_addf(&obname, "%%(objectname:short=%d)", filter->abbrev);
strbuf_addf(&local, "%%(align:%d,left)%%(refname:lstrip=2)%%(end)", maxwidth);
- strbuf_addf(&local, "%s", branch_get_color(BRANCH_COLOR_RESET));
+ strbuf_addstr(&local, branch_get_color(BRANCH_COLOR_RESET));
strbuf_addf(&local, " %s ", obname.buf);
if (filter->verbose > 1)
diff --git a/graph.c b/graph.c
index e7e20650da..e1f6d3bddb 100644
--- a/graph.c
+++ b/graph.c
@@ -696,12 +696,8 @@ static void graph_pad_horizontally(struct git_graph *graph, struct strbuf *sb,
* This way, fields printed to the right of the graph will remain
* aligned for the entire commit.
*/
- int extra;
- if (chars_written >= graph->width)
- return;
-
- extra = graph->width - chars_written;
- strbuf_addf(sb, "%*s", (int) extra, "");
+ if (chars_written < graph->width)
+ strbuf_addchars(sb, ' ', graph->width - chars_written);
}
static void graph_output_padding_line(struct git_graph *graph,
@@ -787,7 +783,7 @@ static void graph_output_pre_commit_line(struct git_graph *graph,
if (col->commit == graph->commit) {
seen_this = 1;
strbuf_write_column(sb, col, '|');
- strbuf_addf(sb, "%*s", graph->expansion_row, "");
+ strbuf_addchars(sb, ' ', graph->expansion_row);
chars_written += 1 + graph->expansion_row;
} else if (seen_this && (graph->expansion_row == 0)) {
/*
diff --git a/path.c b/path.c
index 5aa9244eb2..00ec04e7a5 100644
--- a/path.c
+++ b/path.c
@@ -718,7 +718,7 @@ char *expand_user_path(const char *path, int real_home)
if (!home)
goto return_null;
if (real_home)
- strbuf_addstr(&user_path, real_path(home));
+ strbuf_add_real_path(&user_path, home);
else
strbuf_addstr(&user_path, home);
#ifdef GIT_WINDOWS_NATIVE
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index 6e85b0bf0b..3279d42c5a 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -1233,8 +1233,8 @@ static int write_with_updates(struct packed_ref_store *refs,
}
if (ok != ITER_DONE) {
- strbuf_addf(err, "unable to write packed-refs file: "
- "error iterating over old contents");
+ strbuf_addstr(err, "unable to write packed-refs file: "
+ "error iterating over old contents");
goto error;
}
diff --git a/sequencer.c b/sequencer.c
index b8c1e876fa..7886e2269e 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -204,7 +204,7 @@ int sequencer_remove_state(struct replay_opts *opts)
free(opts->xopts[i]);
free(opts->xopts);
- strbuf_addf(&dir, "%s", get_dir(opts));
+ strbuf_addstr(&dir, get_dir(opts));
remove_dir_recursively(&dir, 0);
strbuf_release(&dir);