aboutsummaryrefslogtreecommitdiff
path: root/builtin/remote.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-07-16 11:25:59 -0700
committerJunio C Hamano <gitster@pobox.com>2014-07-16 11:26:00 -0700
commit6e4094731acee5207595a8416d19508107ea475d (patch)
treea04d3fe754e34c91216f3a5e2f5450a705fd969d /builtin/remote.c
parentd518cc0a56b8b22a5d085be8710f082dbabfe1b3 (diff)
parent47bf4b0fc52f3ad5823185a85f5f82325787c84b (diff)
downloadgit-6e4094731acee5207595a8416d19508107ea475d.tar.gz
git-6e4094731acee5207595a8416d19508107ea475d.tar.xz
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 'builtin/remote.c')
-rw-r--r--builtin/remote.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/builtin/remote.c b/builtin/remote.c
index a8efe3da4..8e1dc3916 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -263,16 +263,17 @@ static int config_read_branches(const char *key, const char *value, void *cb)
struct string_list_item *item;
struct branch_info *info;
enum { REMOTE, MERGE, REBASE } type;
+ size_t key_len;
key += 7;
- if (ends_with(key, ".remote")) {
- name = xstrndup(key, strlen(key) - 7);
+ if (strip_suffix(key, ".remote", &key_len)) {
+ name = xmemdupz(key, key_len);
type = REMOTE;
- } else if (ends_with(key, ".merge")) {
- name = xstrndup(key, strlen(key) - 6);
+ } else if (strip_suffix(key, ".merge", &key_len)) {
+ name = xmemdupz(key, key_len);
type = MERGE;
- } else if (ends_with(key, ".rebase")) {
- name = xstrndup(key, strlen(key) - 7);
+ } else if (strip_suffix(key, ".rebase", &key_len)) {
+ name = xmemdupz(key, key_len);
type = REBASE;
} else
return 0;