git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/4] Fix handling of remotes with single-character names
@ 2015-07-28 21:08 Michael Haggerty
  2015-07-28 21:08 ` [PATCH 1/4] get_remote_group(): handle " Michael Haggerty
                   ` (4 more replies)
  0 siblings, 5 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 parsing of `remotes.<groupname>` was broken if any of the remotes
in the group has a name consisting of a single character.

The first patch fixes the bug; the others are general refactoring to
make the function a little bit clearer.

This series is based on maint, which I just noticed is still v2.4.7,
but it also rebases cleanly to master. It might make sense to apply
only the first patch to maint and the others only to master.

These patches are also available from my GitHub repository [1] as
branch "single-character-remotes".

Michael

[1] https://github.com/mhagger/git

Michael Haggerty (4):
  get_remote_group(): handle remotes with single-character names
  get_remote_group(): rename local variable "space" to "wordlen"
  get_remote_group(): eliminate superfluous call to strcspn()
  get_remote_group(): use skip_prefix()

 builtin/fetch.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

-- 
2.4.6

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [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

* Re: [PATCH 0/4] Fix handling of remotes with single-character names
  2015-07-30 22:12 ` [PATCH 0/4] Fix handling of remotes with single-character names Junio C Hamano
@ 2015-07-31 15:01   ` Michael Haggerty
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Haggerty @ 2015-07-31 15:01 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Björn Gustavsson, git

On 07/31/2015 12:12 AM, Junio C Hamano wrote:
> Thanks, queued.
> 
> By the way, do you plan to revisit two rather large-ish stalled
> topics of yours queued on 'pu' any time soon?

I hope to revive the "tempfile" and "numparse" topics earlyish in this
release cycle if at all possible.

Michael

-- 
Michael Haggerty
mhagger@alum.mit.edu

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-07-31 15:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 3/4] get_remote_group(): eliminate superfluous call to strcspn() 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
2015-07-31 15:01   ` Michael Haggerty

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).