Skip to content

Commit e46ebc2

Browse files
committed
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()
2 parents efe9d6c + 38bdf62 commit e46ebc2

File tree

5 files changed

+8
-12
lines changed

5 files changed

+8
-12
lines changed

builtin/branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ static char *build_format(struct ref_filter *filter, int maxwidth, const char *r
353353
strbuf_addf(&obname, "%%(objectname:short=%d)", filter->abbrev);
354354

355355
strbuf_addf(&local, "%%(align:%d,left)%%(refname:lstrip=2)%%(end)", maxwidth);
356-
strbuf_addf(&local, "%s", branch_get_color(BRANCH_COLOR_RESET));
356+
strbuf_addstr(&local, branch_get_color(BRANCH_COLOR_RESET));
357357
strbuf_addf(&local, " %s ", obname.buf);
358358

359359
if (filter->verbose > 1)

graph.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -696,12 +696,8 @@ static void graph_pad_horizontally(struct git_graph *graph, struct strbuf *sb,
696696
* This way, fields printed to the right of the graph will remain
697697
* aligned for the entire commit.
698698
*/
699-
int extra;
700-
if (chars_written >= graph->width)
701-
return;
702-
703-
extra = graph->width - chars_written;
704-
strbuf_addf(sb, "%*s", (int) extra, "");
699+
if (chars_written < graph->width)
700+
strbuf_addchars(sb, ' ', graph->width - chars_written);
705701
}
706702

707703
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,
787783
if (col->commit == graph->commit) {
788784
seen_this = 1;
789785
strbuf_write_column(sb, col, '|');
790-
strbuf_addf(sb, "%*s", graph->expansion_row, "");
786+
strbuf_addchars(sb, ' ', graph->expansion_row);
791787
chars_written += 1 + graph->expansion_row;
792788
} else if (seen_this && (graph->expansion_row == 0)) {
793789
/*

path.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ char *expand_user_path(const char *path, int real_home)
718718
if (!home)
719719
goto return_null;
720720
if (real_home)
721-
strbuf_addstr(&user_path, real_path(home));
721+
strbuf_add_real_path(&user_path, home);
722722
else
723723
strbuf_addstr(&user_path, home);
724724
#ifdef GIT_WINDOWS_NATIVE

refs/packed-backend.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,8 +1233,8 @@ static int write_with_updates(struct packed_ref_store *refs,
12331233
}
12341234

12351235
if (ok != ITER_DONE) {
1236-
strbuf_addf(err, "unable to write packed-refs file: "
1237-
"error iterating over old contents");
1236+
strbuf_addstr(err, "unable to write packed-refs file: "
1237+
"error iterating over old contents");
12381238
goto error;
12391239
}
12401240

sequencer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ int sequencer_remove_state(struct replay_opts *opts)
204204
free(opts->xopts[i]);
205205
free(opts->xopts);
206206

207-
strbuf_addf(&dir, "%s", get_dir(opts));
207+
strbuf_addstr(&dir, get_dir(opts));
208208
remove_dir_recursively(&dir, 0);
209209
strbuf_release(&dir);
210210

0 commit comments

Comments
 (0)