Skip to content

Commit

Permalink
Merge branch 'mh/get-remote-group-fix' into maint
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Junio C Hamano committed Sep 4, 2015
2 parents c415fb7 + bc598c3 commit 03ea027
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions builtin/fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

Expand Down

0 comments on commit 03ea027

Please sign in to comment.