git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 05/10] cvsserver: run dashless "git command"s to access plumbing

From
MOMatthew Ogilvie <mmogilvi_git@miniinfo.net>
Date
Jan 24, 2009, 23:43 UTC
Message-ID
<1232840601-24696-6-git-send-email-mmogilvi_git@miniinfo.net>
In-Reply-To
<1232840601-24696-5-git-send-email-mmogilvi_git@miniinfo.net>

git-cvsserver has been installed in the default $(bindir) since 1df2a1ce806, but if you actually invoke it that way (CVS_SERVER=git-cvsserver), it was failing because most of the dashed-form plumbing commands cvsserver invokes are not in the PATH.

It seems best not to just switch to pure CVS_SERVER="git cvsserver", which does not work with cvs's ":fork:" connection scheme. In this case "cvs" presumably uses the whole value as argv[0] for exec(), and of course no execuable named "git cvsserver" exists.

But both settings worked under some circumstances:

CVS_SERVER="git cvsserver" works OK for cvs's ":ext:" scheme (at least with ssh), presumably because of how sshd invokes /bin/sh -c "{args}" with limited quoting, and "git" would set up the PATH so that cvsserver could run dashed commands correctly.

Also, CVS_SERVER="git-cvsserver" has been working OK under git's test framework, because the test framework currently always sets up a PATH that includes the dashed forms.

Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net>
---
Note: I only changed the actual command invocations; I left error
messages and comments as-is.  Should they be changed as well?

-- Matthew Ogilvie [mmogilvi_git@miniinfo.net]

 git-cvsserver.perl |   40 ++++++++++++++++++++--------------------
 1 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index fe23b49..8e9e659 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -283,7 +283,7 @@ sub req_Root
        return 0;
     }
 
-    my @gitvars = `git-config -l`;
+    my @gitvars = `git config -l`;
     if ($?) {
        print "E problems executing git-config on the server -- this is not a git repository or the PATH is not set correctly.\n";
         print "E \n";
@@ -700,7 +700,7 @@ sub req_Modified
     # Save the file data in $state
     $state->{entries}{$state->{directory}.$data}{modified_filename} = $filename;
     $state->{entries}{$state->{directory}.$data}{modified_mode} = $mode;
-    $state->{entries}{$state->{directory}.$data}{modified_hash} = `git-hash-object $filename`;
+    $state->{entries}{$state->{directory}.$data}{modified_hash} = `git hash-object $filename`;
     $state->{entries}{$state->{directory}.$data}{modified_hash} =~ s/\s.*$//s;
 
     #$log->debug("req_Modified : file=$data mode=$mode size=$size");
@@ -1287,7 +1287,7 @@ sub req_ci
 
 	# do a checkout of the file if it is part of this tree
         if ($wrev) {
-            system('git-checkout-index', '-f', '-u', $filename);
+            system('git', 'checkout-index', '-f', '-u', $filename);
             unless ($? == 0) {
                 die "Error running git-checkout-index -f -u $filename : $!";
             }
@@ -1329,15 +1329,15 @@ sub req_ci
         {
             $log->info("Removing file '$filename'");
             unlink($filename);
-            system("git-update-index", "--remove", $filename);
+            system("git", "update-index", "--remove", $filename);
         }
         elsif ( $addflag )
         {
             $log->info("Adding file '$filename'");
-            system("git-update-index", "--add", $filename);
+            system("git", "update-index", "--add", $filename);
         } else {
             $log->info("Updating file '$filename'");
-            system("git-update-index", $filename);
+            system("git", "update-index", $filename);
         }
     }
 
@@ -1349,7 +1349,7 @@ sub req_ci
         return;
     }
 
-    my $treehash = `git-write-tree`;
+    my $treehash = `git write-tree`;
     chomp $treehash;
 
     $log->debug("Treehash : $treehash, Parenthash : $parenthash");
@@ -1366,7 +1366,7 @@ sub req_ci
     }
     close $msg_fh;
 
-    my $commithash = `git-commit-tree $treehash -p $parenthash < $msg_filename`;
+    my $commithash = `git commit-tree $treehash -p $parenthash < $msg_filename`;
     chomp($commithash);
     $log->info("Commit hash : $commithash");
 
@@ -1819,7 +1819,7 @@ sub req_annotate
 	# TODO: if we got a revision from the client, use that instead
 	# to look up the commithash in sqlite (still good to default to
 	# the current head as we do now)
-	system("git-read-tree", $lastseenin);
+	system("git", "read-tree", $lastseenin);
 	unless ($? == 0)
 	{
 	    print "E error running git-read-tree $lastseenin $ENV{GIT_INDEX_FILE} $!\n";
@@ -1828,7 +1828,7 @@ sub req_annotate
 	$log->info("Created index '$ENV{GIT_INDEX_FILE}' with commit $lastseenin - exit status $?");
 
         # do a checkout of the file
-        system('git-checkout-index', '-f', '-u', $filename);
+        system('git', 'checkout-index', '-f', '-u', $filename);
         unless ($? == 0) {
             print "E error running git-checkout-index -f -u $filename : $!\n";
             return;
@@ -1859,7 +1859,7 @@ sub req_annotate
         close ANNOTATEHINTS
             or (print "E failed to write $a_hints: $!\n"), return;
 
-        my @cmd = (qw(git-annotate -l -S), $a_hints, $filename);
+        my @cmd = (qw(git annotate -l -S), $a_hints, $filename);
         if (!open(ANNOTATE, "-|", @cmd)) {
             print "E error invoking ". join(' ',@cmd) .": $!\n";
             return;
@@ -2080,17 +2080,17 @@ sub transmitfile
 
     die "Need filehash" unless ( defined ( $filehash ) and $filehash =~ /^[a-zA-Z0-9]{40}$/ );
 
-    my $type = `git-cat-file -t $filehash`;
+    my $type = `git cat-file -t $filehash`;
     chomp $type;
 
     die ( "Invalid type '$type' (expected 'blob')" ) unless ( defined ( $type ) and $type eq "blob" );
 
-    my $size = `git-cat-file -s $filehash`;
+    my $size = `git cat-file -s $filehash`;
     chomp $size;
 
     $log->debug("transmitfile($filehash) size=$size, type=$type");
 
-    if ( open my $fh, '-|', "git-cat-file", "blob", $filehash )
+    if ( open my $fh, '-|', "git", "cat-file", "blob", $filehash )
     {
         if ( defined ( $options->{targetfile} ) )
         {
@@ -2942,7 +2942,7 @@ sub update
         push @git_log_params, $self->{module};
     }
     # git-rev-list is the backend / plumbing version of git-log
-    open(GITLOG, '-|', 'git-rev-list', @git_log_params) or die "Cannot call git-rev-list: $!";
+    open(GITLOG, '-|', 'git', 'rev-list', @git_log_params) or die "Cannot call git-rev-list: $!";
 
     my @commits;
 
@@ -3029,7 +3029,7 @@ sub update
                     # several candidate merge bases. let's assume
                     # that the first one is the best one.
 		    my $base = eval {
-			    safe_pipe_capture('git-merge-base',
+			    safe_pipe_capture('git', 'merge-base',
 						 $lastpicked, $parent);
 		    };
 		    # The two branches may not be related at all,
@@ -3041,7 +3041,7 @@ sub update
                     if ($base) {
                         my @merged;
                         # print "want to log between  $base $parent \n";
-                        open(GITLOG, '-|', 'git-log', '--pretty=medium', "$base..$parent")
+                        open(GITLOG, '-|', 'git', 'log', '--pretty=medium', "$base..$parent")
 			  or die "Cannot call git-log: $!";
                         my $mergedhash;
                         while (<GITLOG>) {
@@ -3083,7 +3083,7 @@ sub update
 
         if ( defined ( $lastpicked ) )
         {
-            my $filepipe = open(FILELIST, '-|', 'git-diff-tree', '-z', '-r', $lastpicked, $commit->{hash}) or die("Cannot call git-diff-tree : $!");
+            my $filepipe = open(FILELIST, '-|', 'git', 'diff-tree', '-z', '-r', $lastpicked, $commit->{hash}) or die("Cannot call git-diff-tree : $!");
 	    local ($/) = "\0";
             while ( <FILELIST> )
             {
@@ -3157,7 +3157,7 @@ sub update
             # this is used to detect files removed from the repo
             my $seen_files = {};
 
-            my $filepipe = open(FILELIST, '-|', 'git-ls-tree', '-z', '-r', $commit->{hash}) or die("Cannot call git-ls-tree : $!");
+            my $filepipe = open(FILELIST, '-|', 'git', 'ls-tree', '-z', '-r', $commit->{hash}) or die("Cannot call git-ls-tree : $!");
 	    local $/ = "\0";
             while ( <FILELIST> )
             {
@@ -3448,7 +3448,7 @@ sub commitmessage
         return $message;
     }
 
-    my @lines = safe_pipe_capture("git-cat-file", "commit", $commithash);
+    my @lines = safe_pipe_capture("git", "cat-file", "commit", $commithash);
     shift @lines while ( $lines[0] =~ /\S/ );
     $message = join("",@lines);
     $message .= " " if ( $message =~ /\n$/ );
-- 
1.6.1.81.g9833d.dirty
Previous: Matthew OgilvieNext: Matthew Ogilvie
Message 6 of 16 in “Misc. cvsserver, dashless, and test suite patches”
  1. 00/10 Misc. cvsserver, dashless, and test suite patchesMatthew Ogilvie, Jan 24, 2009
  2. 01/10 cvsserver: removed unused sha1Or-k mode from kopts_from_pathMatthew Ogilvie, Jan 24, 2009
  3. 02/10 cvsserver: add comments about database schema/usageMatthew Ogilvie, Jan 24, 2009
  4. 03/10 cvsserver: remove unused functions _headrev and gethistoryMatthew Ogilvie, Jan 24, 2009
  5. 04/10 git-shell: allow running git-cvsserver, not just cvsMatthew Ogilvie, Jan 24, 2009
  6. 05/10 cvsserver: run dashless "git command"s to access plumbingMatthew Ogilvie, Jan 24, 2009
  7. 06/10 t2300: use documented technique to invoke git-sh-setupMatthew Ogilvie, Jan 24, 2009
  8. 07/10 t3409: use dashless "git commit" instead of "git-commit"Matthew Ogilvie, Jan 24, 2009
  9. 08/10 run test suite without dashed git-commands in PATHMatthew Ogilvie, Jan 24, 2009
  10. 09/10 Revert "adapt git-cvsserver manpage to dash-free syntax"Matthew Ogilvie, Jan 24, 2009
  11. 10/10 cvsserver doc: emphasize using CVS_SERVER= phrase within CVSROOTMatthew Ogilvie, Jan 24, 2009
  12. Johannes SchindelinJan 25, 2009
  13. Matthew OgilvieJan 26, 2009
  14. Johannes SchindelinJan 26, 2009
  15. Matthew OgilvieJan 27, 2009
  16. Johannes SchindelinJan 25, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.