summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-09-03 19:17:47 -0700
committerJunio C Hamano <gitster@pobox.com>2015-09-03 19:17:48 -0700
commit03ea02771a3752b81db355d70adf430f217b5d7a (patch)
treee3b85db1e90555a118bfb5248b44320d585badd8 /builtin
parentc415fb791b318832f52494b75d99602a7a8d604b (diff)
parentbc598c32ae41cd355169ca7b207c2e35d9449232 (diff)
downloadgit-03ea02771a3752b81db355d70adf430f217b5d7a.tar.gz
Merge branch 'mh/get-remote-group-fix' into maint
An off-by-one error made "git remote" to mishandle a remote with a single letter nickname. * mh/get-remote-group-fix: get_remote_group(): use skip_prefix() get_remote_group(): eliminate superfluous call to strcspn() get_remote_group(): rename local variable "space" to "wordlen" get_remote_group(): handle remotes with single-character names
Diffstat (limited to 'builtin')
-rw-r--r--builtin/fetch.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 8d5b2dba2b..635bbdfc88 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -979,17 +979,15 @@ static int get_remote_group(const char *key, const char *value, void *priv)
{
struct remote_group_data *g = priv;
- if (starts_with(key, "remotes.") &&
- !strcmp(key + 8, g->name)) {
+ if (skip_prefix(key, "remotes.", &key) && !strcmp(key, g->name)) {
/* split list by white space */
- int space = strcspn(value, " \t\n");
while (*value) {
- if (space > 1) {
+ size_t wordlen = strcspn(value, " \t\n");
+
+ if (wordlen >= 1)
string_list_append(g->list,
- xstrndup(value, space));
- }
- value += space + (value[space] != '\0');
- space = strcspn(value, " \t\n");
+ xstrndup(value, wordlen));
+ value += wordlen + (value[wordlen] != '\0');
}
}