On Tue, 9 May 2006 15:44:59 -0400
sean <seanlkml@sympatico.ca> wrote:
Linus,
I really tried to like your patch ;o) But it breaks the repo-config command
line and causes mixing of some branches using old style [branch.xyz] and new
style [branch "XYZ"] which just doesn't seem to be the right thing to do.
The following patch produced for sake of discussion just allows section
headers to contain whatever characters are needed to get the job done.
git-repo-config works properly with no further need of change. Section
headers become case sensitive but key identifiers within sections do not.
AFAIK there should be no backward compatibility issues with regard to
case sensitivity. All tests pass after having been fixed up to remove
the assumption that section names are case insensitive.
The syntax is:
[<random string>]
Here's how your example would look in this style:
[email.torvalds@osdl.org]
name = Linus Torvalds
And there's no strange syntax needed with repo-config to set and get it:
$ git repo-config email.torvalds@osdl.org.name
Linus Torvalds
and just to show that key names are still case insensitive:
$ git repo-config email.torvalds@osdl.org.NAME
Linus Torvalds
Setting new sections is unambiguous from the command line and
doesn't have to decide whether to use the [branch "<string>"] or
[branch.section.name] format.
$ git repo-config branch.branch.x y
$ git repo-config branch.WonkKY.x y
$ git repo-config --get-regexp branch.\*
branch.branch.x y
branch.WonkKY.x y
[email.torvalds@osdl.org]
name = Linus Torvalds
[branch.branch]
x = y
[branch.WonkKY]
x = y
Sean
---
config.c | 11 +++++++----
repo-config.c | 8 ++++----
t/t1300-repo-config.sh | 38 ++++++++++++++++++++++----------------
3 files changed, 33 insertions(+), 24 deletions(-)
diff --git a/config.c b/config.c
index 0f518c9..5d19ae9 100644
--- a/config.c
+++ b/config.c
@@ -144,11 +144,14 @@ static int get_base_var(char *name)
return -1;
if (c == ']')
return baselen;
- if (!isalnum(c) && c != '.')
- return -1;
+ if (c == '\\') {
+ c = get_next_char();
+ if (c == '\n')
+ return -1;
+ }
if (baselen > MAXNAME / 2)
return -1;
- name[baselen++] = tolower(c);
+ name[baselen++] = c;
}
}
@@ -455,7 +458,7 @@ int git_config_set_multivar(const char*
ret = 1;
goto out_free;
} else
- store.key[i] = tolower(key[i]);
+ store.key[i] = key[i];
store.key[i] = 0;
/*
diff --git a/repo-config.c b/repo-config.c
index 63eda1b..ba5fbd6 100644
--- a/repo-config.c
+++ b/repo-config.c
@@ -65,11 +65,11 @@ static int show_config(const char* key_,
static int get_value(const char* key_, const char* regex_)
{
int i;
+ char *tl;
- key = malloc(strlen(key_)+1);
- for (i = 0; key_[i]; i++)
- key[i] = tolower(key_[i]);
- key[i] = 0;
+ key = strdup(key_);
+ for (tl=key+strlen(key)-1; tl >= key && *tl != '.'; --tl)
+ *tl = tolower(*tl);
if (use_key_regexp) {
key_regexp = (regex_t*)malloc(sizeof(regex_t));
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 7090ea9..f341206 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -23,6 +23,7 @@ git-repo-config Core.Movie BadPhysics
cat > expect << EOF
[core]
penguin = little blue
+[Core]
Movie = BadPhysics
EOF
@@ -33,6 +34,7 @@ git-repo-config Cores.WhatEver Second
cat > expect << EOF
[core]
penguin = little blue
+[Core]
Movie = BadPhysics
[Cores]
WhatEver = Second
@@ -45,10 +47,12 @@ git-repo-config CORE.UPPERCASE true
cat > expect << EOF
[core]
penguin = little blue
+[Core]
Movie = BadPhysics
- UPPERCASE = true
[Cores]
WhatEver = Second
+[CORE]
+ UPPERCASE = true
EOF
test_expect_success 'similar section' 'cmp .git/config expect'
@@ -62,11 +66,13 @@ test_expect_success 'replace with non-ma
cat > expect << EOF
[core]
penguin = very blue
- Movie = BadPhysics
- UPPERCASE = true
penguin = kingpin
+[Core]
+ Movie = BadPhysics
[Cores]
WhatEver = Second
+[CORE]
+ UPPERCASE = true
EOF
test_expect_success 'non-match result' 'cmp .git/config expect'
@@ -130,7 +136,7 @@ EOF
test_expect_success 'really mean test' 'cmp .git/config expect'
-git-repo-config nextsection.nonewline wow
+git-repo-config nextSection.nonewline wow
cat > expect << EOF
[beta] ; silly comment # another comment
@@ -160,7 +166,7 @@ EOF
test_expect_success 'unset' 'cmp .git/config expect'
-git-repo-config nextsection.NoNewLine "wow2 for me" "for me$"
+git-repo-config nextSection.NoNewLine "wow2 for me" "for me$"
cat > expect << EOF
[beta] ; silly comment # another comment
@@ -176,18 +182,18 @@ EOF
test_expect_success 'multivar' 'cmp .git/config expect'
test_expect_success 'non-match' \
- 'git-repo-config --get nextsection.nonewline !for'
+ 'git-repo-config --get nextSection.nonewline !for'
test_expect_success 'non-match value' \
- 'test wow = $(git-repo-config --get nextsection.nonewline !for)'
+ 'test wow = $(git-repo-config --get nextSection.nonewline !for)'
test_expect_failure 'ambiguous get' \
- 'git-repo-config --get nextsection.nonewline'
+ 'git-repo-config --get nextSection.nonewline'
test_expect_success 'get multivar' \
- 'git-repo-config --get-all nextsection.nonewline'
+ 'git-repo-config --get-all nextSection.nonewline'
-git-repo-config nextsection.nonewline "wow3" "wow$"
+git-repo-config nextSection.nonewline "wow3" "wow$"
cat > expect << EOF
[beta] ; silly comment # another comment
@@ -202,15 +208,15 @@ EOF
test_expect_success 'multivar replace' 'cmp .git/config expect'
-test_expect_failure 'ambiguous value' 'git-repo-config nextsection.nonewline'
+test_expect_failure 'ambiguous value' 'git-repo-config nextSection.nonewline'
test_expect_failure 'ambiguous unset' \
- 'git-repo-config --unset nextsection.nonewline'
+ 'git-repo-config --unset nextSection.nonewline'
test_expect_failure 'invalid unset' \
- 'git-repo-config --unset somesection.nonewline'
+ 'git-repo-config --unset someSection.nonewline'
-git-repo-config --unset nextsection.nonewline "wow3$"
+git-repo-config --unset nextSection.nonewline "wow3$"
cat > expect << EOF
[beta] ; silly comment # another comment
@@ -249,7 +255,7 @@ test_expect_success 'hierarchical sectio
cat > expect << EOF
beta.noindent=sillyValue
-nextsection.nonewline=wow2 for me
+nextSection.nonewline=wow2 for me
123456.a123=987
1.2.3.alpha=beta
EOF
@@ -259,7 +265,7 @@ test_expect_success 'working --list' \
cat > expect << EOF
beta.noindent sillyValue
-nextsection.nonewline wow2 for me
+nextSection.nonewline wow2 for me
EOF
test_expect_success '--get-regexp' \
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html