Navigation Menu

Skip to content

Commit

Permalink
Merge branch 'jc/make-static'
Browse files Browse the repository at this point in the history
Turn many file-scope private symbols to static to reduce the
global namespace contamination.

* jc/make-static:
  sequencer.c: mark a private file-scope symbol as static
  ident.c: mark private file-scope symbols as static
  trace.c: mark a private file-scope symbol as static
  wt-status.c: mark a private file-scope symbol as static
  read-cache.c: mark a private file-scope symbol as static
  strbuf.c: mark a private file-scope symbol as static
  sha1-array.c: mark a private file-scope symbol as static
  symlinks.c: mark private file-scope symbols as static
  notes.c: mark a private file-scope symbol as static
  rerere.c: mark private file-scope symbols as static
  graph.c: mark private file-scope symbols as static
  diff.c: mark a private file-scope symbol as static
  commit.c: mark a file-scope private symbol as static
  builtin/notes.c: mark file-scope private symbols as static
  • Loading branch information
gitster committed Sep 18, 2012
2 parents 8db3865 + 250f249 commit 06e211a
Show file tree
Hide file tree
Showing 26 changed files with 69 additions and 96 deletions.
3 changes: 0 additions & 3 deletions Documentation/technical/api-sha1-array.txt
Expand Up @@ -25,9 +25,6 @@ Functions
the array (but note that some operations below may lose this
ordering).

`sha1_array_sort`::
Sort the elements in the array.

`sha1_array_lookup`::
Perform a binary search of the array for a specific sha1.
If found, returns the offset (in number of elements) of the
Expand Down
2 changes: 0 additions & 2 deletions builtin.h
Expand Up @@ -21,7 +21,6 @@ struct fmt_merge_msg_opts {

extern int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
struct fmt_merge_msg_opts *);
extern void commit_notes(struct notes_tree *t, const char *msg);

struct notes_rewrite_cfg {
struct notes_tree **trees;
Expand All @@ -33,7 +32,6 @@ struct notes_rewrite_cfg {
int mode_from_env;
};

combine_notes_fn parse_combine_notes_fn(const char *v);
struct notes_rewrite_cfg *init_copy_notes_for_rewrite(const char *cmd);
int copy_note_for_rewrite(struct notes_rewrite_cfg *c,
const unsigned char *from_obj, const unsigned char *to_obj);
Expand Down
7 changes: 5 additions & 2 deletions builtin/notes.c
Expand Up @@ -19,6 +19,9 @@
#include "string-list.h"
#include "notes-merge.h"

static void commit_notes(struct notes_tree *t, const char *msg);
static combine_notes_fn parse_combine_notes_fn(const char *v);

static const char * const git_notes_usage[] = {
N_("git notes [--ref <notes_ref>] [list [<object>]]"),
N_("git notes [--ref <notes_ref>] add [-f] [-m <msg> | -F <file> | (-c | -C) <object>] [<object>]"),
Expand Down Expand Up @@ -288,7 +291,7 @@ static int parse_reedit_arg(const struct option *opt, const char *arg, int unset
return parse_reuse_arg(opt, arg, unset);
}

void commit_notes(struct notes_tree *t, const char *msg)
static void commit_notes(struct notes_tree *t, const char *msg)
{
struct strbuf buf = STRBUF_INIT;
unsigned char commit_sha1[20];
Expand All @@ -312,7 +315,7 @@ void commit_notes(struct notes_tree *t, const char *msg)
strbuf_release(&buf);
}

combine_notes_fn parse_combine_notes_fn(const char *v)
static combine_notes_fn parse_combine_notes_fn(const char *v)
{
if (!strcasecmp(v, "overwrite"))
return combine_notes_overwrite;
Expand Down
6 changes: 0 additions & 6 deletions cache.h
Expand Up @@ -442,7 +442,6 @@ extern int discard_index(struct index_state *);
extern int unmerged_index(const struct index_state *);
extern int verify_path(const char *path);
extern struct cache_entry *index_name_exists(struct index_state *istate, const char *name, int namelen, int igncase);
extern int index_name_stage_pos(const struct index_state *, const char *name, int namelen, int stage);
extern int index_name_pos(const struct index_state *, const char *name, int namelen);
#define ADD_CACHE_OK_TO_ADD 1 /* Ok to add */
#define ADD_CACHE_OK_TO_REPLACE 2 /* Ok to replace file/directory */
Expand Down Expand Up @@ -902,9 +901,7 @@ extern const char *git_author_info(int);
extern const char *git_committer_info(int);
extern const char *fmt_ident(const char *name, const char *email, const char *date_str, int);
extern const char *fmt_name(const char *name, const char *email);
extern const char *ident_default_name(void);
extern const char *ident_default_email(void);
extern const char *ident_default_date(void);
extern const char *git_editor(void);
extern const char *git_pager(int stdout_is_tty);
extern int git_ident_config(const char *, const char *, void *);
Expand Down Expand Up @@ -947,9 +944,7 @@ struct cache_def {
extern int has_symlink_leading_path(const char *name, int len);
extern int threaded_has_symlink_leading_path(struct cache_def *, const char *, int);
extern int check_leading_path(const char *name, int len);
extern int threaded_check_leading_path(struct cache_def *cache, const char *name, int len);
extern int has_dirs_only_path(const char *name, int len, int prefix_len);
extern int threaded_has_dirs_only_path(struct cache_def *cache, const char *name, int len, int prefix_len);
extern void schedule_dir_for_removal(const char *name, int len);
extern void remove_scheduled_dirs(void);

Expand Down Expand Up @@ -1208,7 +1203,6 @@ extern void alloc_report(void);
/* trace.c */
__attribute__((format (printf, 1, 2)))
extern void trace_printf(const char *format, ...);
extern void trace_vprintf(const char *key, const char *format, va_list ap);
__attribute__((format (printf, 2, 3)))
extern void trace_argv_printf(const char **argv, const char *format, ...);
extern void trace_repo_setup(const char *prefix);
Expand Down
7 changes: 5 additions & 2 deletions commit.c
Expand Up @@ -9,6 +9,8 @@
#include "gpg-interface.h"
#include "mergesort.h"

static struct commit_extra_header *read_commit_extra_header_lines(const char *buf, size_t len, const char **);

int save_commit_buffer = 1;

const char *commit_type = "commit";
Expand Down Expand Up @@ -1073,8 +1075,9 @@ static int excluded_header_field(const char *field, size_t len, const char **exc
return 0;
}

struct commit_extra_header *read_commit_extra_header_lines(const char *buffer, size_t size,
const char **exclude)
static struct commit_extra_header *read_commit_extra_header_lines(
const char *buffer, size_t size,
const char **exclude)
{
struct commit_extra_header *extra = NULL, **tail = &extra, *it = NULL;
const char *line, *next, *eof, *eob;
Expand Down
1 change: 0 additions & 1 deletion commit.h
Expand Up @@ -204,7 +204,6 @@ extern int commit_tree_extended(const struct strbuf *msg, unsigned char *tree,
struct commit_extra_header *);

extern struct commit_extra_header *read_commit_extra_headers(struct commit *, const char **);
extern struct commit_extra_header *read_commit_extra_header_lines(const char *buf, size_t len, const char **);

extern void free_commit_extra_headers(struct commit_extra_header *extra);

Expand Down
2 changes: 1 addition & 1 deletion diff.c
Expand Up @@ -25,7 +25,7 @@
static int diff_detect_rename_default;
static int diff_rename_limit_default = 400;
static int diff_suppress_blank_empty;
int diff_use_color_default = -1;
static int diff_use_color_default = -1;
static const char *diff_word_regex_cfg;
static const char *external_diff_cmd_cfg;
int diff_auto_refresh_index = 1;
Expand Down
1 change: 0 additions & 1 deletion diff.h
Expand Up @@ -243,7 +243,6 @@ extern int parse_long_opt(const char *opt, const char **argv,

extern int git_diff_basic_config(const char *var, const char *value, void *cb);
extern int git_diff_ui_config(const char *var, const char *value, void *cb);
extern int diff_use_color_default;
extern void diff_setup(struct diff_options *);
extern int diff_opt_parse(struct diff_options *, const char **, int);
extern void diff_setup_done(struct diff_options *);
Expand Down
32 changes: 30 additions & 2 deletions graph.c
Expand Up @@ -7,6 +7,34 @@

/* Internal API */

/*
* Output the next line for a graph.
* This formats the next graph line into the specified strbuf. It is not
* terminated with a newline.
*
* Returns 1 if the line includes the current commit, and 0 otherwise.
* graph_next_line() will return 1 exactly once for each time
* graph_update() is called.
*/
static int graph_next_line(struct git_graph *graph, struct strbuf *sb);

/*
* Set up a custom scheme for column colors.
*
* The default column color scheme inserts ANSI color escapes to colorize
* the graph. The various color escapes are stored in an array of strings
* where each entry corresponds to a color, except for the last entry,
* which denotes the escape for resetting the color back to the default.
* When generating the graph, strings from this array are inserted before
* and after the various column characters.
*
* This function allows you to enable a custom array of color escapes.
* The 'colors_max' argument is the index of the last "reset" entry.
*
* This functions must be called BEFORE graph_init() is called.
*/
static void graph_set_column_colors(const char **colors, unsigned short colors_max);

/*
* Output a padding line in the graph.
* This is similar to graph_next_line(). However, it is guaranteed to
Expand Down Expand Up @@ -62,7 +90,7 @@ enum graph_state {
static const char **column_colors;
static unsigned short column_colors_max;

void graph_set_column_colors(const char **colors, unsigned short colors_max)
static void graph_set_column_colors(const char **colors, unsigned short colors_max)
{
column_colors = colors;
column_colors_max = colors_max;
Expand Down Expand Up @@ -1116,7 +1144,7 @@ static void graph_output_collapsing_line(struct git_graph *graph, struct strbuf
graph_update_state(graph, GRAPH_PADDING);
}

int graph_next_line(struct git_graph *graph, struct strbuf *sb)
static int graph_next_line(struct git_graph *graph, struct strbuf *sb)
{
switch (graph->state) {
case GRAPH_PADDING:
Expand Down
27 changes: 0 additions & 27 deletions graph.h
Expand Up @@ -4,22 +4,6 @@
/* A graph is a pointer to this opaque structure */
struct git_graph;

/*
* Set up a custom scheme for column colors.
*
* The default column color scheme inserts ANSI color escapes to colorize
* the graph. The various color escapes are stored in an array of strings
* where each entry corresponds to a color, except for the last entry,
* which denotes the escape for resetting the color back to the default.
* When generating the graph, strings from this array are inserted before
* and after the various column characters.
*
* This function allows you to enable a custom array of color escapes.
* The 'colors_max' argument is the index of the last "reset" entry.
*
* This functions must be called BEFORE graph_init() is called.
*/
void graph_set_column_colors(const char **colors, unsigned short colors_max);

/*
* Create a new struct git_graph.
Expand Down Expand Up @@ -49,17 +33,6 @@ void graph_update(struct git_graph *graph, struct commit *commit);
*/
int graph_is_commit_finished(struct git_graph const *graph);

/*
* Output the next line for a graph.
* This formats the next graph line into the specified strbuf. It is not
* terminated with a newline.
*
* Returns 1 if the line includes the current commit, and 0 otherwise.
* graph_next_line() will return 1 exactly once for each time
* graph_update() is called.
*/
int graph_next_line(struct git_graph *graph, struct strbuf *sb);


/*
* graph_show_*: helper functions for printing to stdout
Expand Down
4 changes: 2 additions & 2 deletions ident.c
Expand Up @@ -93,7 +93,7 @@ static void copy_email(const struct passwd *pw, struct strbuf *email)
add_domainname(email);
}

const char *ident_default_name(void)
static const char *ident_default_name(void)
{
if (!git_default_name.len) {
copy_gecos(xgetpwuid_self(), &git_default_name);
Expand All @@ -117,7 +117,7 @@ const char *ident_default_email(void)
return git_default_email.buf;
}

const char *ident_default_date(void)
static const char *ident_default_date(void)
{
if (!git_default_date[0])
datestamp(git_default_date, sizeof(git_default_date));
Expand Down
14 changes: 12 additions & 2 deletions notes.c
Expand Up @@ -1196,8 +1196,18 @@ void free_notes(struct notes_tree *t)
memset(t, 0, sizeof(struct notes_tree));
}

void format_note(struct notes_tree *t, const unsigned char *object_sha1,
struct strbuf *sb, const char *output_encoding, int flags)
/*
* Fill the given strbuf with the notes associated with the given object.
*
* If the given notes_tree structure is not initialized, it will be auto-
* initialized to the default value (see documentation for init_notes() above).
* If the given notes_tree is NULL, the internal/default notes_tree will be
* used instead.
*
* 'flags' is a bitwise combination of the flags for format_display_notes.
*/
static void format_note(struct notes_tree *t, const unsigned char *object_sha1,
struct strbuf *sb, const char *output_encoding, int flags)
{
static const char utf8[] = "utf-8";
const unsigned char *sha1;
Expand Down
14 changes: 0 additions & 14 deletions notes.h
Expand Up @@ -241,20 +241,6 @@ void free_notes(struct notes_tree *t);
#define NOTES_SHOW_HEADER 1
#define NOTES_INDENT 2

/*
* Fill the given strbuf with the notes associated with the given object.
*
* If the given notes_tree structure is not initialized, it will be auto-
* initialized to the default value (see documentation for init_notes() above).
* If the given notes_tree is NULL, the internal/default notes_tree will be
* used instead.
*
* 'flags' is a bitwise combination of the above formatting flags.
*/
void format_note(struct notes_tree *t, const unsigned char *object_sha1,
struct strbuf *sb, const char *output_encoding, int flags);


struct string_list;

struct display_notes_opt {
Expand Down
2 changes: 1 addition & 1 deletion read-cache.c
Expand Up @@ -424,7 +424,7 @@ int cache_name_compare(const char *name1, int len1, const char *name2, int len2)
return cache_name_stage_compare(name1, len1, 0, name2, len2, 0);
}

int index_name_stage_pos(const struct index_state *istate, const char *name, int namelen, int stage)
static int index_name_stage_pos(const struct index_state *istate, const char *name, int namelen, int stage)
{
int first, last;

Expand Down
2 changes: 1 addition & 1 deletion rerere.c
Expand Up @@ -25,7 +25,7 @@ const char *rerere_path(const char *hex, const char *file)
return git_path("rr-cache/%s/%s", hex, file);
}

int has_rerere_resolution(const char *hex)
static int has_rerere_resolution(const char *hex)
{
struct stat st;
return !stat(rerere_path(hex, "postimage"), &st);
Expand Down
1 change: 0 additions & 1 deletion rerere.h
Expand Up @@ -16,7 +16,6 @@ extern void *RERERE_RESOLVED;
extern int setup_rerere(struct string_list *, int);
extern int rerere(int);
extern const char *rerere_path(const char *hex, const char *file);
extern int has_rerere_resolution(const char *hex);
extern int rerere_forget(const char **);
extern int rerere_remaining(struct string_list *);
extern void rerere_clear(struct string_list *);
Expand Down
2 changes: 1 addition & 1 deletion sequencer.c
Expand Up @@ -19,7 +19,7 @@

const char sign_off_header[] = "Signed-off-by: ";

void remove_sequencer_state(void)
static void remove_sequencer_state(void)
{
struct strbuf seq_dir = STRBUF_INIT;

Expand Down
3 changes: 0 additions & 3 deletions sequencer.h
Expand Up @@ -44,9 +44,6 @@ struct replay_opts {
struct rev_info *revs;
};

/* Removes SEQ_DIR. */
extern void remove_sequencer_state(void);

int sequencer_pick_revisions(struct replay_opts *opts);

extern const char sign_off_header[];
Expand Down
2 changes: 1 addition & 1 deletion sha1-array.c
Expand Up @@ -14,7 +14,7 @@ static int void_hashcmp(const void *a, const void *b)
return hashcmp(a, b);
}

void sha1_array_sort(struct sha1_array *array)
static void sha1_array_sort(struct sha1_array *array)
{
qsort(array->sha1, array->nr, sizeof(*array->sha1), void_hashcmp);
array->sorted = 1;
Expand Down
1 change: 0 additions & 1 deletion sha1-array.h
Expand Up @@ -11,7 +11,6 @@ struct sha1_array {
#define SHA1_ARRAY_INIT { NULL, 0, 0, 0 }

void sha1_array_append(struct sha1_array *array, const unsigned char *sha1);
void sha1_array_sort(struct sha1_array *array);
int sha1_array_lookup(struct sha1_array *array, const unsigned char *sha1);
void sha1_array_clear(struct sha1_array *array);

Expand Down
13 changes: 2 additions & 11 deletions strbuf.c
Expand Up @@ -445,8 +445,8 @@ static int is_rfc3986_unreserved(char ch)
ch == '-' || ch == '_' || ch == '.' || ch == '~';
}

void strbuf_add_urlencode(struct strbuf *sb, const char *s, size_t len,
int reserved)
static void strbuf_add_urlencode(struct strbuf *sb, const char *s, size_t len,
int reserved)
{
strbuf_grow(sb, len);
while (len--) {
Expand All @@ -465,15 +465,6 @@ void strbuf_addstr_urlencode(struct strbuf *sb, const char *s,
strbuf_add_urlencode(sb, s, strlen(s), reserved);
}

void strbuf_addf_ln(struct strbuf *sb, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
strbuf_vaddf(sb, fmt, ap);
va_end(ap);
strbuf_addch(sb, '\n');
}

int printf_ln(const char *fmt, ...)
{
int ret;
Expand Down
4 changes: 0 additions & 4 deletions strbuf.h
Expand Up @@ -99,8 +99,6 @@ __attribute__((format (printf,2,3)))
extern void strbuf_addf(struct strbuf *sb, const char *fmt, ...);
__attribute__((format (printf,2,0)))
extern void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap);
__attribute__((format (printf,2,3)))
extern void strbuf_addf_ln(struct strbuf *sb, const char *fmt, ...);

extern void strbuf_add_lines(struct strbuf *sb, const char *prefix, const char *buf, size_t size);

Expand All @@ -126,8 +124,6 @@ extern int launch_editor(const char *path, struct strbuf *buffer, const char *co
extern int strbuf_branchname(struct strbuf *sb, const char *name);
extern int strbuf_check_branch_ref(struct strbuf *sb, const char *name);

extern void strbuf_add_urlencode(struct strbuf *, const char *, size_t,
int reserved);
extern void strbuf_addstr_urlencode(struct strbuf *, const char *,
int reserved);

Expand Down

0 comments on commit 06e211a

Please sign in to comment.