Skip to content

Commit 03ea027

Browse files
committed
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
2 parents c415fb7 + bc598c3 commit 03ea027

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
@@ -979,17 +979,15 @@ static int get_remote_group(const char *key, const char *value, void *priv)
979979
{
980980
struct remote_group_data *g = priv;
981981

982-
if (starts_with(key, "remotes.") &&
983-
!strcmp(key + 8, g->name)) {
982+
if (skip_prefix(key, "remotes.", &key) && !strcmp(key, g->name)) {
984983
/* split list by white space */
985-
int space = strcspn(value, " \t\n");
986984
while (*value) {
987-
if (space > 1) {
985+
size_t wordlen = strcspn(value, " \t\n");
986+
987+
if (wordlen >= 1)
988988
string_list_append(g->list,
989-
xstrndup(value, space));
990-
}
991-
value += space + (value[space] != '\0');
992-
space = strcspn(value, " \t\n");
989+
xstrndup(value, wordlen));
990+
value += wordlen + (value[wordlen] != '\0');
993991
}
994992
}
995993

0 commit comments

Comments
 (0)