diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-10-05 13:48:19 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-10-05 13:48:19 +0900 |
commit | e46ebc27547e3d09385a76ade7ab11dc794f7595 (patch) | |
tree | 30cb7479169551ea70b0efaf87881d1a0001b6d1 | |
parent | Merge branch 'rs/resolve-ref-optional-result' (diff) | |
parent | graph: use strbuf_addchars() to add spaces (diff) | |
download | tgif-e46ebc27547e3d09385a76ade7ab11dc794f7595.tar.xz |
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.c | 2 | ||||
-rw-r--r-- | graph.c | 10 | ||||
-rw-r--r-- | path.c | 2 | ||||
-rw-r--r-- | refs/packed-backend.c | 4 | ||||
-rw-r--r-- | sequencer.c | 2 |
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) @@ -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)) { /* @@ -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); |