Skip to content

Commit a6c9e0b

Browse files
committed
tree-wide: mark local functions as static
We've accumulated quite some functions which are never used outside of their respective code unit, but which are lacking the `static` keyword. Add it to reduce their linkage scope and allow the compiler to optimize better.
1 parent 7c499b5 commit a6c9e0b

File tree

20 files changed

+59
-61
lines changed

20 files changed

+59
-61
lines changed

src/checkout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ static int checkout_conflictdata_cmp(const void *a, const void *b)
806806
return diff;
807807
}
808808

809-
int checkout_conflictdata_empty(
809+
static int checkout_conflictdata_empty(
810810
const git_vector *conflicts, size_t idx, void *payload)
811811
{
812812
checkout_conflictdata *conflict;

src/config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ static int multivar_iter_next(git_config_entry **entry, git_config_iterator *_it
10001000
return error;
10011001
}
10021002

1003-
void multivar_iter_free(git_config_iterator *_iter)
1003+
static void multivar_iter_free(git_config_iterator *_iter)
10041004
{
10051005
multivar_iter *iter = (multivar_iter *) _iter;
10061006

src/diff.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ int git_diff_foreach(
150150
return error;
151151
}
152152

153-
int git_diff_format_email__append_header_tobuf(
153+
static int diff_format_email_append_header_tobuf(
154154
git_buf *out,
155155
const git_oid *id,
156156
const git_signature *author,
@@ -207,7 +207,7 @@ int git_diff_format_email__append_header_tobuf(
207207
return error;
208208
}
209209

210-
int git_diff_format_email__append_patches_tobuf(
210+
static int diff_format_email_append_patches_tobuf(
211211
git_buf *out,
212212
git_diff *diff)
213213
{
@@ -287,7 +287,7 @@ int git_diff_format_email(
287287
strncpy(summary, opts->summary, offset);
288288
}
289289

290-
error = git_diff_format_email__append_header_tobuf(out,
290+
error = diff_format_email_append_header_tobuf(out,
291291
opts->id, opts->author, summary == NULL ? opts->summary : summary,
292292
opts->body, opts->patch_no, opts->total_patches, ignore_marker);
293293

@@ -300,7 +300,7 @@ int git_diff_format_email(
300300
(error = git_diff_get_stats(&stats, diff)) < 0 ||
301301
(error = git_diff_stats_to_buf(out, stats, format_flags, 0)) < 0 ||
302302
(error = git_buf_putc(out, '\n')) < 0 ||
303-
(error = git_diff_format_email__append_patches_tobuf(out, diff)) < 0)
303+
(error = diff_format_email_append_patches_tobuf(out, diff)) < 0)
304304
goto on_error;
305305

306306
error = git_buf_puts(out, "--\nlibgit2 " LIBGIT2_VERSION "\n\n");
@@ -421,7 +421,7 @@ static void strip_spaces(git_buf *buf)
421421
git_buf_truncate(buf, len);
422422
}
423423

424-
int git_diff_patchid_print_callback__to_buf(
424+
static int diff_patchid_print_callback_to_buf(
425425
const git_diff_delta *delta,
426426
const git_diff_hunk *hunk,
427427
const git_diff_line *line,
@@ -480,7 +480,7 @@ int git_diff_patchid(git_oid *out, git_diff *diff, git_diff_patchid_options *opt
480480

481481
if ((error = git_diff_print(diff,
482482
GIT_DIFF_FORMAT_PATCH_ID,
483-
git_diff_patchid_print_callback__to_buf,
483+
diff_patchid_print_callback_to_buf,
484484
&args)) < 0)
485485
goto out;
486486

src/diff_generate.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,14 @@ GIT_INLINE(const char *) diff_delta__i2w_path(const git_diff_delta *delta)
301301
delta->old_file.path : delta->new_file.path;
302302
}
303303

304-
int git_diff_delta__i2w_cmp(const void *a, const void *b)
304+
static int diff_delta_i2w_cmp(const void *a, const void *b)
305305
{
306306
const git_diff_delta *da = a, *db = b;
307307
int val = strcmp(diff_delta__i2w_path(da), diff_delta__i2w_path(db));
308308
return val ? val : ((int)da->status - (int)db->status);
309309
}
310310

311-
int git_diff_delta__i2w_casecmp(const void *a, const void *b)
311+
static int diff_delta_i2w_casecmp(const void *a, const void *b)
312312
{
313313
const git_diff_delta *da = a, *db = b;
314314
int val = strcasecmp(diff_delta__i2w_path(da), diff_delta__i2w_path(db));
@@ -361,7 +361,7 @@ static const char *diff_mnemonic_prefix(
361361
return pfx;
362362
}
363363

364-
void git_diff__set_ignore_case(git_diff *diff, bool ignore_case)
364+
static void diff_set_ignore_case(git_diff *diff, bool ignore_case)
365365
{
366366
if (!ignore_case) {
367367
diff->opts.flags &= ~GIT_DIFF_IGNORE_CASE;
@@ -431,7 +431,7 @@ static git_diff_generated *diff_generated_alloc(
431431

432432
/* Use case-insensitive compare if either iterator has
433433
* the ignore_case bit set */
434-
git_diff__set_ignore_case(
434+
diff_set_ignore_case(
435435
&diff->base,
436436
git_iterator_ignore_case(old_iter) ||
437437
git_iterator_ignore_case(new_iter));
@@ -1375,7 +1375,7 @@ int git_diff_tree_to_index(
13751375

13761376
/* if index is in case-insensitive order, re-sort deltas to match */
13771377
if (index_ignore_case)
1378-
git_diff__set_ignore_case(diff, true);
1378+
diff_set_ignore_case(diff, true);
13791379

13801380
*out = diff;
13811381
diff = NULL;
@@ -1526,7 +1526,7 @@ int git_diff_index_to_index(
15261526

15271527
/* if index is in case-insensitive order, re-sort deltas to match */
15281528
if (old_index->ignore_case || new_index->ignore_case)
1529-
git_diff__set_ignore_case(diff, true);
1529+
diff_set_ignore_case(diff, true);
15301530

15311531
*out = diff;
15321532
diff = NULL;
@@ -1583,10 +1583,10 @@ int git_diff__paired_foreach(
15831583
if (i2w_icase && !icase_mismatch) {
15841584
strcomp = git__strcasecmp;
15851585

1586-
git_vector_set_cmp(&idx2wd->deltas, git_diff_delta__i2w_casecmp);
1586+
git_vector_set_cmp(&idx2wd->deltas, diff_delta_i2w_casecmp);
15871587
git_vector_sort(&idx2wd->deltas);
15881588
} else if (idx2wd != NULL) {
1589-
git_vector_set_cmp(&idx2wd->deltas, git_diff_delta__i2w_cmp);
1589+
git_vector_set_cmp(&idx2wd->deltas, diff_delta_i2w_cmp);
15901590
git_vector_sort(&idx2wd->deltas);
15911591
}
15921592

src/diff_print.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ static int diff_delta_format_with_paths(
337337
return git_buf_printf(out, template, oldpath, newpath);
338338
}
339339

340-
int diff_delta_format_similarity_header(
340+
static int diff_delta_format_similarity_header(
341341
git_buf *out,
342342
const git_diff_delta *delta)
343343
{

src/diff_stats.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static int digits_for_value(size_t val)
4646
return count;
4747
}
4848

49-
int git_diff_file_stats__full_to_buf(
49+
static int diff_file_stats_full_to_buf(
5050
git_buf *out,
5151
const git_diff_delta *delta,
5252
const diff_file_stats *filestat,
@@ -134,7 +134,7 @@ int git_diff_file_stats__full_to_buf(
134134
return (git_buf_oom(out) ? -1 : 0);
135135
}
136136

137-
int git_diff_file_stats__number_to_buf(
137+
static int diff_file_stats_number_to_buf(
138138
git_buf *out,
139139
const git_diff_delta *delta,
140140
const diff_file_stats *filestats)
@@ -151,7 +151,7 @@ int git_diff_file_stats__number_to_buf(
151151
return error;
152152
}
153153

154-
int git_diff_file_stats__summary_to_buf(
154+
static int diff_file_stats_summary_to_buf(
155155
git_buf *out,
156156
const git_diff_delta *delta)
157157
{
@@ -288,7 +288,7 @@ int git_diff_stats_to_buf(
288288
if ((delta = git_diff_get_delta(stats->diff, i)) == NULL)
289289
continue;
290290

291-
error = git_diff_file_stats__number_to_buf(
291+
error = diff_file_stats_number_to_buf(
292292
out, delta, &stats->filestats[i]);
293293
if (error < 0)
294294
return error;
@@ -309,7 +309,7 @@ int git_diff_stats_to_buf(
309309
if ((delta = git_diff_get_delta(stats->diff, i)) == NULL)
310310
continue;
311311

312-
error = git_diff_file_stats__full_to_buf(
312+
error = diff_file_stats_full_to_buf(
313313
out, delta, &stats->filestats[i], stats, width);
314314
if (error < 0)
315315
return error;
@@ -342,7 +342,7 @@ int git_diff_stats_to_buf(
342342
if ((delta = git_diff_get_delta(stats->diff, i)) == NULL)
343343
continue;
344344

345-
error = git_diff_file_stats__summary_to_buf(out, delta);
345+
error = diff_file_stats_summary_to_buf(out, delta);
346346
if (error < 0)
347347
return error;
348348
}

src/filter.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ static int stream_list_init(
941941
return error;
942942
}
943943

944-
void stream_list_free(git_vector *streams)
944+
static void filter_streams_free(git_vector *streams)
945945
{
946946
git_writestream *stream;
947947
size_t i;
@@ -990,7 +990,7 @@ int git_filter_list_stream_file(
990990

991991
if (fd >= 0)
992992
p_close(fd);
993-
stream_list_free(&filter_streams);
993+
filter_streams_free(&filter_streams);
994994
git_buf_dispose(&abspath);
995995
return error;
996996
}
@@ -1018,7 +1018,7 @@ int git_filter_list_stream_data(
10181018
if (initialized)
10191019
error |= stream_start->close(stream_start);
10201020

1021-
stream_list_free(&filter_streams);
1021+
filter_streams_free(&filter_streams);
10221022
return error;
10231023
}
10241024

src/merge.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static int cache_invalid_marker;
8080

8181
/* Merge base computation */
8282

83-
int merge_bases_many(git_commit_list **out, git_revwalk **walk_out, git_repository *repo, size_t length, const git_oid input_array[])
83+
static int merge_bases_many(git_commit_list **out, git_revwalk **walk_out, git_repository *repo, size_t length, const git_oid input_array[])
8484
{
8585
git_revwalk *walk = NULL;
8686
git_vector list;
@@ -2845,7 +2845,7 @@ static int merge_ancestor_head(
28452845
return error;
28462846
}
28472847

2848-
const char *merge_their_label(const char *branchname)
2848+
static const char *merge_their_label(const char *branchname)
28492849
{
28502850
const char *slash;
28512851

src/merge_file.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
#define GIT_MERGE_FILE_SIDE_EXISTS(X) ((X)->mode != 0)
3030

31-
int git_merge_file__input_from_index(
31+
static int merge_file_input_from_index(
3232
git_merge_file_input *input_out,
3333
git_odb_object **odb_object_out,
3434
git_odb *odb,
@@ -276,17 +276,15 @@ int git_merge_file_from_index(
276276
goto done;
277277

278278
if (ancestor) {
279-
if ((error = git_merge_file__input_from_index(
279+
if ((error = merge_file_input_from_index(
280280
&ancestor_input, &odb_object[0], odb, ancestor)) < 0)
281281
goto done;
282282

283283
ancestor_ptr = &ancestor_input;
284284
}
285285

286-
if ((error = git_merge_file__input_from_index(
287-
&our_input, &odb_object[1], odb, ours)) < 0 ||
288-
(error = git_merge_file__input_from_index(
289-
&their_input, &odb_object[2], odb, theirs)) < 0)
286+
if ((error = merge_file_input_from_index(&our_input, &odb_object[1], odb, ours)) < 0 ||
287+
(error = merge_file_input_from_index(&their_input, &odb_object[2], odb, theirs)) < 0)
290288
goto done;
291289

292290
error = merge_file__from_inputs(out,

src/pack-objects.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,7 +1642,7 @@ static int mark_edges_uninteresting(git_packbuilder *pb, git_commit_list *commit
16421642
return 0;
16431643
}
16441644

1645-
int insert_tree(git_packbuilder *pb, git_tree *tree)
1645+
static int pack_objects_insert_tree(git_packbuilder *pb, git_tree *tree)
16461646
{
16471647
size_t i;
16481648
int error;
@@ -1669,7 +1669,7 @@ int insert_tree(git_packbuilder *pb, git_tree *tree)
16691669
if ((error = git_tree_lookup(&subtree, pb->repo, entry_id)) < 0)
16701670
return error;
16711671

1672-
error = insert_tree(pb, subtree);
1672+
error = pack_objects_insert_tree(pb, subtree);
16731673
git_tree_free(subtree);
16741674

16751675
if (error < 0)
@@ -1695,7 +1695,7 @@ int insert_tree(git_packbuilder *pb, git_tree *tree)
16951695
return error;
16961696
}
16971697

1698-
int insert_commit(git_packbuilder *pb, struct walk_object *obj)
1698+
static int pack_objects_insert_commit(git_packbuilder *pb, struct walk_object *obj)
16991699
{
17001700
int error;
17011701
git_commit *commit = NULL;
@@ -1712,7 +1712,7 @@ int insert_commit(git_packbuilder *pb, struct walk_object *obj)
17121712
if ((error = git_tree_lookup(&tree, pb->repo, git_commit_tree_id(commit))) < 0)
17131713
goto cleanup;
17141714

1715-
if ((error = insert_tree(pb, tree)) < 0)
1715+
if ((error = pack_objects_insert_tree(pb, tree)) < 0)
17161716
goto cleanup;
17171717

17181718
cleanup:
@@ -1747,7 +1747,7 @@ int git_packbuilder_insert_walk(git_packbuilder *pb, git_revwalk *walk)
17471747
if (obj->seen || obj->uninteresting)
17481748
continue;
17491749

1750-
if ((error = insert_commit(pb, obj)) < 0)
1750+
if ((error = pack_objects_insert_commit(pb, obj)) < 0)
17511751
return error;
17521752
}
17531753

0 commit comments

Comments
 (0)