summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2015-08-17 15:07:51 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2015-08-17 15:07:51 -0700
commit66873d40655feb640ae9dfd77defa5f6199152bc (patch)
treed895ba4c5ce21090c4e21297120cb76068088dce
parentMerge branch 'kd/pull-rebase-autostash' (diff)
parentget_remote_group(): use skip_prefix() (diff)
downloadtgif-66873d40655feb640ae9dfd77defa5f6199152bc.tar.xz
Merge branch 'mh/get-remote-group-fix'
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
-rw-r--r--builtin/fetch.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 34b6f5ebca..6d743aa4eb 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -988,17 +988,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');
}
}