threads / patch / 12117

patchValidate nicknames of remote branches to prohibit confusing ones

Subject: [PATCH] Validate nicknames of remote branches to prohibit confusing ones

## tl;dr

4 messages between Feb 15, 2008 and Feb 16, 2008. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

Daniel Barkalow· Feb 15, 2008, 19:14 UTC · lore

The original problem was that the parsers for configuration files were getting confused by seeing as nicknames remotes that involved directory-changing characters. In particular, the branches config file for ".." was particularly mystifying on platforms that can open directories and read odd data from them.

The validation function was written by Junio Hamano (with a typo corrected).

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
---
I was sort of expecting you to just put this in yourself, but since you 
haven't, I wrote it up as an actual patch and fixed the polarity of the 
test for slashes.
 remote.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
Show changes to remote.c +11 −1
diff --git a/remote.c b/remote.c
index 20abbc0..6b56473 100644
--- a/remote.c
+++ b/remote.c
@@ -343,6 +343,16 @@ struct refspec *parse_ref_spec(int nr_refspec, const char **refspec)
 	return rs;
 }
 
+static int valid_remote_nick(const char *name)
+{
+	if (!name[0] || /* not empty */
+	    (name[0] == '.' && /* not "." */
+	     (!name[1] || /* not ".." */
+	      (name[1] == '.' && !name[2]))))
+		return 0;
+	return !strchr(name, '/'); /* no slash */
+}
+
 struct remote *remote_get(const char *name)
 {
 	struct remote *ret;
@@ -351,7 +361,7 @@ struct remote *remote_get(const char *name)
 	if (!name)
 		name = default_remote_name;
 	ret = make_remote(name, 0);
-	if (name[0] != '/') {
+	if (valid_remote_nick(name)) {
 		if (!ret->url)
 			read_remotes_file(ret);
 		if (!ret->url)
-- 
1.5.4
Junio C Hamano· Feb 15, 2008, 22:22 UTC · re: Daniel Barkalow · lore

Re: [PATCH] Validate nicknames of remote branches to prohibit confusing ones

Daniel Barkalow <barkalow@iabervon.org> writes:
Show 14 quoted lines
> The original problem was that the parsers for configuration files were
> getting confused by seeing as nicknames remotes that involved
> directory-changing characters. In particular, the branches config file
> for ".." was particularly mystifying on platforms that can open
> directories and read odd data from them.
>
> The validation function was written by Junio Hamano (with a typo
> corrected).
>
> Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
> ---
> I was sort of expecting you to just put this in yourself, but since you 
> haven't, I wrote it up as an actual patch and fixed the polarity of the 
> test for slashes.

Thanks. I am bogged down in day-job these days and have been down-sick for the past 36 hours.

Daniel Barkalow· Feb 16, 2008, 03:11 UTC · re: Junio C Hamano · lore

Re: [PATCH] Validate nicknames of remote branches to prohibit confusing ones

On Fri, 15 Feb 2008, Junio C Hamano wrote:
Show 19 quoted lines
> Daniel Barkalow <barkalow@iabervon.org> writes:
> 
> > The original problem was that the parsers for configuration files were
> > getting confused by seeing as nicknames remotes that involved
> > directory-changing characters. In particular, the branches config file
> > for ".." was particularly mystifying on platforms that can open
> > directories and read odd data from them.
> >
> > The validation function was written by Junio Hamano (with a typo
> > corrected).
> >
> > Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
> > ---
> > I was sort of expecting you to just put this in yourself, but since you 
> > haven't, I wrote it up as an actual patch and fixed the polarity of the 
> > test for slashes.
> 
> Thanks.  I am bogged down in day-job these days and have been
> down-sick for the past 36 hours.

No problem. It's an easy enough patch, and the test suite found the bug in the original version. I just wanted to make sure it didn't get forgotten on account of never getting a patch emailled to the list.

	-Daniel
*This .sig left intentionally blank*
Junio C Hamano· Feb 16, 2008, 08:08 UTC · re: Daniel Barkalow · lore

Re: [PATCH] Validate nicknames of remote branches to prohibit confusing ones

Daniel Barkalow <barkalow@iabervon.org> writes:
Show 14 quoted lines
> On Fri, 15 Feb 2008, Junio C Hamano wrote:
>
>> Daniel Barkalow <barkalow@iabervon.org> writes:
>> ...
>> > I was sort of expecting you to just put this in yourself, but since you 
>> > haven't, I wrote it up as an actual patch and fixed the polarity of the 
>> > test for slashes.
>> 
>> Thanks.  I am bogged down in day-job these days and have been
>> down-sick for the past 36 hours.
>
> No problem. It's an easy enough patch, and the test suite found the bug in 
> the original version. I just wanted to make sure it didn't get forgotten 
> on account of never getting a patch emailled to the list.

Actually I have been slowly trying to give up on being in the business of tying up loose ends left by everybody. I used to touch-up and finish obvious loose ends and add tests myself to patches from many people, and I still try to do so when able, but as contributor base gets larger, doing so to all incoming patches is starting to become unfeasible, and it is not quite fair to me (and my wife ;-)).

So in that sense, yes it was getting forgotten, waiting for a "this is the final revision, apply it" message from you.

← back to recent threads