diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-07-16 20:25:59 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-07-16 20:26:00 +0200 |
commit | 6e4094731acee5207595a8416d19508107ea475d (patch) | |
tree | a04d3fe754e34c91216f3a5e2f5450a705fd969d /strbuf.h | |
parent | Merge branch 'ep/submodule-code-cleanup' (diff) | |
parent | prepare_packed_git_one: refactor duplicate-pack check (diff) | |
download | git-6e4094731acee5207595a8416d19508107ea475d.tar.xz git-6e4094731acee5207595a8416d19508107ea475d.zip |
Merge branch 'jk/strip-suffix'
* jk/strip-suffix:
prepare_packed_git_one: refactor duplicate-pack check
verify-pack: use strbuf_strip_suffix
strbuf: implement strbuf_strip_suffix
index-pack: use strip_suffix to avoid magic numbers
use strip_suffix instead of ends_with in simple cases
replace has_extension with ends_with
implement ends_with via strip_suffix
add strip_suffix function
sha1_file: replace PATH_MAX buffer with strbuf in prepare_packed_git_one()
Diffstat (limited to 'strbuf.h')
-rw-r--r-- | strbuf.h | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -49,6 +49,15 @@ extern int strbuf_reencode(struct strbuf *sb, const char *from, const char *to); extern void strbuf_tolower(struct strbuf *sb); extern int strbuf_cmp(const struct strbuf *, const struct strbuf *); +static inline int strbuf_strip_suffix(struct strbuf *sb, const char *suffix) +{ + if (strip_suffix_mem(sb->buf, &sb->len, suffix)) { + strbuf_setlen(sb, sb->len); + return 1; + } else + return 0; +} + /* * Split str (of length slen) at the specified terminator character. * Return a null-terminated array of pointers to strbuf objects |