All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcus Comstedt <marcus@mc.pp.se>
To: git@vger.kernel.org
Cc: gitster@pobox.com
Subject: [PATCH v2 2/2] t0021: test checkout and commit of foreign idents
Date: Tue, 7 Sep 2010 21:16:03 +0200	[thread overview]
Message-ID: <E1Ot4NU-0002xs-OO@chiyo.mc.pp.se> (raw)
In-Reply-To: <yf9sk1l73bt.fsf@chiyo.mc.pp.se>

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 <marcus@mc.pp.se>
---
 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

  parent reply	other threads:[~2010-09-07 20:09 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-23 21:30 Fix for normalization of foreign idents Marcus Comstedt
2010-08-23 21:30 ` [PATCH] convert: fix " Marcus Comstedt
2010-08-23 21:35 ` Fix for " Jonathan Nieder
2010-08-23 21:44   ` Marcus Comstedt
2010-08-23 22:33     ` Jonathan Nieder
2010-08-23 23:46       ` Junio C Hamano
2010-08-24  7:23         ` Marcus Comstedt
2010-09-06  9:42     ` Marcus Comstedt
2010-09-06 21:07       ` Jonathan Nieder
2010-09-07 19:37         ` Marcus Comstedt
2010-08-23  7:05           ` [PATCH v2 1/2] convert: fix " Marcus Comstedt
2010-09-10  0:26             ` Junio C Hamano
2010-09-12 21:01               ` Marcus Comstedt
2010-09-12 21:44                 ` Junio C Hamano
2010-09-12 22:06                   ` Marcus Comstedt
2010-09-13 22:00                     ` [PATCH] convert: generalize checksafe parameter Marcus Comstedt
2010-09-07 19:16           ` Marcus Comstedt [this message]
2010-09-07 20:00           ` [PATCH v2 0/2] fix normalization of foreign idents (now with test cases) Marcus Comstedt
2010-09-08  4:32           ` Fix for normalization of foreign idents Jonathan Nieder

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=E1Ot4NU-0002xs-OO@chiyo.mc.pp.se \
    --to=marcus@mc.pp.se \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.