[PATCH/RFT] cvsserver: only allow checkout of branches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It does not make sense to check out tags or "HEAD".

Noticed by Jan Wielemaker.

---

	On Thu, 4 Oct 2007, Jan Wielemaker wrote:

	> On Thursday 04 October 2007 14:56, Johannes Schindelin wrote:
	>
	> > Ah!  Did you do "CVSROOT=:ext:blablub cvs co HEAD"?
	> 
	> Yip ...
	> 
	> > You should "co master".  The branches in git are the modules 
	> > in cvs.
	> >
	> > HEAD is too volatile, you cannot make a proper module from it 
	> > (imagine for example "git checkout next" where "next" is a 
	> > branch, followed by "git checkout html", where "html" is 
	> > another branch).
	> 
	> Ok.  Pretty sure I got literal HEAD from one of the examples 
	> somewhere ... Or, I've been blind all along.  Anyway, the 
	> maintainer may consider giving an error when trying to access 
	> HEAD as a module.  Would have saved about 2 days work and its 
	> unlikely I'm the last victim :-(

	This patch is completely untested.  Could you try it, please?

	If it works:
	Signed-off-by: Johannes Schindelin <Johannes.Schindelin@xxxxxx>

	Cc'ed Frank, who is de-facto maintainer (according to shortlog) 
	and Martin, who started it all IIRC.

 git-cvsserver.perl |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index 13dbd27..869690c 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -770,6 +770,14 @@ sub req_co
 
     $log->debug("req_co : " . ( defined($data) ? $data : "[NULL]" ) );
 
+    if( system("git", "rev-parse", "--verify", "refs/heads/$module" ) != 0 )
+    {
+	$log->warn("Checkout failed: $module is not a branch");
+	print "error 1 Checkout failed: $module is not a branch\n";
+	chdir "/";
+	exit;
+    }
+
     $log->info("Checking out module '$module' ($state->{CVSROOT}) to '$checkout_path'");
 
     $ENV{GIT_DIR} = $state->{CVSROOT} . "/";
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux