Merge branch 'cw/strbuf-cleanup'
Move functions that are not about pure string manipulation out of strbuf.[ch] * cw/strbuf-cleanup: strbuf: remove global variable path: move related function to path object-name: move related functions to object-name credential-store: move related functions to credential-store file abspath: move related functions to abspath strbuf: clarify dependency strbuf: clarify API boundary
This commit is contained in:
57
strbuf.h
57
strbuf.h
@ -1,6 +1,14 @@
|
||||
#ifndef STRBUF_H
|
||||
#define STRBUF_H
|
||||
|
||||
/*
|
||||
* NOTE FOR STRBUF DEVELOPERS
|
||||
*
|
||||
* strbuf is a low-level primitive; as such it should interact only
|
||||
* with other low-level primitives. Do not introduce new functions
|
||||
* which interact with higher-level APIs.
|
||||
*/
|
||||
|
||||
struct string_list;
|
||||
|
||||
/**
|
||||
@ -279,7 +287,8 @@ void strbuf_splice(struct strbuf *sb, size_t pos, size_t len,
|
||||
* by a comment character and a blank.
|
||||
*/
|
||||
void strbuf_add_commented_lines(struct strbuf *out,
|
||||
const char *buf, size_t size);
|
||||
const char *buf, size_t size,
|
||||
char comment_line_char);
|
||||
|
||||
|
||||
/**
|
||||
@ -369,8 +378,8 @@ void strbuf_addf(struct strbuf *sb, const char *fmt, ...);
|
||||
* Add a formatted string prepended by a comment character and a
|
||||
* blank to the buffer.
|
||||
*/
|
||||
__attribute__((format (printf, 2, 3)))
|
||||
void strbuf_commented_addf(struct strbuf *sb, const char *fmt, ...);
|
||||
__attribute__((format (printf, 3, 4)))
|
||||
void strbuf_commented_addf(struct strbuf *sb, char comment_line_char, const char *fmt, ...);
|
||||
|
||||
__attribute__((format (printf,2,0)))
|
||||
void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap);
|
||||
@ -496,28 +505,6 @@ int strbuf_getwholeline_fd(struct strbuf *sb, int fd, int term);
|
||||
*/
|
||||
int strbuf_getcwd(struct strbuf *sb);
|
||||
|
||||
/**
|
||||
* Add a path to a buffer, converting a relative path to an
|
||||
* absolute one in the process. Symbolic links are not
|
||||
* resolved.
|
||||
*/
|
||||
void strbuf_add_absolute_path(struct strbuf *sb, const char *path);
|
||||
|
||||
/**
|
||||
* Canonize `path` (make it absolute, resolve symlinks, remove extra
|
||||
* slashes) and append it to `sb`. Die with an informative error
|
||||
* message if there is a problem.
|
||||
*
|
||||
* The directory part of `path` (i.e., everything up to the last
|
||||
* dir_sep) must denote a valid, existing directory, but the last
|
||||
* component need not exist.
|
||||
*
|
||||
* Callers that don't mind links should use the more lightweight
|
||||
* strbuf_add_absolute_path() instead.
|
||||
*/
|
||||
void strbuf_add_real_path(struct strbuf *sb, const char *path);
|
||||
|
||||
|
||||
/**
|
||||
* Normalize in-place the path contained in the strbuf. See
|
||||
* normalize_path_copy() for details. If an error occurs, the contents of "sb"
|
||||
@ -526,10 +513,11 @@ void strbuf_add_real_path(struct strbuf *sb, const char *path);
|
||||
int strbuf_normalize_path(struct strbuf *sb);
|
||||
|
||||
/**
|
||||
* Strip whitespace from a buffer. The second parameter controls if
|
||||
* comments are considered contents to be removed or not.
|
||||
* Strip whitespace from a buffer. If comment_line_char is non-NUL,
|
||||
* then lines beginning with that character are considered comments,
|
||||
* thus removed.
|
||||
*/
|
||||
void strbuf_stripspace(struct strbuf *buf, int skip_comments);
|
||||
void strbuf_stripspace(struct strbuf *buf, char comment_line_char);
|
||||
|
||||
static inline int strbuf_strip_suffix(struct strbuf *sb, const char *suffix)
|
||||
{
|
||||
@ -599,16 +587,6 @@ void strbuf_add_separated_string_list(struct strbuf *str,
|
||||
*/
|
||||
void strbuf_list_free(struct strbuf **list);
|
||||
|
||||
/**
|
||||
* Add the abbreviation, as generated by repo_find_unique_abbrev(), of `sha1` to
|
||||
* the strbuf `sb`.
|
||||
*/
|
||||
struct repository;
|
||||
void strbuf_repo_add_unique_abbrev(struct strbuf *sb, struct repository *repo,
|
||||
const struct object_id *oid, int abbrev_len);
|
||||
void strbuf_add_unique_abbrev(struct strbuf *sb, const struct object_id *oid,
|
||||
int abbrev_len);
|
||||
|
||||
/*
|
||||
* Remove the filename from the provided path string. If the path
|
||||
* contains a trailing separator, then the path is considered a directory
|
||||
@ -673,9 +651,6 @@ int strbuf_check_branch_ref(struct strbuf *sb, const char *name);
|
||||
|
||||
typedef int (*char_predicate)(char ch);
|
||||
|
||||
int is_rfc3986_unreserved(char ch);
|
||||
int is_rfc3986_reserved_or_unreserved(char ch);
|
||||
|
||||
void strbuf_addstr_urlencode(struct strbuf *sb, const char *name,
|
||||
char_predicate allow_unencoded_fn);
|
||||
|
||||
|
Reference in New Issue
Block a user