From mboxrd@z Thu Jan 1 00:00:00 1970 From: Junio C Hamano Subject: [PATCH v3 06/11] t4200: rerere a merge with two identical conflicts Date: Wed, 6 Apr 2016 16:05:30 -0700 Message-ID: <1459983935-25267-7-git-send-email-gitster@pobox.com> References: <1459204942-26601-1-git-send-email-gitster@pobox.com> <1459983935-25267-1-git-send-email-gitster@pobox.com> To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Thu Apr 07 01:05:53 2016 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1anwWH-0008M9-Gy for gcvg-git-2@plane.gmane.org; Thu, 07 Apr 2016 01:05:53 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754387AbcDFXFu (ORCPT ); Wed, 6 Apr 2016 19:05:50 -0400 Received: from pb-smtp0.pobox.com ([208.72.237.35]:54148 "EHLO sasl.smtp.pobox.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752574AbcDFXFs (ORCPT ); Wed, 6 Apr 2016 19:05:48 -0400 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp0.pobox.com (Postfix) with ESMTP id 8BAC853731; Wed, 6 Apr 2016 19:05:47 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to :subject:date:message-id:in-reply-to:references; s=sasl; bh=tbwU 6QE1aF2CJVCf27HT6lXM9jQ=; b=cqAcklczjzEjwQJKzL1nE9kvZwpe9ZCQoVxC SG2Rsxhk3nonKGpktWyrbIQsmpL0Gc98xxEK+cJ6E0eYbTucAdIZssbRBP1dhJsF sAd+GCFCJO2hpjzAkYjgyhYH62kaTel3HzWHscM9IB+v5CXxhowGi9liPqqNh0Km EBlrdHw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:subject :date:message-id:in-reply-to:references; q=dns; s=sasl; b=qVR11G G+ecNefUR9wWhZi3ay8/yhDmNU7llfVc9RuALu1A4eL9s8zVW+MH2xGaHjmB6aq3 VbQoBJaOJE4AyZmrq6WOIHsle9eKD1mdvSE4CTDYND+AsYTrLgIueUEmTVTwzPBI 2lD5949mcNoEo5UdpeZJVzNKEl9m1poPjSsh0= Received: from pb-smtp0.int.icgroup.com (unknown [127.0.0.1]) by pb-smtp0.pobox.com (Postfix) with ESMTP id 8353C53730; Wed, 6 Apr 2016 19:05:47 -0400 (EDT) Received: from pobox.com (unknown [104.132.1.64]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by pb-smtp0.pobox.com (Postfix) with ESMTPSA id 052BE5372E; Wed, 6 Apr 2016 19:05:46 -0400 (EDT) X-Mailer: git-send-email 2.3.8-32-g0ce02b3 In-Reply-To: <1459983935-25267-1-git-send-email-gitster@pobox.com> X-Pobox-Relay-ID: 18E976CA-FC4C-11E5-906B-45AF6BB36C07-77302942!pb-smtp0.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: When the context of multiple identical conflicts are different, two seemingly the same conflict resolution cannot be safely applied. In such a case, at least we should be able to record these two resolutions separately in the rerere database, and reuse them when we see the same conflict later. Signed-off-by: Junio C Hamano --- t/t4200-rerere.sh | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh index c428011..6fcc6d4 100755 --- a/t/t4200-rerere.sh +++ b/t/t4200-rerere.sh @@ -406,4 +406,78 @@ test_expect_success 'rerere -h' ' test_i18ngrep [Uu]sage help ' +concat_insert () { + last=$1 + shift + cat early && printf "%s\n" "$@" && cat late "$last" +} + +test_expect_failure 'multiple identical conflicts' ' + git reset --hard && + + test_seq 1 6 >early && + >late && + test_seq 11 15 >short && + test_seq 111 120 >long && + concat_insert short >file1 && + concat_insert long >file2 && + git add file1 file2 && + git commit -m base && + git tag base && + git checkout -b six.1 && + concat_insert short 6.1 >file1 && + concat_insert long 6.1 >file2 && + git add file1 file2 && + git commit -m 6.1 && + git checkout -b six.2 HEAD^ && + concat_insert short 6.2 >file1 && + concat_insert long 6.2 >file2 && + git add file1 file2 && + git commit -m 6.2 && + + # At this point, six.1 and six.2 + # - derive from common ancestor that has two files + # 1...6 7 11..15 (file1) and 1...6 7 111..120 (file2) + # - six.1 replaces these 7s with 6.1 + # - six.2 replaces these 7s with 6.2 + + test_must_fail git merge six.1 && + + # Check that rerere knows that file1 and file2 have conflicts + + printf "%s\n" file1 file2 >expect && + git ls-files -u | sed -e "s/^.* //" | sort -u >actual && + test_cmp expect actual && + + git rerere status | sort >actual && + test_cmp expect actual && + + # Resolution is to replace 7 with 6.1 and 6.2 (i.e. take both) + concat_insert short 6.1 6.2 >file1 && + concat_insert long 6.1 6.2 >file2 && + + git rerere remaining >actual && + test_cmp expect actual && + + # We resolved file1 and file2 + git rerere && + >expect && + git rerere remaining >actual && + test_cmp expect actual && + + # Now we should be able to resolve them both + git reset --hard && + test_must_fail git merge six.1 && + git rerere && + + >expect && + git rerere remaining >actual && + test_cmp expect actual && + + concat_insert short 6.1 6.2 >file1.expect && + concat_insert long 6.1 6.2 >file2.expect && + test_cmp file1.expect file1 && + test_cmp file2.expect file2 +' + test_done -- 2.8.1-273-ga2cd0f9