From: Marcus Comstedt Subject: [PATCH v2 2/2] t0021: test checkout and commit of foreign idents Date: Tue, 7 Sep 2010 21:16:03 +0200 Message-ID: References: Cc: gitster@pobox.com To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Tue Sep 07 22:09:41 2010 Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ot4U8-0003iV-MS for gcvg-git-2@lo.gmane.org; Tue, 07 Sep 2010 22:09:41 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758213Ab0IGUJe (ORCPT ); Tue, 7 Sep 2010 16:09:34 -0400 Received: from ua-85-227-1-6.cust.bredbandsbolaget.se ([85.227.1.6]:49954 "EHLO bahamut.mc.pp.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758181Ab0IGUJc (ORCPT ); Tue, 7 Sep 2010 16:09:32 -0400 X-Greylist: delayed 409 seconds by postgrey-1.27 at vger.kernel.org; Tue, 07 Sep 2010 16:09:32 EDT Received: from chiyo.mc.pp.se (chiyo [192.168.42.32]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by bahamut.mc.pp.se (Postfix) with ESMTPS id 12F6FFB18; Tue, 7 Sep 2010 22:02:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mc.pp.se; s=hedgehog; t=1283889770; bh=LEw+XPlp7cbcuUyiBOqDSdx4K1ClqZye9vsdBzHlbC4=; h=Message-Id:In-Reply-To:References:From:Date:Subject:To:Cc; b=fw3E /oq2PYdrdfWHUrehnoQFTQTRjKiyTL7RYYXPWmZvpnM15p2KW/wNgICZ0zAA5OQWzhw s67d4FFVAnEiQrhu/vpz9Y1osmIFQWp8yFcY1XxwwIVpextDB/wiPBEwgdP/w6F7EFY i7Q537sOTypwpVIwXNVc1LPZN1gbPA4mI= Received: from marcus by chiyo.mc.pp.se with local (Exim 4.71) (envelope-from ) id 1Ot4NU-0002xs-OO; Tue, 07 Sep 2010 22:02:48 +0200 In-Reply-To: Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Add test cases for the following behaviors: * Checking out a file with a foreign ident should not flag the file as modified. This is to prevent a mess when checking out old versions, and to allow a migration model where files are allowed to keep their foreign ident as long as their content is also "foreign", i.e. not modified since the migration to git. * Committing to a file with a foreign ident should replace the foreign ident with a native ident. This is simply to get the normal behavior of ident: When the contents of the file is updated, so is the ident. Signed-off-by: Marcus Comstedt --- t/t0021-conversion.sh | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 58 insertions(+), 0 deletions(-) diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh index 828e35b..c0ad9e8 100755 --- a/t/t0021-conversion.sh +++ b/t/t0021-conversion.sh @@ -93,4 +93,62 @@ test_expect_success expanded_in_repo ' cmp expanded-keywords expected-output ' +# Check that a file containing idents (native or foreign) is not +# spuriously flagged as modified on checkout +test_expect_success 'ident pristine after checkout' ' + { + echo "File with expanded keywords" + echo "\$Id\$" + echo "\$Id: Foreign Commit With Spaces \$" + } > native-and-foreign-idents && + + { + echo "File with expanded keywords" + echo "\$Id: 9bdc217750894eed31bb870e9ffa00599f0573a2 \$" + echo "\$Id: Foreign Commit With Spaces \$" + } > expected-output && + + git add native-and-foreign-idents && + git commit -m "File with native and foreign idents" && + + echo "native-and-foreign-idents ident" >> .gitattributes && + + rm -f native-and-foreign-idents && + git checkout -- native-and-foreign-idents && + cat native-and-foreign-idents && + cmp native-and-foreign-idents expected-output && + touch native-and-foreign-idents && + git status --porcelain native-and-foreign-idents > output && + test ! -s output && + git diff -- native-and-foreign-idents > output && + test ! -s output +' + +# Check that actually modifying the file and committing it produces a +# new ident on checkout +test_expect_success 'foreign ident replaced on commit' ' + { + echo "File with expanded keywords" + echo "\$Id: 2499e26293e36cc92399835e497ef6396d710055 \$" + echo "\$Id: 2499e26293e36cc92399835e497ef6396d710055 \$" + echo "Some new content" + } > expected-output && + + echo "1 0 native-and-foreign-idents" > expected-stat1 && + echo "2 1 native-and-foreign-idents" > expected-stat2 && + + echo "Some new content" >> native-and-foreign-idents && + git diff --numstat -- native-and-foreign-idents > output && + cmp output expected-stat1 && + git add native-and-foreign-idents && + git commit -m "Modified file" && + git diff --numstat HEAD^ HEAD -- native-and-foreign-idents > output && + cmp output expected-stat2 && + rm -f native-and-foreign-idents && + git checkout -- native-and-foreign-idents && + cat native-and-foreign-idents && + cmp native-and-foreign-idents expected-output +' + + test_done -- 1.7.2