From: Andy Parkins <andyparkins@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH] cvsserver: Make always-binary mode a config file option
Date: Tue, 27 Feb 2007 13:45:08 +0000 [thread overview]
Message-ID: <200702271345.09341.andyparkins@gmail.com> (raw)
In-Reply-To: <7v4ppedj3r.fsf@assigned-by-dhcp.cox.net>
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>
---
How about this instead?
I've added one new function - kopts_from_path() - which is passed the
path of the file having an "Entries" line generated. It can do what it
likes to convert that into the options component. I've just used a
config option to decide whether everything is binary or nothing is binary.
Default is to be the same as previous behaviour - you have to specifically
ask for the binary flag.
git-cvsserver.perl | 47 ++++++++++++++++++++++++++++++++++++++---------
1 files changed, 38 insertions(+), 9 deletions(-)
diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index 56f21b6..15b9443 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -374,7 +374,8 @@ sub req_add
print "Checked-in $dirpart\n";
print "$filename\n";
- print "/$filepart/0//-kb/\n";
+ my $kopts = kopts_from_path($filepart);
+ print "/$filepart/0//$kopts/\n";
$addcount++;
}
@@ -455,7 +456,8 @@ sub req_remove
print "Checked-in $dirpart\n";
print "$filename\n";
- print "/$filepart/-1.$wrev//-kb/\n";
+ my $kopts = kopts_from_path($filepart);
+ print "/$filepart/-1.$wrev//$kopts/\n";
$rmcount++;
}
@@ -726,7 +728,8 @@ sub req_co
print $state->{CVSROOT} . "/$module/" . ( defined ( $git->{dir} ) and
$git->{dir} ne "./" ? $git->{dir} . "/" : "" ) . "$git->{name}\n";
# this is an "entries" line
- print "/$git->{name}/1.$git->{revision}//-kb/\n";
+ my $kopts = kopts_from_path($git->{name});
+ print "/$git->{name}/1.$git->{revision}//$kopts/\n";
# permissions
print "u=$git->{mode},g=$git->{mode},o=$git->{mode}\n";
@@ -917,8 +920,9 @@ sub req_update
print $state->{CVSROOT} . "/$state->{module}/$filename\n";
# this is an "entries" line
- $log->debug("/$filepart/1.$meta->{revision}//-kb/");
- print "/$filepart/1.$meta->{revision}//-kb/\n";
+ my $kopts = kopts_from_path($filepart);
+ $log->debug("/$filepart/1.$meta->{revision}//$kopts/");
+ print "/$filepart/1.$meta->{revision}//$kopts/\n";
# permissions
$log->debug("SEND : u=$meta->{mode},g=$meta->{mode},o=$meta->{mode}");
@@ -961,8 +965,9 @@ sub req_update
print "Update-existing $dirpart\n";
$log->debug($state->{CVSROOT} . "/$state->{module}/$filename");
print
$state->{CVSROOT} . "/$state->{module}/$filename\n";
- $log->debug("/$filepart/1.$meta->{revision}//-kb/");
- print "/$filepart/1.$meta->{revision}//-kb/\n";
+ my $kopts = kopts_from_path($filepart);
+ $log->debug("/$filepart/1.$meta->{revision}//$kopts/");
+ print "/$filepart/1.$meta->{revision}//$kopts/\n";
}
}
elsif ( $return == 1 )
@@ -975,7 +980,8 @@ sub req_update
{
print "Update-existing $dirpart\n";
print
$state->{CVSROOT} . "/$state->{module}/$filename\n";
- print "/$filepart/1.$meta->{revision}/+/-kb/\n";
+ my $kopts = kopts_from_path($filepart);
+ print "/$filepart/1.$meta->{revision}/+/$kopts/\n";
}
}
else
@@ -1206,7 +1212,8 @@ sub req_ci
} else {
print "Checked-in $dirpart\n";
print "$filename\n";
- print "/$filepart/1.$meta->{revision}//-kb/\n";
+ my $kopts = kopts_from_path($filepart);
+ print "/$filepart/1.$meta->{revision}//$kopts/\n";
}
}
@@ -1887,6 +1894,28 @@ sub filecleanup
return $filename;
}
+# Given a path, this function returns a string containing the kopts
+# that should go into that path's Entries line. For example, a binary
+# file should get -kb.
+sub kopts_from_path
+{
+ my ($path) = @_;
+
+ # Once it exists, the git attributes system should be used to look up
+ # what attributes apply to this path.
+
+ # Until then, take the setting from the config file
+ unless ( defined ( $cfg->{gitcvs}{allbinary} ) and $cfg->{gitcvs}
{allbinary} =~ /^\s*(1|true|yes)\s*$/i )
+ {
+ # Return "" to give no special treatment to any path
+ return "";
+ } else {
+ # Alternatively, to have all files treated as if they are binary (which
+ # is more like git itself), always return the "-kb" option
+ return "-kb";
+ }
+}
+
package GITCVS::log;
####
--
1.5.0.2.778.gdcb06
next prev parent reply other threads:[~2007-02-27 13:45 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-22 15:04 git-cvsserver and binary files Andy Parkins
2007-02-22 16:06 ` [PATCH] Added "-kb" to all the entries lines sent to the client Andy Parkins
2007-02-22 20:37 ` Junio C Hamano
2007-02-27 13:45 ` Andy Parkins [this message]
2007-02-28 11:36 ` [PATCH] cvsserver: Make always-binary mode a config file option Martin Langhoff
2007-02-28 13:01 ` Andy Parkins
2007-02-28 23:40 ` Martin Langhoff
2007-03-01 8:40 ` Andy Parkins
2007-03-01 9:13 ` Martin Langhoff
2007-03-01 9:41 ` Andy Parkins
2007-03-01 9:46 ` Junio C Hamano
2007-03-01 10:04 ` Junio C Hamano
2007-03-01 11:03 ` Junio C Hamano
2007-03-01 11:40 ` Andy Parkins
2007-03-01 11:44 ` Karl Hasselström
2007-02-27 13:46 ` Andy Parkins
2007-02-27 23:56 ` Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200702271345.09341.andyparkins@gmail.com \
--to=andyparkins@gmail.com \
--cc=git@vger.kernel.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.
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 NNTP newsgroup(s).