@matheusbsbs / matheus-bagliano / commits / e509db990b
Fork 0

cvsserver: Fix for histories with multiple roots

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. Signed-off-by: Steffen Prohaska <prohaska@zib.de> git-cvsserver.perl | 9 ++++++++- t/t9400-git-cvsserver-server.sh | 10 +++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) Signed-off-by: Junio C Hamano <gitster@pobox.com>

Steffen Prohaska committed Jan 26, 2008 at 10:54 UTC e509db990b2ecae642efe3cdef4014d57d525f24
2 files changed +17 -2
git-cvsserver.perl
+8 -1
@@ -2543,8 +2543,15 @@ sub update
2543 if ($parent eq $lastpicked) {
2544 next;
2545 }
2546 - my $base = safe_pipe_capture('git-merge-base',
2546 + my $base = eval {
2547 + safe_pipe_capture('git-merge-base',
2548 $lastpicked, $parent);
2549 + };
2550 + # The two branches may not be related at all,
2551 + # in which case merge base simply fails to find
2552 + # any, but that's Ok.
2553 + next if ($@);
2554 +
2555 chomp $base;
2556 if ($base) {
2557 my @merged;
t/t9400-git-cvsserver-server.sh
+9 -1
@@ -37,6 +37,13 @@ test_expect_success 'setup' '
37 echo >empty &&
38 git add empty &&
39 git commit -q -m "First Commit" &&
40 + mkdir secondroot &&
41 + ( cd secondroot &&
42 + git init &&
43 + touch secondrootfile &&
44 + git add secondrootfile &&
45 + git commit -m "second root") &&
46 + git pull secondroot master &&
47 git clone -q --local --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 &&
48 GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
49 GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log"
@@ -46,7 +53,8 @@ test_expect_success 'setup' '
53 # as argument to co -d
54 test_expect_success 'basic checkout' \
55 'GIT_CONFIG="$git_config" cvs -Q co -d cvswork master &&
49 - test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5))" = "empty/1.1/"'
56 + test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | head -n 1))" = "empty/1.1/"
57 + test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | tail -n 1))" = "secondrootfile/1.1/"'
58
59 #------------------------
60 # PSERVER AUTHENTICATION