Skip to content

Commit 66873d4

Browse files
committed
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
2 parents e69b408 + bc598c3 commit 66873d4

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

builtin/fetch.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -988,17 +988,15 @@ static int get_remote_group(const char *key, const char *value, void *priv)
988988
{
989989
struct remote_group_data *g = priv;
990990

991-
if (starts_with(key, "remotes.") &&
992-
!strcmp(key + 8, g->name)) {
991+
if (skip_prefix(key, "remotes.", &key) && !strcmp(key, g->name)) {
993992
/* split list by white space */
994-
int space = strcspn(value, " \t\n");
995993
while (*value) {
996-
if (space > 1) {
994+
size_t wordlen = strcspn(value, " \t\n");
995+
996+
if (wordlen >= 1)
997997
string_list_append(g->list,
998-
xstrndup(value, space));
999-
}
1000-
value += space + (value[space] != '\0');
1001-
space = strcspn(value, " \t\n");
998+
xstrndup(value, wordlen));
999+
value += wordlen + (value[wordlen] != '\0');
10021000
}
10031001
}
10041002

0 commit comments

Comments
 (0)