1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-19 14:06:37 +02:00
Commit Graph

45 Commits

Author SHA1 Message Date
Frank Lichtenheld eb1780d480 cvsserver: Make the database backend configurable
Make all the different parts of the database backend connection
configurable. This adds the following string configuration variables:
- gitcvs.dbdriver
- gitcvs.dbname
- gitcvs.dbuser
- gitcvs.dbpass
The default values emulate the current behavior exactly for
backwards compatibility.
All configuration variables can also be specified for a specific
access method (i.e. in the form gitcvs.<method>.<var>)

The dbdriver/dbuser/dbpass variables are added for completness.
No other backend than SQLite is tested yet.
The dbname variable on the other hand is useful with this backend
already (to not discriminate against other possible backends
it was not splitted in dbdir and dbfile).

Both dbname and dbuser support dynamic variable substitution where
the available variables are:
%m -- the CVS 'module' (i.e. GIT 'head') worked on
%a -- CVS access method used (i.e. 'ext' or 'pserver')
%u -- User name of the user invoking git-cvsserver
%G -- .git directory name
%g -- .git directory name, mangled to be used in a filename,
      currently this substitutes all chars except for [\w.-]
      with '_'

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-22 01:26:26 -07:00
Frank Lichtenheld d55820ced6 cvsserver: Allow to override the configuration per access method
Allow to override the gitcvs.enabled and gitcvs.logfile configuration
variables for each access method (i.e. "ext" or "pserver") in the
form gitcvs.<method>.<var>

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-22 01:26:26 -07:00
Frank Lichtenheld 92a39a14d0 cvsserver: Handle three part keys in git config correctly
This is intended to be used in the form gitcvs.<method>.<var>
but this patch doesn't introduce any users yet.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-22 01:26:26 -07:00
Frank Lichtenheld 80573baec4 cvsserver: Introduce new state variable 'method'
$state->{method} contains the CVS access method used,
either 'ext' or 'pserver'

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-22 01:26:26 -07:00
Frank Lichtenheld 392e28170b cvsserver: further improve messages on commit and status
commit: Also print the old revision similar to how cvs does it and
prepend a line stating the filename so that one can actually
understand what happened when commiting more than one file.

status: Fix the RCS filename displayed. The directory was
printed twice.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-14 02:09:33 -07:00
Frank Lichtenheld 459bad77e7 cvsserver: Be more chatty
Submit some additional messages to the client on commit and update.
Inspired by the standard CVS server though a little more terse.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-14 02:09:32 -07:00
Frank Lichtenheld 538778469c cvsserver: Use Merged response instead of Update-existing for merged files
Using Update-existing leads to the client forgetting about the "locally
modified" status of the file which can lead to loss of local changes on
later updates.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de>
Acked-by: Martin Langhoff <martin.langhoff@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-11 22:49:08 -07:00
Andy Parkins 8538e876b1 cvsserver: Make always-binary mode a config file option
The config option gitcvs.allbinary may be set to force all entries to
get the -kb flag.

In the future the gitattributes system will probably be a more
appropriate way of doing this, but that will easily slot in as the
entries lines sent to the CVS client now have their kopts set via the
function kopts_from_path().

In the interim it might be better to not just have a all-or-nothing
approach, but rather detect based on file extension (or file contents?).
That would slot in easily here as well.  However, I personally prefer
everything to be binary-safe, so I just switch the switch.

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-27 16:01:58 -08:00
Andy Parkins 1872adabcc cvsserver: Remove trailing "\n" from commithash in checkin function
The commithash for updating the ref is obtained from a call to
git-commit-tree.  However, it was returned (and stored) with the
trailing newline.  This meant that the later call to git-update-ref that
was trying to update to $commithash was including the newline in the
parameter - obviously that hash would never exist, and so git-update-ref
would always fail.

The solution is to chomp() the commithash as soon as it is returned by
git-commit-tree.

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-27 15:51:03 -08:00
Junio C Hamano ada5ef3b48 Make 'cvs ci' lockless in git-cvsserver by using git-update-ref
This makes "ci" codepath lockless by following the usual
"remember the tip, do your thing, then compare and swap at the
end" update pattern using update-ref.  Incidentally, by updating
the code that reads where the tip of the head is to use
show-ref, it makes it safe to use in a repository whose refs are
pack-pruned.

I noticed that other parts of the program are not yet pack-refs
safe, but tried to keep the changes to the minimum.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-27 15:44:40 -08:00
Andy Parkins b2741f63d4 Have git-cvsserver call hooks/update before really altering the ref
git-cvsserver is analogous to git-receive-pack; a checking from a cvs
client to a central server is like a git-push from a working repository.
Therefore it's nice to use the same access control (and email sending)
that a receive-pack would perform.

This patch tests for an executable update hook; if it is it is run with
the ref being updated and the old and new hashes as normal.  If the
update hook returns an error code the update is aborted and the ref is
never updated.  The cvsserver returns "error 1" to the client to signal
there was an EPERM error.

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-14 02:15:42 -08:00
Tom Prince e0d10e1c63 [PATCH] Rename git-repo-config to git-config.
Signed-off-by: Tom Prince <tom.prince@ualberta.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-28 16:16:53 -08:00
Andy Parkins 535514f1f3 New files in git weren't being downloaded during CVS update
If a repository was checked out via git-cvsserver and then later a new
file is added to the git repository via some other method; a CVS update
wasn't fetching the new file.

It would be reported as a new file as
 A some/dir/newfile.c
but would never appear in the directory.

The problem seems to be that git-cvsserver was treating these two cases
identically, as "A" type results.

1. New file in repository
2. New file locally

In fact, traditionally, case 1 is treated as a "U" result, and case 2
only is treated as an "A" result.  "A", should just report that the file
is added locally and then skip that file during an update as there is
(of course) nothing to send.

In both these cases there is no working revision, so the checking for
"is there no working revision" will return true.  The test for case 2
needs refining to say "if there is no working revision and no upstream
revision".  This patch does just that, leaving case 1 to be handled by
the normal "U" handler.

I've also updated the log message to more accurately describe the
operation.  i.e. that "A" means that content is scheduled for addition;
not that it actually has been added.

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-24 23:38:55 -08:00
Martin Langhoff 3486595bf1 cvsserver: fix revision number during file adds
With this patch, cvs add / cvs commit echoes back to the client
the correct file version (1.1) so that the file in the checkout
is recognised as up-to-date.

Signed-off-by: Martin Langhoff <martin@catalyst.net.nz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-08 21:45:13 -08:00
Martin Langhoff 49fb940e40 cvsserver: detect early of we are up to date and avoid costly rev-list
if the SHA1 of our head matches the last SHA1 seen in the DB, avoid further
processing.

[jc: an "Oops, please amend" patch rolled in]

Signed-off-by: Martin Langhoff <martin@catalyst.net.nz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-08 21:44:07 -08:00
Eric Wong c6b4fa96cb git-cvsserver: fix breakage when calling git merge-file
In the same vein as 8336afa563,
this fixes the the RCS merge to git-merge-file conversion in
commit e2b70087.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-19 16:32:18 -08:00
Junio C Hamano 8042ed1ceb Merge branch 'master' into js/merge
* master: (42 commits)
  git-svn: correctly handle packed-refs in refs/remotes/
  add test case for recursive merge
  git-svn: correctly display fatal() error messages
  git-svn: allow dcommit to take an alternate head
  git-svn: enable logging of information not supported by git
  Clarify fetch error for missing objects.
  Move Fink and Ports check to after config file
  shortlog: fix segfault on empty authorname
  shortlog: remove "[PATCH]" prefix from shortlog output
  Make sure the empty tree exists when needed in merge-recursive.
  Don't use memcpy when source and dest. buffers may overlap
  no need to install manpages as executable
  Documentation: simpler shared repository creation
  shortlog: fix segfault on empty authorname
  Add branch.*.merge warning and documentation update
  Fix perl/ build.
  git-svn: use do_switch for --follow-parent if the SVN library supports it
  Fix documentation copy&paste typo
  git-svn: extra error check to ensure we open a file correctly
  Documentation: update git-clone man page with new behavior
  ...
2006-12-12 21:52:19 -08:00
Johannes Schindelin e2b7008752 Get rid of the dependency on RCS' merge program
Now that we have git-merge-file, an RCS merge lookalike, we no longer
need it. So long, merge, and thanks for all the fish!

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-12 21:47:29 -08:00
Martin Langhoff 4f88d3e0cb cvsserver: Avoid miscounting bytes in Perl v5.8.x
At some point between v5.6 and 5.8 Perl started to assume its input,
output and filehandles are UTF-8. This breaks the counting of bytes
for the CVS protocol, resulting in the client expecting less data
than we actually send, and storing truncated files.

Signed-off-by: Martin Langhoff <martin@catalyst.net.nz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-06 21:47:19 -08:00
Junio C Hamano dc8302d274 Merge branch 'maint'
* maint:
  git-cvsserver: read from git with -z to get non-ASCII pathnames.
2006-11-11 18:30:31 -08:00
Junio C Hamano e02cd6388f git-cvsserver: read from git with -z to get non-ASCII pathnames.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-11-11 18:26:57 -08:00
Shawn Pearce 178e015c05 Use column indexes in git-cvsserver where necessary.
Tonight I found a git-cvsserver instance spending a lot of time in
disk IO while trying to process operations against a Git repository
with >30,000 objects contained in it.

Blowing away my SQLLite database and rebuilding all tables with
indexes on the attributes that git-cvsserver frequently runs queries
against seems to have resolved the issue quite nicely.

Since the indexes shouldn't hurt performance on small repositories
and always helps on larger repositories we should just always create
them when creating the revision storage tables.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-10-22 23:06:00 -07:00
Johannes Schindelin d988b82232 cvsserver: fix "cvs diff" in a subdirectory
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-10-14 18:19:13 -07:00
Johannes Schindelin 0a7a9a12d6 cvsserver: Show correct letters for modified, removed and added files
Earlier, cvsserver showed always an 'U', sometimes even without a space
between the 'U' and the name. Now, the correct letter is shown, with a
space.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-10-14 18:19:12 -07:00
Johannes Schindelin cadbcf2712 cvsserver: imitate git-update-ref when committing
git-update-ref writes into the lockfile, and renames it afterwards. Like
commit v1.3.0-rc3~22, it is not only cleaner, but also helps with shared
setups: every developer can have a different primary group; what matters
is that $GIT_DIR/refs/heads has to be writable by a group you are in.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-26 14:32:13 -07:00
Johannes Schindelin 2c3cff4930 git-cvsserver: support multiline commit messages
Earlier, cvsserver barfed when you tried to check in files with a
multiline commit message.

That is what Argumentx is for... Argument: lines can be followed by
several Argumentx: lines, which means they should be appended.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-26 13:03:01 -07:00
Johannes Schindelin 96256bba94 cvsserver: avoid warning about active db handles
Turns out that DBD::SQLite does not favour preparing statements which are
never executed. So, turn all 4 statements, which were prepared _always_,
into methods, like the other 12 prepared statements.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-25 14:11:36 -07:00
Johannes Schindelin 42217f13ef cvsserver: suppress warnings
This patch defines $state->{prependdir} as the empty string, so that
quite a few warnings are avoided.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Acked-by: Martin Langhoff <martin@catalyst.net.nz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-25 14:09:21 -07:00
Pavel Roskin addf88e455 Assorted typo fixes
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-09 02:42:41 -07:00
Martyn Smith 82000d7464 Change to allow subdir updates from Eclipse
(Now you can rightclick any directory and select team-update/team-commit) and it should work
2006-05-08 10:38:31 +12:00
Martyn Smith 7d90095abe Many fixes for most operations in Eclipse.
* Implemented global -n option
* Implemented "Questionable"
* Fixed Directory method, I _believe_ it's now correct in both cmdline and Eclipse.
* Directory method Now looks for localdir of "." and compares the repo dir, uses THIS as a basis for all directory level calculations.
* Added extra parameter to filenamesplit() to force stripping of "prepended" directory name. This ensures commits/updates etc work from any directory in the source tree.
* Modified argsfromdir() so it is "always" called. This means that when the client specifies a directory, the method can detect this and behave accordingly (this is currently only implemented for the '.' directory)
* Fixed "commit" method to correctly work from in a subdir
2006-05-08 10:33:36 +12:00
Martyn Smith 568907f520 Added logged warnings for CVS error returns 2006-05-08 10:10:48 +12:00
Martin Langhoff a248c9614f cvsserver: use git-rev-list instead of git-log
On 5/4/06, Linus Torvalds <torvalds@osdl.org> wrote:
> No it wasn't. "git log --parents" was definitely supposed to still work.
>
> That said, I suspect a git-cvsserver kind of usage is better off using
> "git-rev-list --parents HEAD" instead, which didn't break in the first
> place.
2006-05-04 10:51:46 +12:00
Junio C Hamano 5348b6e7f4 git-cvsserver: typofixes
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-25 23:59:28 -07:00
Petr Baudis e1cbc46d12 Deprecate usage of git-var -l for getting config vars list
This has been an unfortunate sideway in the git API evolution.
We use git-repo-config for all the other .git/config interaction
so let's also use git-repo-config -l for the variable listing.

Signed-off-by: Petr Baudis <pasky@suse.cz>
2006-04-24 22:29:36 -07:00
Martin Langhoff 91a6bf4682 cvsserver: anonymous cvs via pserver support
git-cvsserver now knows how to do the pserver auth chat when the user
is anonymous. To get it to work, add a line to your inetd.conf like

  cvspserver stream tcp nowait nobody git-cvsserver pserver

(On some inetd implementations you may have to put the pserver parameter twice.)

Commits are blocked. Naively, git-cvsserver assumes non-malicious users. Please
review the code before setting this up on an internet-accessible server.

NOTE: the <nobody> user above will need write access to the .git directory
to maintain the sqlite database. Updating of the sqlite database should be
put in an update hook to avoid this problem, so that it is maintained by
users with write access.
2006-03-04 20:30:04 +13:00
Martin Langhoff cdb6760e6f cvsserver: better error messages
We now have different error messages when the repo is not found vs repo is
not configured to allow gitcvs. Should help users during initial checkouts.

Signed-off-by: Martin Langhoff <martin@catalyst.net.nz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-03 22:28:04 -08:00
Martin Langhoff 6be32d4791 cvsserver: nested directory creation fixups for Eclipse clients
To create nested directories without (or before) sending file entries
is rather tricky. Most clients just work. Eclipse, however, expects
a very specific sequence of events. With this patch, cvsserver meets
those expectations.

Note: we may want to reuse prepdir() in req_update -- should move it
outside of req_co. Right now prepdir() is tied to how req_co() works.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-03 21:37:31 -08:00
Martin Langhoff e74ee784c7 cvsserver: fix checkouts with -d <somedir>
A recent Eclipse compat fix broke checkouts with -d. Fix it so that the server
sends the correct module name instead of the destination directory name.
2006-03-02 22:56:28 -08:00
Martin Langhoff 501c7372c7 cvsserver: checkout faster by sending files in a sensible order
Just by sending the files in an ordered fashion, clients can process them
much faster. And we can optimize our check of whether we created this
directory already -- faster.

Timings for a checkout on a commandline cvs client for a project with
~13K files totalling ~100MB:

Unsorted:
  603.12 real        16.89 user        42.88 sys

Sorted:
  298.19 real        26.37 user        42.42 sys
2006-03-02 22:56:27 -08:00
Martin Langhoff ec58db15a9 cvsserver: Eclipse compat -- now "compare with latest from HEAD" works
The Eclipse client uses cvs update when that menu option is triggered.
And doesn't like the standard cvs update response. Give it *exactly* what
it wants.

And hope the other clients don't lose the plot too badly.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-01 21:41:58 -08:00
Martin Langhoff c8c4f22025 cvsserver: Checkout correctly on Eclipse
Initial checkouts were failing to create Entries files under Eclipse.
Eclipse was waiting for two non-standard directory-resets to prepare for a new
directory from the server.

This patch is tricky, because the same directory resets tend to confuse other
clients. It's taken a bit of fiddling to get the commandline cvs client and
Eclipse to get a good, clean checkout.

Signed-off-by: Martin Langhoff <martin@catalyst.net.nz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-01 17:44:58 -08:00
Martin Langhoff 858cbfbabe cvsserver: Eclipse compat - browsing 'modules' (heads in our case) works
Eclipse CVS clients have an odd way of perusing the top level of
the repository, by calling update on module "". So reproduce cvs'
odd behaviour in the interest of compatibility.

It makes it much easier to get a checkout when using Eclipse.
2006-03-01 01:10:27 -08:00
Martin Langhoff 7172aabb4b cvsserver: Eclipse compat fixes - implement Questionable, alias rlog, add a space after the U
A few things to satisfy Eclipse's strange habits as a cvs client:

- Implement Questionable
- Aliased rlog to log, but more work may be needed
- Add a space after the U that indicates updated
2006-03-01 01:10:26 -08:00
Martin Langhoff 3fda8c4cc7 Introducing git-cvsserver -- a CVS emulator for git.
git-cvsserver is highly functional. However, not all methods are implemented,
and for those methods that are implemented, not all switches are implemented.
All the common read operations are implemented, and add/remove/commit are
supported.

Testing has been done using both the CLI CVS client, and the Eclipse CVS
plugin. Most functionality works fine with both of these clients.

Currently git-cvsserver only works over SSH connections, see the
Documentation for more details on how to configure your client. It
does not support pserver for anonymous access but it should not be
hard to implement. Anonymous access will need tighter input validation.

In our very informal tests, it seems to be significantly faster than a real
CVS server.

This utility depends on a version of git-cvsannotate that supports -S and on
DBD::SQLite.

Licensed under GPLv2. Copyright The Open University UK.

Authors: Martyn Smith <martyn@catalyst.net.nz>
         Martin Langhoff <martin@catalyst.net.nz>

Signed-off-by: Martin Langhoff <martin@catalyst.net.nz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-22 02:17:07 -08:00