[PATCH v3 3/4] t0021: test checkout and commit of foreign idents
From: Marcus Comstedt <hidden>
Date: 2016-06-15 22:49:34
Subsystem:
the rest · Maintainer:
Linus Torvalds
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 <redacted>
---
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..cf83c02 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 foreign ident" + echo "\$Id\$" + echo "\$Id: Foreign Commit With Spaces \$" + } > native-and-foreign-idents && + + { + echo "File with foreign ident" + echo "\$Id: c389f8936d7baa13f463254d55b72e00e5496e3f \$" + 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 foreign ident" + echo "\$Id: cc874844b7868ce341059e6a87c50b6f37b75807 \$" + echo "\$Id: cc874844b7868ce341059e6a87c50b6f37b75807 \$" + 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