git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Linus Torvalds <torvalds@osdl.org>
To: Pavel Roskin <proski@gnu.org>
Cc: git <git@vger.kernel.org>
Subject: Re: Implementing branch attributes in git config
Date: Sun, 7 May 2006 17:05:26 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0605071629080.3718@g5.osdl.org> (raw)
In-Reply-To: <1147037659.25090.25.camel@dv>



On Sun, 7 May 2006, Pavel Roskin wrote:
>
> I think a good implementation should allow any characters in the keys,
> even "=", because the key can be quoted.  Section names may disallow
> square brackets and dots.

That wouldn't help. The thing is designed to not only need no quoting 
(except for the _value_), it also is designed to have both section and key 
names ignore case. So you really aren't supposed to put things like branch 
names (which are potentially case-sensitive, depending on filesystem) in 
either.

And we depend on that (and I think it's important - users normally should 
_not_ care about capitalization)

So you'd need to literally create a different syntax if you want unquoted 
section naming.

> Such limitations make it unpractical to use branch names in section or
> key names.  I'd like to have it fixed.

Here's a possible syntax/patch. I actually think the quoting makes more 
sense in the section name, since you'll usually want several keys under 
each branch, so it makes sense to make the _branch_ be the section.

It basically makes it a special case if you have the section name be 
marked with quotes, like

	["XyZZy"]

and in that case it turns the _real_ section name into the string 
"branch.XyZZy", where the important part is that it does this without 
changing case or limiting the character set (but it will _not_ allow a 
newline) in any way.

So you could have something like

	["Origin"]
		URL = ...
		fetch = master

and it would just turn it into

	branch.Origin.url = ...
	branch.Origin.fetch = master

etc.

No, I'm not sure this is the best possible syntax. It's just a suggestion. 
And it's certainly simple enough.

The downside is that if you start using config files like this, you 
literally can't go back to older git versions. They'll refuse to touch 
such a config file (rather than just ignoring the new entries) and will 
exit with nasty messages. That might be unacceptable.

Instead of quoting with double-quotes, it might be ok to use some 
alternate syntax line "[:$branchname:]" which looks visually reasonable, 
and has the potential advantage that ':' is already an invalid character 
in a branch name, so you don't actually even need any quoting logic at all 
at that point.

I think the

	["branch"]
		...

syntax looks reasonably readable and clean.

		Linus

----
diff --git a/config.c b/config.c
index 41066e4..802e326 100644
--- a/config.c
+++ b/config.c
@@ -134,9 +134,44 @@ static int get_value(config_fn_t fn, cha
 	return fn(name, value);
 }
 
+static int get_branch_name(char *name)
+{
+	int baselen = 7;
+	int quote = 0;
+
+	memcpy(name, "branch.", 7);
+	for (;;) {
+		int c = get_next_char();
+		if (c == EOF)
+			return -1;
+		if (c == '\n')
+			return -1;
+		if (!quote) {
+			if (c == '"')
+				break;
+			if (c == ']')
+				return -1;
+			if (c == '\\') {
+				quote = 1;
+				continue;
+			}
+		}
+		name[baselen++] = c;
+		if (baselen > MAXNAME / 2)
+			return -1;
+	}
+	if (get_next_char() != ']')
+		return -1;
+	return baselen;
+}
+
 static int get_base_var(char *name)
 {
 	int baselen = 0;
+	int c = get_next_char();
+
+	if (c == '"')
+		return get_branch_name(name);
 
 	for (;;) {
 		int c = get_next_char();

  parent reply	other threads:[~2006-05-08  0:05 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-07 21:34 Implementing branch attributes in git config Pavel Roskin
2006-05-07 22:24 ` Junio C Hamano
2006-05-08  0:43   ` Johannes Schindelin
2006-05-08  0:05 ` Linus Torvalds [this message]
2006-05-08  0:18   ` Linus Torvalds
2006-05-08  0:25   ` Linus Torvalds
2006-05-08  1:05     ` Johannes Schindelin
2006-05-08  1:21       ` Pavel Roskin
2006-05-08  1:27         ` Johannes Schindelin
2006-05-08  1:55           ` Pavel Roskin
2006-05-08  9:00             ` Junio C Hamano
2006-05-08 12:17               ` Johannes Schindelin
2006-05-08 15:15               ` Pavel Roskin
     [not found]   ` <20060507203458.439d8815.seanlkml@sympatico.ca>
2006-05-08  0:34     ` sean
2006-05-08  0:55       ` Linus Torvalds
2006-05-08  1:04         ` Pavel Roskin
     [not found]         ` <20060507211145.36fb1be4.seanlkml@sympatico.ca>
2006-05-08  1:11           ` sean
2006-05-08  0:36   ` Pavel Roskin
2006-05-08  0:43     ` Linus Torvalds
2006-05-08  1:27       ` Junio C Hamano
     [not found]         ` <20060507213445.66a2a3b0.seanlkml@sympatico.ca>
2006-05-08  1:34           ` sean
2006-05-08  1:45             ` Johannes Schindelin
     [not found]               ` <20060507214429.623905a6.seanlkml@sympatico.ca>
2006-05-08  1:44                 ` sean
2006-05-08  2:29             ` Junio C Hamano
     [not found]               ` <20060507223918.6112f0c1.seanlkml@sympatico.ca>
2006-05-08  2:39                 ` sean
2006-05-08 23:20                   ` Daniel Barkalow
     [not found]                     ` <20060508193005.40f249a1.seanlkml@sympatico.ca>
2006-05-08 23:30                       ` sean
2006-05-08 23:44                         ` Johannes Schindelin
     [not found]                           ` <20060508200826.2b0f34a6.seanlkml@sympatico.ca>
2006-05-09  0:08                             ` sean
2006-05-09  0:23                               ` Johannes Schindelin
2006-05-09  0:37                               ` Linus Torvalds
     [not found]                                 ` <20060508204933.539ddd8b.seanlkml@sympatico.ca>
2006-05-09  0:49                                   ` sean
2006-05-09  0:54                                 ` Junio C Hamano
2006-05-09  1:05                                   ` Linus Torvalds
2006-05-09  1:18                                     ` Junio C Hamano
2006-05-09  1:30                                       ` Linus Torvalds
2006-05-09  5:31                                         ` Junio C Hamano
2006-05-09  1:57                                       ` Linus Torvalds
     [not found]                                         ` <20060508224721.045a48fb.seanlkml@sympatico.ca>
2006-05-09  2:47                                           ` sean
2006-05-09  3:08                                             ` Linus Torvalds
     [not found]                                               ` <20060508230752.43118643.seanlkml@sympatico.ca>
2006-05-09  3:07                                                 ` sean
2006-05-09  4:11                                                   ` Linus Torvalds
2006-05-09  4:28                                                     ` Jakub Narebski
2006-05-09 11:21                                                       ` Johannes Schindelin
2006-05-09 15:29                                                         ` Linus Torvalds
2006-05-09 18:03                                                         ` Junio C Hamano
2006-05-09 19:24                                                           ` Linus Torvalds
     [not found]                                                             ` <20060509154459.40cc0d13.seanlkml@sympatico.ca>
2006-05-09 19:44                                                               ` sean
     [not found]                                                                 ` <20060509180955.373a2c1d.seanlkml@sympatico.ca>
2006-05-09 22:09                                                                   ` sean
2006-05-09 22:42                                                                     ` Junio C Hamano
     [not found]                                                                       ` <20060509184519.5a707231.seanlkml@sympatico.ca>
2006-05-09 22:45                                                                         ` sean
     [not found]                                                                         ` <20060509190708.4ee6656e.seanlkml@sympatico.ca>
2006-05-09 23:07                                                                           ` sean
2006-05-09 23:23                                                                         ` Pavel Roskin
2006-05-10  0:17                                                                     ` Linus Torvalds
     [not found]                                                                       ` <20060509210857.27df014e.seanlkml@sympatico.ca>
2006-05-10  1:08                                                                         ` sean
2006-05-10  2:08                                                                           ` Linus Torvalds
2006-05-10  7:19                                                                             ` Martin Langhoff
2006-05-10 11:07                                                                               ` Johannes Schindelin
2006-05-10 15:37                                                                               ` Linus Torvalds
2006-05-10 16:03                                                                                 ` Jakub Narebski
2006-05-10 23:17                                                                                 ` Martin Langhoff
2006-05-10 23:55                                                                                   ` Linus Torvalds
2006-05-11  0:11                                                                                     ` Linus Torvalds
2006-05-11  9:51                                                                                       ` Jeff King
2006-05-11 11:39                                                                                         ` Jeff King
2006-05-11  0:13                                                                                     ` Martin Langhoff
2006-05-11 10:30                                                                                       ` Johannes Schindelin
2006-05-11  1:53                                                                                     ` Nicolas Pitre
2006-05-11  6:02                                                                                       ` Jakub Narebski
     [not found]                                                                       ` <20060509213853.0fd8af0f.seanlkml@sympatico.ca>
2006-05-10  1:38                                                                         ` sean
2006-05-11 17:22                                                             ` Junio C Hamano
2006-05-09  4:20                                                 ` Pavel Roskin
2006-05-09 11:26                                               ` Martin Waitz
2006-05-09 11:34                                                 ` Johannes Schindelin
2006-05-08 23:40                     ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0605071629080.3718@g5.osdl.org \
    --to=torvalds@osdl.org \
    --cc=git@vger.kernel.org \
    --cc=proski@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).