Skip to content

Commit e509db9

Browse files
sprohaskagitster
authored andcommitted
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>
1 parent 7549376 commit e509db9

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

git-cvsserver.perl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2543,8 +2543,15 @@ sub update
25432543
if ($parent eq $lastpicked) {
25442544
next;
25452545
}
2546-
my $base = safe_pipe_capture('git-merge-base',
2546+
my $base = eval {
2547+
safe_pipe_capture('git-merge-base',
25472548
$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+
25482555
chomp $base;
25492556
if ($base) {
25502557
my @merged;

t/t9400-git-cvsserver-server.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ test_expect_success 'setup' '
3737
echo >empty &&
3838
git add empty &&
3939
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 &&
4047
git clone -q --local --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 &&
4148
GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
4249
GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log"
@@ -46,7 +53,8 @@ test_expect_success 'setup' '
4653
# as argument to co -d
4754
test_expect_success 'basic checkout' \
4855
'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/"'
5058

5159
#------------------------
5260
# PSERVER AUTHENTICATION

0 commit comments

Comments
 (0)