X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=strbuf.h;h=3646a6291b5026fc6d9e211a0313d76e4d2e100d;hb=f2bb1218f1e559131887b5c981bc8d962b00d85a;hp=2262b12683b5d91d536baa0b71094098872200d1;hpb=a849d36cf2877a1890371851710382f463290978;p=git-core%2Fgit.git diff --git a/strbuf.h b/strbuf.h index 2262b1268..3646a6291 100644 --- a/strbuf.h +++ b/strbuf.h @@ -109,9 +109,7 @@ extern void strbuf_attach(struct strbuf *, void *, size_t, size_t); */ static inline void strbuf_swap(struct strbuf *a, struct strbuf *b) { - struct strbuf tmp = *a; - *a = *b; - *b = tmp; + SWAP(*a, *b); } @@ -266,12 +264,6 @@ static inline void strbuf_addstr(struct strbuf *sb, const char *s) extern void strbuf_addbuf(struct strbuf *sb, const struct strbuf *sb2); /** - * Copy part of the buffer from a given position till a given length to the - * end of the buffer. - */ -extern void strbuf_adddup(struct strbuf *sb, size_t pos, size_t len); - -/** * This function can be used to expand a format string containing * placeholders. To that end, it parses the string and calls the specified * function for every percent sign found. @@ -342,8 +334,14 @@ extern void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap); /** * Add the time specified by `tm`, as formatted by `strftime`. + * `tz_name` is used to expand %Z internally unless it's NULL. + * `tz_offset` is in decimal hhmm format, e.g. -600 means six hours west + * of Greenwich, and it's used to expand %z internally. However, tokens + * with modifiers (e.g. %Ez) are passed to `strftime`. */ -extern void strbuf_addftime(struct strbuf *sb, const char *fmt, const struct tm *tm); +extern void strbuf_addftime(struct strbuf *sb, const char *fmt, + const struct tm *tm, int tz_offset, + const char *tz_name); /** * Read a given size of data from a FILE* pointer to the buffer. @@ -443,6 +441,20 @@ extern int strbuf_getcwd(struct strbuf *sb); */ extern 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. + */ +extern void strbuf_add_real_path(struct strbuf *sb, const char *path); + /** * Normalize in-place the path contained in the strbuf. See @@ -562,7 +574,26 @@ static inline void strbuf_complete_line(struct strbuf *sb) strbuf_complete(sb, '\n'); } -extern int strbuf_branchname(struct strbuf *sb, const char *name); +/* + * Copy "name" to "sb", expanding any special @-marks as handled by + * interpret_branch_name(). The result is a non-qualified branch name + * (so "foo" or "origin/master" instead of "refs/heads/foo" or + * "refs/remotes/origin/master"). + * + * Note that the resulting name may not be a syntactically valid refname. + * + * If "allowed" is non-zero, restrict the set of allowed expansions. See + * interpret_branch_name() for details. + */ +extern void strbuf_branchname(struct strbuf *sb, const char *name, + unsigned allowed); + +/* + * Like strbuf_branchname() above, but confirm that the result is + * syntactically valid to be used as a local branch name in refs/heads/. + * + * The return value is "0" if the result is valid, and "-1" otherwise. + */ extern int strbuf_check_branch_ref(struct strbuf *sb, const char *name); extern void strbuf_addstr_urlencode(struct strbuf *, const char *,