* [PATCH] Another config file parsing fix. [not found] <20060506141402.3909cb37.seanlkml@sympatico.ca> @ 2006-05-06 18:14 ` sean [not found] ` <20060506142511.667fe954.seanlkml@sympatico.ca> 1 sibling, 0 replies; 4+ messages in thread From: sean @ 2006-05-06 18:14 UTC (permalink / raw) To: git; +Cc: Linus Torvalds If the variable we need to store should go into a section that currently only has a single variable (not matching the one we're trying to insert), we will already be into the next section before we notice we've bypassed the correct location to insert the variable. To handle this case we store the current location as soon as we find a variable matching the section of our new variable. Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca> --- config.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) 1ba487db7393d773a2a4b7c404ba1b807272eb7d diff --git a/config.c b/config.c index 87fb220..41066e4 100644 --- a/config.c +++ b/config.c @@ -336,8 +336,10 @@ static int store_aux(const char* key, co store.state = KEY_SEEN; store.seen++; } else if (strrchr(key, '.') - key == store.baselen && - !strncmp(key, store.key, store.baselen)) + !strncmp(key, store.key, store.baselen)) { store.state = SECTION_SEEN; + store.offset[store.seen] = ftell(config_file); + } } return 0; } -- 1.3.2.g6e99a-dirty ^ permalink raw reply related [flat|nested] 4+ messages in thread
[parent not found: <20060506142511.667fe954.seanlkml@sympatico.ca>]
* Re: [PATCH] Another config file parsing fix. [not found] ` <20060506142511.667fe954.seanlkml@sympatico.ca> @ 2006-05-06 18:25 ` sean [not found] ` <20060506154343.750a806a.seanlkml@sympatico.ca> 2006-05-06 21:01 ` [PATCH] Another config file parsing fix Johannes Schindelin 0 siblings, 2 replies; 4+ messages in thread From: sean @ 2006-05-06 18:25 UTC (permalink / raw) To: sean; +Cc: git, torvalds On Sat, 6 May 2006 14:14:02 -0400 sean <seanlkml@sympatico.ca> wrote: > If the variable we need to store should go into a section > that currently only has a single variable (not matching > the one we're trying to insert), we will already be into > the next section before we notice we've bypassed the correct > location to insert the variable. > > To handle this case we store the current location as soon > as we find a variable matching the section of our new > variable. > Sorry.. this should really be amended to mention that it was Linus who spotted the problem. Sean ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <20060506154343.750a806a.seanlkml@sympatico.ca>]
* [PATCH] t1300-repo-config: two new config parsing tests. [not found] ` <20060506154343.750a806a.seanlkml@sympatico.ca> @ 2006-05-06 19:43 ` sean 0 siblings, 0 replies; 4+ messages in thread From: sean @ 2006-05-06 19:43 UTC (permalink / raw) To: git; +Cc: torvalds - correctly insert a new variable into a section that only contains a single (different) variable. - correctly insert a new section that matches the initial substring of an existing section. Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca> --- Both tests fail with v1.3.2 and pass with latest patches. t/t1300-repo-config.sh | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) ef2178a10e27f43d4120884bc587c460e9b1bfcb diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 1bf728f..0914be2 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -278,5 +278,36 @@ git-repo-config > output 2>&1 test_expect_success 'no arguments, but no crash' \ "test $? = 129 && grep usage output" +cat > .git/config << EOF +[a.b] + c = d +EOF + +git-repo-config a.x y + +cat > expect << EOF +[a.b] + c = d +[a] + x = y +EOF + +test_expect_success 'new section is partial match of another' 'cmp .git/config expect' + +git-repo-config b.x y +git-repo-config a.b c + +cat > expect << EOF +[a.b] + c = d +[a] + x = y + b = c +[b] + x = y +EOF + +test_expect_success 'new variable inserts into proper section' 'cmp .git/config expect' + test_done -- 1.3.2.gd777c ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Another config file parsing fix. 2006-05-06 18:25 ` sean [not found] ` <20060506154343.750a806a.seanlkml@sympatico.ca> @ 2006-05-06 21:01 ` Johannes Schindelin 1 sibling, 0 replies; 4+ messages in thread From: Johannes Schindelin @ 2006-05-06 21:01 UTC (permalink / raw) To: sean; +Cc: git, torvalds Hi, On Sat, 6 May 2006, sean wrote: > On Sat, 6 May 2006 14:14:02 -0400 > sean <seanlkml@sympatico.ca> wrote: > > > If the variable we need to store should go into a section > > that currently only has a single variable (not matching > > the one we're trying to insert), we will already be into > > the next section before we notice we've bypassed the correct > > location to insert the variable. > > > > To handle this case we store the current location as soon > > as we find a variable matching the section of our new > > variable. > > > > Sorry.. this should really be amended to mention that it was Linus > who spotted the problem. Thanks to both of you! Ciao, Dscho ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-05-06 21:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20060506141402.3909cb37.seanlkml@sympatico.ca>
2006-05-06 18:14 ` [PATCH] Another config file parsing fix sean
[not found] ` <20060506142511.667fe954.seanlkml@sympatico.ca>
2006-05-06 18:25 ` sean
[not found] ` <20060506154343.750a806a.seanlkml@sympatico.ca>
2006-05-06 19:43 ` [PATCH] t1300-repo-config: two new config parsing tests sean
2006-05-06 21:01 ` [PATCH] Another config file parsing fix Johannes Schindelin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox