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

[PATCH v2] cvsserver: Fix for histories with multiple roots

From
Steffen Prohaska <prohaska@zib.de>
Date
Jan 27, 2008, 09:37 UTC
Message-ID
<12014266292347-git-send-email-prohaska@zib.de>
In-Reply-To
<7v8x2cyqsg.fsf@gitster.siamese.dyndns.org>

Junio, here is a replacement for the second patch. Different from your diff, I replaced tabs with 8 spaces because all of the surrounding code uses spaces for indentation.

    Steffen
---- snip ---

Git histories may have multiple roots, which can cause git merge-base to fail and this caused git cvsserver to die.

This commit teaches git cvsserver to handle a failing git merge-base gracefully, and modifies the test case to verify this. All the test cases now use a history with two roots.

Thanks to Junio C Hamano for the implementation that avoids calling git-merge-base twice.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
 git-cvsserver.perl              |   11 +++++++++--
 t/t9400-git-cvsserver-server.sh |   10 +++++++++-
 2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index ecded3b..920e7de 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -2543,8 +2543,15 @@ sub update
                     if ($parent eq $lastpicked) {
                         next;
                     }
-                    my $base = safe_pipe_capture('git-merge-base',
-						 $lastpicked, $parent);
+                    my $base = eval {
+                            safe_pipe_capture('git-merge-base',
+                                                 $lastpicked, $parent);
+                    };
+                    # The two branches may not be related at all,
+                    # in which case merge base simply fails to find
+                    # any, but that's Ok.
+                    next if ($@);
+
                     chomp $base;
                     if ($base) {
                         my @merged;
diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh
index 1f2749e..75d1ce4 100755
--- a/t/t9400-git-cvsserver-server.sh
+++ b/t/t9400-git-cvsserver-server.sh
@@ -37,6 +37,13 @@ test_expect_success 'setup' '
   echo >empty &&
   git add empty &&
   git commit -q -m "First Commit" &&
+  mkdir secondroot &&
+  ( cd secondroot &&
+  git init &&
+  touch secondrootfile &&
+  git add secondrootfile &&
+  git commit -m "second root") &&
+  git pull secondroot master &&
   git clone -q --local --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 &&
   GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
   GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log"
@@ -46,7 +53,8 @@ test_expect_success 'setup' '
 # as argument to co -d
 test_expect_success 'basic checkout' \
   'GIT_CONFIG="$git_config" cvs -Q co -d cvswork master &&
-   test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5))" = "empty/1.1/"'
+   test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | head -n 1))" = "empty/1.1/"
+   test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | tail -n 1))" = "secondrootfile/1.1/"'
 
 #------------------------
 # PSERVER AUTHENTICATION
-- 
1.5.4.rc4.42.gacc73
Previous: Junio C HamanoNext: Steffen Prohaska
Message 4 of 5 in “t9400-git-cvsserver-server: Wrap setup into test case”
  1. 1/2 t9400-git-cvsserver-server: Wrap setup into test caseSteffen Prohaska, Jan 26, 2008
  2. 2/2 cvsserver: Fix for histories with multiple rootsSteffen Prohaska, Jan 26, 2008
  3. Junio C HamanoJan 27, 2008
  4. cvsserver: Fix for histories with multiple rootsSteffen Prohaska, Jan 27, 2008
  5. Steffen ProhaskaJan 27, 2008

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.