* [PATCH 1/4] get_remote_group(): handle remotes with single-character names
2015-07-28 21:08 [PATCH 0/4] Fix handling of remotes with single-character names Michael Haggerty
@ 2015-07-28 21:08 ` Michael Haggerty
2015-07-28 21:08 ` [PATCH 2/4] get_remote_group(): rename local variable "space" to "wordlen" Michael Haggerty
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Michael Haggerty @ 2015-07-28 21:08 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Björn Gustavsson, git, Michael Haggerty
The code for splitting a whitespace-separated list of values in
"remotes.<name>" had an off-by-one error that caused it to skip over
remotes whose names consist of a single character.
Also remove unnecessary braces.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
builtin/fetch.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index f951265..98f9048 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -980,10 +980,9 @@ static int get_remote_group(const char *key, const char *value, void *priv)
/* split list by white space */
int space = strcspn(value, " \t\n");
while (*value) {
- if (space > 1) {
+ if (space >= 1)
string_list_append(g->list,
xstrndup(value, space));
- }
value += space + (value[space] != '\0');
space = strcspn(value, " \t\n");
}
--
2.4.6
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/4] get_remote_group(): rename local variable "space" to "wordlen"
2015-07-28 21:08 [PATCH 0/4] Fix handling of remotes with single-character names Michael Haggerty
2015-07-28 21:08 ` [PATCH 1/4] get_remote_group(): handle " Michael Haggerty
@ 2015-07-28 21:08 ` Michael Haggerty
2015-07-28 21:08 ` [PATCH 3/4] get_remote_group(): eliminate superfluous call to strcspn() Michael Haggerty
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Michael Haggerty @ 2015-07-28 21:08 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Björn Gustavsson, git, Michael Haggerty
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
builtin/fetch.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 98f9048..d0d267b 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -978,13 +978,13 @@ static int get_remote_group(const char *key, const char *value, void *priv)
if (starts_with(key, "remotes.") &&
!strcmp(key + 8, g->name)) {
/* split list by white space */
- int space = strcspn(value, " \t\n");
+ size_t wordlen = strcspn(value, " \t\n");
while (*value) {
- if (space >= 1)
+ 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');
+ wordlen = strcspn(value, " \t\n");
}
}
--
2.4.6
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/4] get_remote_group(): eliminate superfluous call to strcspn()
2015-07-28 21:08 [PATCH 0/4] Fix handling of remotes with single-character names Michael Haggerty
2015-07-28 21:08 ` [PATCH 1/4] get_remote_group(): handle " Michael Haggerty
2015-07-28 21:08 ` [PATCH 2/4] get_remote_group(): rename local variable "space" to "wordlen" Michael Haggerty
@ 2015-07-28 21:08 ` Michael Haggerty
2015-07-28 21:08 ` [PATCH 4/4] get_remote_group(): use skip_prefix() Michael Haggerty
2015-07-30 22:12 ` [PATCH 0/4] Fix handling of remotes with single-character names Junio C Hamano
4 siblings, 0 replies; 7+ messages in thread
From: Michael Haggerty @ 2015-07-28 21:08 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Björn Gustavsson, git, Michael Haggerty
There is no need to call it if value is the empty string. This also
eliminates code duplication.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
builtin/fetch.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index d0d267b..bd945d0 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -978,13 +978,13 @@ static int get_remote_group(const char *key, const char *value, void *priv)
if (starts_with(key, "remotes.") &&
!strcmp(key + 8, g->name)) {
/* split list by white space */
- size_t wordlen = strcspn(value, " \t\n");
while (*value) {
+ size_t wordlen = strcspn(value, " \t\n");
+
if (wordlen >= 1)
string_list_append(g->list,
xstrndup(value, wordlen));
value += wordlen + (value[wordlen] != '\0');
- wordlen = strcspn(value, " \t\n");
}
}
--
2.4.6
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/4] get_remote_group(): use skip_prefix()
2015-07-28 21:08 [PATCH 0/4] Fix handling of remotes with single-character names Michael Haggerty
` (2 preceding siblings ...)
2015-07-28 21:08 ` [PATCH 3/4] get_remote_group(): eliminate superfluous call to strcspn() Michael Haggerty
@ 2015-07-28 21:08 ` Michael Haggerty
2015-07-30 22:12 ` [PATCH 0/4] Fix handling of remotes with single-character names Junio C Hamano
4 siblings, 0 replies; 7+ messages in thread
From: Michael Haggerty @ 2015-07-28 21:08 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Björn Gustavsson, git, Michael Haggerty
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
builtin/fetch.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index bd945d0..76ca100 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -975,8 +975,7 @@ 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 */
while (*value) {
size_t wordlen = strcspn(value, " \t\n");
--
2.4.6
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 0/4] Fix handling of remotes with single-character names
2015-07-28 21:08 [PATCH 0/4] Fix handling of remotes with single-character names Michael Haggerty
` (3 preceding siblings ...)
2015-07-28 21:08 ` [PATCH 4/4] get_remote_group(): use skip_prefix() Michael Haggerty
@ 2015-07-30 22:12 ` Junio C Hamano
2015-07-31 15:01 ` Michael Haggerty
4 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2015-07-30 22:12 UTC (permalink / raw)
To: Michael Haggerty; +Cc: Björn Gustavsson, git
Thanks, queued.
By the way, do you plan to revisit two rather large-ish stalled
topics of yours queued on 'pu' any time soon?
^ permalink raw reply [flat|nested] 7+ messages in thread