Allow git-cvsserver database table name prefix to be specified.
PATCH 1/1 Allow git-cvsserver database table name prefix to be specified.
Adds a gitcvs.dbprefix config variable, the contents of which are prepended to any database tables used by git-cvsserver. The same substutions as gitcvs.dbname and gitcvs.dbuser are supported, and any non-alphabetic characters are replaced with underscores.
---
The purpose of this patch is to easily allow a single database (think PostgreSQL or MySQL) to be shared by multiple repositories.
Documentation/config.txt | 7 +++ Documentation/git-cvsserver.txt | 5 ++ contrib/completion/git-completion.bash | 2 +- git-cvsserver.perl | 77 ++++++++++++++++++------------- 4 files changed, 58 insertions(+), 33 deletions(-)
Documentation/config.txt +7 -0
@@ -661,6 +661,13 @@ gitcvs.dbuser, gitcvs.dbpass:: 'gitcvs.dbuser' supports variable substitution (see linkgit:git-cvsserver[1] for details). +gitcvs.dbprefix:: + Database table name prefix. This will be prepended to any + tables used, allowing a single database to be used for deveral + repositories. Supports variable substitution (see + linkgit:git-cvsserver[1] for details). Any non-alphabetic + characters will be replaces with underscores. + All gitcvs variables except for 'gitcvs.allbinary' can also be specified as 'gitcvs.<access_method>.<varname>' (where 'access_method' is one of "ext" and "pserver") to make them apply only for the given
Documentation/git-cvsserver.txt +5 -0
@@ -227,6 +227,11 @@ gitcvs.dbpass:: Database password. Only useful if setting `dbdriver`, since SQLite has no concept of database passwords. +gitcvs.dbprefix:: + Database table name prefix. Supports variable substitution + (see below). Any non-alphabetic characters will be replaces + with underscores. + All variables can also be set per access method, see <<configaccessmethod,above>>. Variable substitution
contrib/completion/git-completion.bash +1 -1
@@ -999,7 +999,7 @@ _git_config () gitcvs.enabled gitcvs.logfile gitcvs.allbinary - gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dvpass + gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dbpass gitcvs.dbprefix gc.packrefs gc.reflogexpire gc.reflogexpireunreachable
git-cvsserver.perl +45 -32
231 lines not on this page · raw message
Signature · 1 line
1.5.4.2
Quoted 7 lines · Josh Elsasser
Adds a gitcvs.dbprefix config variable, the contents of which are prepended to any database tables used by git-cvsserver. The same substutions as gitcvs.dbname and gitcvs.dbuser are supported, and any non-alphabetic characters are replaced with underscores.
---
The purpose of this patch is to easily allow a single database (think PostgreSQL or MySQL) to be shared by multiple repositories.
For the record, I think that this is a good idea, but have no time to really test it.
Documentation/config.txt gitcvs.dbuser, gitcvs.dbpass:: · line 666
Quoted 11 lines
Documentation/config.txt +3
-0@@ -661,6 +661,13 @@ gitcvs.dbuser, gitcvs.dbpass:: 'gitcvs.dbuser' supports variable substitution (see linkgit:git-cvsserver[1] for details). +gitcvs.dbprefix:: + Database table name prefix. This will be prepended to any + tables used, allowing a single database to be used for deveral
Typo s/deveral/several/
Documentation/config.txt gitcvs.dbuser, gitcvs.dbpass:: · line 669
Quoted 3 lines
Documentation/config.txt +3
-0+gitcvs.dbprefix:: + Database table name prefix. Supports variable substitution + (see below). Any non-alphabetic characters will be replaces
Typo s/replaces/replaced/
Quoted 5 lines
Documentation/config.txt +2
-0+ with underscores. + All variables can also be set per access method, see <<configaccessmethod,above>>. Variable substitution
[...]
Documentation/config.txt sub update · line 2438
Quoted 11 lines
Documentation/config.txt +2
-2@@ -2427,10 +2431,10 @@ sub update # first lets get the commit list $ENV{GIT_DIR} = $self->{git_path}; - my $commitsha1 = `git rev-parse $self->{module}`; + my $commitsha1 = `git-rev-parse $self->{module}`; chomp $commitsha1; - my $commitinfo = `git cat-file commit $self->{module} 2>&1`; + my $commitinfo = `git-cat-file commit $self->{module} 2>&1`; unless ( $commitinfo =~ /tree\s+[a-zA-Z0-9]{40}/ )
Unrelated whitespace changes?
Gruesse,
Signature · 2 lines
Frank Lichtenheld <[email protected]> www: http://www.djpig.de/
PATCH v2 1/1 Allow git-cvsserver database table name prefix to be specified.
Adds a gitcvs.dbprefix config variable, the contents of which are prepended to any database tables used by git-cvsserver. The same substutions as gitcvs.dbname and gitcvs.dbuser are supported, and any non-alphabetic characters are replaced with underscores.
---
The purpose of this patch is to easily allow a single database (think PostgreSQL or MySQL) to be shared by multiple repositories.
This version of the patches fixes a couple spelling mistakes and unrelated changes pointed out by Frank Lichtenheld, thanks.
Documentation/config.txt | 7 +++ Documentation/git-cvsserver.txt | 5 ++ contrib/completion/git-completion.bash | 2 +- git-cvsserver.perl | 73 +++++++++++++++++++------------- 4 files changed, 56 insertions(+), 31 deletions(-)
Documentation/config.txt +7 -0
@@ -661,6 +661,13 @@ gitcvs.dbuser, gitcvs.dbpass:: 'gitcvs.dbuser' supports variable substitution (see linkgit:git-cvsserver[1] for details). +gitcvs.dbprefix:: + Database table name prefix. This will be prepended to any + tables used, allowing a single database to be used for several + repositories. Supports variable substitution (see + linkgit:git-cvsserver[1] for details). Any non-alphabetic + characters will be replaced with underscores. + All gitcvs variables except for 'gitcvs.allbinary' can also be specified as 'gitcvs.<access_method>.<varname>' (where 'access_method' is one of "ext" and "pserver") to make them apply only for the given
Documentation/git-cvsserver.txt +5 -0
@@ -227,6 +227,11 @@ gitcvs.dbpass:: Database password. Only useful if setting `dbdriver`, since SQLite has no concept of database passwords. +gitcvs.dbprefix:: + Database table name prefix. Supports variable substitution + (see below). Any non-alphabetic characters will be replaced + with underscores. + All variables can also be set per access method, see <<configaccessmethod,above>>. Variable substitution
contrib/completion/git-completion.bash +1 -1
@@ -999,7 +999,7 @@ _git_config () gitcvs.enabled gitcvs.logfile gitcvs.allbinary - gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dvpass + gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dbpass gitcvs.dbprefix gc.packrefs gc.reflogexpire gc.reflogexpireunreachable
git-cvsserver.perl +43 -30
219 lines not on this page · raw message
Signature · 1 line
1.5.4.2
Quoted 2 lines · Josh Elsasser
The purpose of this patch is to easily allow a single database (think PostgreSQL or MySQL) to be shared by multiple repositories.
I am not sure if this is even a good idea. You can share a single database cluster (in PostgreSQL lingo, I do not recall how MySQL calls it) and have multiple database instances on it, which would give you better isolation between repositories. What's the advantage of your approach, I have to wonder.
Quoted 1 line
+gitcvs.dbprefix::
And it would not be dbprefix but table name prefix.
git-cvsserver.perl sub new · line 2330
Quoted 10 lines
git-cvsserver.perl +2
-0@@ -2326,6 +2326,8 @@ sub new $cfg->{gitcvs}{dbuser} || ""; $self->{dbpass} = $cfg->{gitcvs}{$state->{method}}{dbpass} || $cfg->{gitcvs}{dbpass} || ""; + $self->{dbprefix} = $cfg->{gitcvs}{$state->{method}}{dbprefix} || + $cfg->{gitcvs}{dbprefix} || "";
Ok.
git-cvsserver.perl sub new · line 2340
Quoted 6 lines
git-cvsserver.perl +2
-0@@ -2334,6 +2336,8 @@ sub new ); $self->{dbname} =~ s/%([mauGg])/$mapping{$1}/eg; $self->{dbuser} =~ s/%([mauGg])/$mapping{$1}/eg; + $self->{dbprefix} =~ s/%([mauGg])/$mapping{$1}/eg; + $self->{dbprefix} = mangle_tablename($self->{dbprefix});
Ok.
git-cvsserver.perl sub new · line 2356
Quoted 6 lines
git-cvsserver.perl +1
-1@@ -2349,10 +2353,10 @@ sub new } # Construct the revision table if required - unless ( $self->{tables}{revision} ) + unless ( $self->{tables}{"$self->{dbprefix}revision"} )
Hmmm. If we are going to insist on having multiple tables in a single database, can we make sure we have better chances of catching mistakes by doing something like...
* Identify the set of tables and indices one repository would use (i.e. revision, revision_ix1, etc.)
* Instead of doing things like this:
git-cvsserver.perl sub new
Quoted 4 lines
git-cvsserver.perl +2
-2- CREATE TABLE revision ( + CREATE TABLE $self->{dbprefix}revision ( - my $insert_rev = $self->{dbh}->prepare_cached("INSERT INTO revision (name, revision, filehash, commithash, modified, author, mode) VALUES (?,?,?,?,?,?,?)",{},1); + my $insert_rev = $self->{dbh}->prepare_cached("INSERT INTO $self->{dbprefix}revision (name, revision, filehash, commithash, modified, author, mode) VALUES (?,?,?,?,?,?,?)",{},1);
Define symbolic name for the full name of tables and indices you identified in the previous step to avoid typos. Perhaps use a per GITCVS::updater instance slot $self->{revision_table}, or a method that returns these names (so that you would get an empty string and blattant SQL statement error if you make typos in your program)?
But I do not have _so_ strong opinion on these. GITCVS::updater module seems to abstract the individual access operations (e.g. insert_rev, insert_mergelog) reasonably well, so perhaps I am worrying too much.
Quoted 10 lines · Junio C Hamano
Quoted 2 lines · Josh Elsasser
The purpose of this patch is to easily allow a single database (think PostgreSQL or MySQL) to be shared by multiple repositories.
I am not sure if this is even a good idea. You can share a single database cluster (in PostgreSQL lingo, I do not recall how MySQL calls it) and have multiple database instances on it, which would give you better isolation between repositories. What's the advantage of your approach, I have to wonder.
Unless I misunderstand what you mean, that is exactly what I would like to be able to avoid. A user may not always be able to create new database instances, or may just want to avoid creating a new one for each repository.
Quoted 3 lines
Quoted 1 line
+gitcvs.dbprefix::
And it would not be dbprefix but table name prefix.
All right, how does gitcvs.dbTableNamePrefix sound?
Quoted 11 lines
git-cvsserver.perl sub new · line 2356
Quoted 6 lines
git-cvsserver.perl +1
-1@@ -2349,10 +2353,10 @@ sub new } # Construct the revision table if required - unless ( $self->{tables}{revision} ) + unless ( $self->{tables}{"$self->{dbprefix}revision"} )Hmmm. If we are going to insist on having multiple tables in a single database, can we make sure we have better chances of catching mistakes by doing something like...
Quoted 2 lines
* Identify the set of tables and indices one repository would use (i.e. revision,
revision_ix1, etc.)
It did occur to me that I should abstract it a little more, I just ended up being lazy about it. A slightly cleaner version should follow this mail.
-jre
PATCH v3 1/1 Allow git-cvsserver database table name prefix to be specified.
Adds a gitcvs.dbtablenameprefix config variable, the contents of which are prepended to any database tables names used by git-cvsserver. The same substutions as gitcvs.dbname and gitcvs.dbuser are supported, and any non-alphabetic characters are replaced with underscores.
A typo found in contrib/completion/git-completion.bash is also fixed.
---
This version of the patch is a bit cleaner, it calls a function to get the table names instead of pasting a variable reference everywhere. The config var name has also been changed from gitcvs.dbprefix to gitcvs.dbTableNamePrefix
Documentation/config.txt | 7 ++ Documentation/git-cvsserver.txt | 5 ++ contrib/completion/git-completion.bash | 3 +- git-cvsserver.perl | 123 ++++++++++++++++++++++++-------- 4 files changed, 107 insertions(+), 31 deletions(-)
Documentation/config.txt +7 -0
@@ -661,6 +661,13 @@ gitcvs.dbuser, gitcvs.dbpass:: 'gitcvs.dbuser' supports variable substitution (see linkgit:git-cvsserver[1] for details). +gitcvs.dbTableNamePrefix:: + Database table name prefix. Prepended to the names of any + database tables used, allowing a single database to be used + for several repositories. Supports variable substitution (see + linkgit:git-cvsserver[1] for details). Any non-alphabetic + characters will be replaced with underscores. + All gitcvs variables except for 'gitcvs.allbinary' can also be specified as 'gitcvs.<access_method>.<varname>' (where 'access_method' is one of "ext" and "pserver") to make them apply only for the given
Documentation/git-cvsserver.txt +5 -0
@@ -227,6 +227,11 @@ gitcvs.dbpass:: Database password. Only useful if setting `dbdriver`, since SQLite has no concept of database passwords. +gitcvs.dbTableNamePrefix:: + Database table name prefix. Supports variable substitution + (see below). Any non-alphabetic characters will be replaced + with underscores. + All variables can also be set per access method, see <<configaccessmethod,above>>. Variable substitution
contrib/completion/git-completion.bash +2 -1
@@ -999,7 +999,8 @@ _git_config () gitcvs.enabled gitcvs.logfile gitcvs.allbinary - gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dvpass + gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dbpass + gitcvs.dbtablenameprefix gc.packrefs gc.reflogexpire gc.reflogexpireunreachable
git-cvsserver.perl +93 -30
304 lines not on this page · raw message
Signature · 1 line
1.5.4.2
Quoted 6 lines · Josh Elsasser
Adds a gitcvs.dbtablenameprefix config variable, the contents of which are prepended to any database tables names used by git-cvsserver. The same substutions as gitcvs.dbname and gitcvs.dbuser are supported, and any non-alphabetic characters are replaced with underscores.
A typo found in contrib/completion/git-completion.bash is also fixed.
Wow, sharp eyes.
Quoted 2 lines
This version of the patch is a bit cleaner, it calls a function to get the table names instead of pasting a variable reference everywhere.
Looks much cleaner then the previous one, indeed.
I consider it signed-off?
Hi,
Quoted 5 lines · Josh Elsasser
Adds a gitcvs.dbtablenameprefix config variable, the contents of which are prepended to any database tables names used by git-cvsserver. The same substutions as gitcvs.dbname and gitcvs.dbuser are supported, and any non-alphabetic characters are replaced with underscores.
Quoted 7 lines
A typo found in contrib/completion/git-completion.bash is also fixed.
---This version of the patch is a bit cleaner, it calls a function to get the table names instead of pasting a variable reference everywhere. The config var name has also been changed from gitcvs.dbprefix to gitcvs.dbTableNamePrefix
I probably missed something, but I cannot find a reason why you need this. In the commit message, I mean.
Ciao,
Dscho