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@xxxxxxxx> --- 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 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html