{"thread":{"id":"11749","subject":"[PATCH 1/2] t9400-git-cvsserver-server: Wrap setup into test case","startedAt":"2008-01-26T09:54:05Z","lastAt":"2008-01-27T09:47:15Z","messageCount":5,"participants":["Steffen Prohaska","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"66628","messageId":"12013412461111-git-send-email-prohaska@zib.de","threadId":"11749","inReplyTo":null,"subject":"[PATCH 1/2] t9400-git-cvsserver-server: Wrap setup into test case","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2008-01-26T09:54:05Z","receivedAt":"2008-01-26T09:54:05Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"The prefer to have the test setup in a test case.  The setup\nitself may fail and having it as a test case handles this\nsituation gracefully.\n\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n t/t9400-git-cvsserver-server.sh |    7 ++++---\n 1 files changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh\nindex 641303e..1f2749e 100755\n--- a/t/t9400-git-cvsserver-server.sh\n+++ b/t/t9400-git-cvsserver-server.sh\n@@ -33,13 +33,14 @@ CVS_SERVER=git-cvsserver\n export CVSROOT CVS_SERVER\n \n rm -rf \"$CVSWORK\" \"$SERVERDIR\"\n-echo >empty &&\n+test_expect_success 'setup' '\n+  echo >empty &&\n   git add empty &&\n   git commit -q -m \"First Commit\" &&\n   git clone -q --local --bare \"$WORKDIR/.git\" \"$SERVERDIR\" >/dev/null 2>&1 &&\n   GIT_DIR=\"$SERVERDIR\" git config --bool gitcvs.enabled true &&\n-  GIT_DIR=\"$SERVERDIR\" git config gitcvs.logfile \"$SERVERDIR/gitcvs.log\" ||\n-  exit 1\n+  GIT_DIR=\"$SERVERDIR\" git config gitcvs.logfile \"$SERVERDIR/gitcvs.log\"\n+'\n \n # note that cvs doesn't accept absolute pathnames\n # as argument to co -d\n-- \n1.5.4.rc4.42.gacc73\n"},{"id":"66629","messageId":"12013412462758-git-send-email-prohaska@zib.de","threadId":"11749","inReplyTo":"12013412461111-git-send-email-prohaska@zib.de","subject":"[PATCH 2/2] cvsserver: Fix for histories with multiple roots","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2008-01-26T09:54:06Z","receivedAt":"2008-01-26T09:54:06Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"Git histories may have multiple roots, which can cause\ngit merge-base to fail and this caused git cvsserver to die.\n\nThis commit teaches git cvsserver to handle a failing git\nmerge-base gracefully, and modifies the test case to verify this.\nAll the test cases now use a history with two roots.\n\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n git-cvsserver.perl              |    5 +++++\n t/t9400-git-cvsserver-server.sh |   10 +++++++++-\n 2 files changed, 14 insertions(+), 1 deletions(-)\n\ndiff --git a/git-cvsserver.perl b/git-cvsserver.perl\nindex ecded3b..534b41e 100755\n--- a/git-cvsserver.perl\n+++ b/git-cvsserver.perl\n@@ -2543,6 +2543,11 @@ sub update\n                     if ($parent eq $lastpicked) {\n                         next;\n                     }\n+                    # or it may fail to find a merge base.  In this\n+                    # case we just ignore this merge.\n+                    if (system(\"git merge-base $lastpicked $parent >/dev/null 2>/dev/null\")) {\n+                        next;\n+                    }\n                     my $base = safe_pipe_capture('git-merge-base',\n \t\t\t\t\t\t $lastpicked, $parent);\n                     chomp $base;\ndiff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh\nindex 1f2749e..75d1ce4 100755\n--- a/t/t9400-git-cvsserver-server.sh\n+++ b/t/t9400-git-cvsserver-server.sh\n@@ -37,6 +37,13 @@ test_expect_success 'setup' '\n   echo >empty &&\n   git add empty &&\n   git commit -q -m \"First Commit\" &&\n+  mkdir secondroot &&\n+  ( cd secondroot &&\n+  git init &&\n+  touch secondrootfile &&\n+  git add secondrootfile &&\n+  git commit -m \"second root\") &&\n+  git pull secondroot master &&\n   git clone -q --local --bare \"$WORKDIR/.git\" \"$SERVERDIR\" >/dev/null 2>&1 &&\n   GIT_DIR=\"$SERVERDIR\" git config --bool gitcvs.enabled true &&\n   GIT_DIR=\"$SERVERDIR\" git config gitcvs.logfile \"$SERVERDIR/gitcvs.log\"\n@@ -46,7 +53,8 @@ test_expect_success 'setup' '\n # as argument to co -d\n test_expect_success 'basic checkout' \\\n   'GIT_CONFIG=\"$git_config\" cvs -Q co -d cvswork master &&\n-   test \"$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5))\" = \"empty/1.1/\"'\n+   test \"$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | head -n 1))\" = \"empty/1.1/\"\n+   test \"$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | tail -n 1))\" = \"secondrootfile/1.1/\"'\n \n #------------------------\n # PSERVER AUTHENTICATION\n-- \n1.5.4.rc4.42.gacc73\n"},{"id":"66654","messageId":"7v8x2cyqsg.fsf@gitster.siamese.dyndns.org","threadId":"11749","inReplyTo":"12013412462758-git-send-email-prohaska@zib.de","subject":"Re: [PATCH 2/2] cvsserver: Fix for histories with multiple roots","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-01-27T01:56:47Z","receivedAt":"2008-01-27T01:56:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Steffen Prohaska <prohaska@zib.de> writes:\n\n> Git histories may have multiple roots, which can cause\n> git merge-base to fail and this caused git cvsserver to die.\n>\n> This commit teaches git cvsserver to handle a failing git\n> merge-base gracefully, and modifies the test case to verify this.\n> All the test cases now use a history with two roots.\n>\n> Signed-off-by: Steffen Prohaska <prohaska@zib.de>\n> ---\n>  git-cvsserver.perl              |    5 +++++\n>  t/t9400-git-cvsserver-server.sh |   10 +++++++++-\n>  2 files changed, 14 insertions(+), 1 deletions(-)\n>\n> diff --git a/git-cvsserver.perl b/git-cvsserver.perl\n> index ecded3b..534b41e 100755\n> --- a/git-cvsserver.perl\n> +++ b/git-cvsserver.perl\n> @@ -2543,6 +2543,11 @@ sub update\n>                      if ($parent eq $lastpicked) {\n>                          next;\n>                      }\n> +                    # or it may fail to find a merge base.  In this\n> +                    # case we just ignore this merge.\n> +                    if (system(\"git merge-base $lastpicked $parent >/dev/null 2>/dev/null\")) {\n> +                        next;\n> +                    }\n>                      my $base = safe_pipe_capture('git-merge-base',\n>  \t\t\t\t\t\t $lastpicked, $parent);\n>                      chomp $base;\n\nThat is a \"Yes, but...\" patch.\n\nRunning merge-base always twice, due to fear of uncommon case of\nfailure, feels quite backwards.\n\nDoesn't this work equally well without running a rather\nexpensive merge-base twice?\n\n git-cvsserver.perl |    9 ++++++++-\n 1 files changed, 8 insertions(+), 1 deletions(-)\n\ndiff --git a/git-cvsserver.perl b/git-cvsserver.perl\nindex ecded3b..afe3d0b 100755\n--- a/git-cvsserver.perl\n+++ b/git-cvsserver.perl\n@@ -2543,8 +2543,15 @@ sub update\n                     if ($parent eq $lastpicked) {\n                         next;\n                     }\n-                    my $base = safe_pipe_capture('git-merge-base',\n+\t\t    my $base = eval {\n+\t\t\t    safe_pipe_capture('git-merge-base',\n \t\t\t\t\t\t $lastpicked, $parent);\n+\t\t    };\n+\t\t    # The two branches may not be related at all,\n+\t\t    # in which case merge base simply fails to find\n+\t\t    # any, but that's Ok.\n+\t\t    next if ($@);\n+\n                     chomp $base;\n                     if ($base) {\n                         my @merged;\n"},{"id":"66668","messageId":"12014266292347-git-send-email-prohaska@zib.de","threadId":"11749","inReplyTo":"7v8x2cyqsg.fsf@gitster.siamese.dyndns.org","subject":"[PATCH v2] cvsserver: Fix for histories with multiple roots","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2008-01-27T09:37:09Z","receivedAt":"2008-01-27T09:37:09Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"Junio,\nhere is a replacement for the second patch.  Different from your diff,\nI replaced tabs with 8 spaces because all of the surrounding code\nuses spaces for indentation.\n\n    Steffen\n\n---- snip ---\n\nGit histories may have multiple roots, which can cause\ngit merge-base to fail and this caused git cvsserver to die.\n\nThis commit teaches git cvsserver to handle a failing git\nmerge-base gracefully, and modifies the test case to verify this.\nAll the test cases now use a history with two roots.\n\nThanks to Junio C Hamano for the implementation that avoids\ncalling git-merge-base twice.\n\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n git-cvsserver.perl              |   11 +++++++++--\n t/t9400-git-cvsserver-server.sh |   10 +++++++++-\n 2 files changed, 18 insertions(+), 3 deletions(-)\n\ndiff --git a/git-cvsserver.perl b/git-cvsserver.perl\nindex ecded3b..920e7de 100755\n--- a/git-cvsserver.perl\n+++ b/git-cvsserver.perl\n@@ -2543,8 +2543,15 @@ sub update\n                     if ($parent eq $lastpicked) {\n                         next;\n                     }\n-                    my $base = safe_pipe_capture('git-merge-base',\n-\t\t\t\t\t\t $lastpicked, $parent);\n+                    my $base = eval {\n+                            safe_pipe_capture('git-merge-base',\n+                                                 $lastpicked, $parent);\n+                    };\n+                    # The two branches may not be related at all,\n+                    # in which case merge base simply fails to find\n+                    # any, but that's Ok.\n+                    next if ($@);\n+\n                     chomp $base;\n                     if ($base) {\n                         my @merged;\ndiff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh\nindex 1f2749e..75d1ce4 100755\n--- a/t/t9400-git-cvsserver-server.sh\n+++ b/t/t9400-git-cvsserver-server.sh\n@@ -37,6 +37,13 @@ test_expect_success 'setup' '\n   echo >empty &&\n   git add empty &&\n   git commit -q -m \"First Commit\" &&\n+  mkdir secondroot &&\n+  ( cd secondroot &&\n+  git init &&\n+  touch secondrootfile &&\n+  git add secondrootfile &&\n+  git commit -m \"second root\") &&\n+  git pull secondroot master &&\n   git clone -q --local --bare \"$WORKDIR/.git\" \"$SERVERDIR\" >/dev/null 2>&1 &&\n   GIT_DIR=\"$SERVERDIR\" git config --bool gitcvs.enabled true &&\n   GIT_DIR=\"$SERVERDIR\" git config gitcvs.logfile \"$SERVERDIR/gitcvs.log\"\n@@ -46,7 +53,8 @@ test_expect_success 'setup' '\n # as argument to co -d\n test_expect_success 'basic checkout' \\\n   'GIT_CONFIG=\"$git_config\" cvs -Q co -d cvswork master &&\n-   test \"$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5))\" = \"empty/1.1/\"'\n+   test \"$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | head -n 1))\" = \"empty/1.1/\"\n+   test \"$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | tail -n 1))\" = \"secondrootfile/1.1/\"'\n \n #------------------------\n # PSERVER AUTHENTICATION\n-- \n1.5.4.rc4.42.gacc73\n"},{"id":"66670","messageId":"359E2AFB-50AA-470E-9FE3-C78805037AAA@zib.de","threadId":"11749","inReplyTo":"12014266292347-git-send-email-prohaska@zib.de","subject":"Re: [PATCH v2] cvsserver: Fix for histories with multiple roots","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2008-01-27T09:47:15Z","receivedAt":"2008-01-27T09:47:15Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Jan 27, 2008, at 10:37 AM, Steffen Prohaska wrote:\n\n> Junio,\n> here is a replacement for the second patch.  Different from your diff,\n> I replaced tabs with 8 spaces because all of the surrounding code\n> uses spaces for indentation.\n\nAh... too late... I should have pulled first ;)\n\nAnyway; thanks for improving the first version.\n\n\tSteffen\n"}]}