git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Steffen Prohaska <prohaska@zib.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/2] cvsserver: Fix for histories with multiple roots
Date: Sat, 26 Jan 2008 17:56:47 -0800	[thread overview]
Message-ID: <7v8x2cyqsg.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <12013412462758-git-send-email-prohaska@zib.de> (Steffen Prohaska's message of "Sat, 26 Jan 2008 10:54:06 +0100")

Steffen Prohaska <prohaska@zib.de> writes:

> 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              |    5 +++++
>  t/t9400-git-cvsserver-server.sh |   10 +++++++++-
>  2 files changed, 14 insertions(+), 1 deletions(-)
>
> diff --git a/git-cvsserver.perl b/git-cvsserver.perl
> index ecded3b..534b41e 100755
> --- a/git-cvsserver.perl
> +++ b/git-cvsserver.perl
> @@ -2543,6 +2543,11 @@ sub update
>                      if ($parent eq $lastpicked) {
>                          next;
>                      }
> +                    # or it may fail to find a merge base.  In this
> +                    # case we just ignore this merge.
> +                    if (system("git merge-base $lastpicked $parent >/dev/null 2>/dev/null")) {
> +                        next;
> +                    }
>                      my $base = safe_pipe_capture('git-merge-base',
>  						 $lastpicked, $parent);
>                      chomp $base;

That is a "Yes, but..." patch.

Running merge-base always twice, due to fear of uncommon case of
failure, feels quite backwards.

Doesn't this work equally well without running a rather
expensive merge-base twice?

 git-cvsserver.perl |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index ecded3b..afe3d0b 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',
+		    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;

  reply	other threads:[~2008-01-27  1:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-26  9:54 [PATCH 1/2] t9400-git-cvsserver-server: Wrap setup into test case Steffen Prohaska
2008-01-26  9:54 ` [PATCH 2/2] cvsserver: Fix for histories with multiple roots Steffen Prohaska
2008-01-27  1:56   ` Junio C Hamano [this message]
2008-01-27  9:37     ` [PATCH v2] " Steffen Prohaska
2008-01-27  9:47       ` Steffen Prohaska

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v8x2cyqsg.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=prohaska@zib.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).