cvsimport: new -R option: generate .git/cvs-revisions mapping

This option causes the creation or updating of a file mapping CVS
(filename, revision number) pairs to Git commit IDs.  This is expected
to be useful if you have CVS revision numbers stored in commit messages,
bug-tracking systems, email archives, and the like.

Signed-off-by: Aaron Crane <git@aaroncrane.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff --git a/t/t9600-cvsimport.sh b/t/t9600-cvsimport.sh
index 363345f..b572ce3 100755
--- a/t/t9600-cvsimport.sh
+++ b/t/t9600-cvsimport.sh
@@ -47,13 +47,20 @@
 
 test_expect_success 'import a trivial module' '
 
-	git cvsimport -a -z 0 -C module-git module &&
+	git cvsimport -a -R -z 0 -C module-git module &&
 	test_cmp module-cvs/o_fortuna module-git/o_fortuna
 
 '
 
 test_expect_success 'pack refs' 'cd module-git && git gc && cd ..'
 
+test_expect_success 'initial import has correct .git/cvs-revisions' '
+
+	(cd module-git &&
+	 git log --format="o_fortuna 1.1 %H" -1) > expected &&
+	test_cmp expected module-git/.git/cvs-revisions
+'
+
 test_expect_success 'update cvs module' '
 
 	cd module-cvs &&
@@ -86,13 +93,21 @@
 test_expect_success 'update git module' '
 
 	cd module-git &&
-	git cvsimport -a -z 0 module &&
+	git cvsimport -a -R -z 0 module &&
 	git merge origin &&
 	cd .. &&
 	test_cmp module-cvs/o_fortuna module-git/o_fortuna
 
 '
 
+test_expect_success 'update has correct .git/cvs-revisions' '
+
+	(cd module-git &&
+	 git log --format="o_fortuna 1.1 %H" -1 HEAD^ &&
+	 git log --format="o_fortuna 1.2 %H" -1 HEAD) > expected &&
+	test_cmp expected module-git/.git/cvs-revisions
+'
+
 test_expect_success 'update cvs module' '
 
 	cd module-cvs &&
@@ -107,13 +122,22 @@
 
 	cd module-git &&
 		git config cvsimport.module module &&
-		git cvsimport -a -z0 &&
+		git cvsimport -a -R -z0 &&
 		git merge origin &&
 	cd .. &&
 	test_cmp module-cvs/tick module-git/tick
 
 '
 
+test_expect_success 'second update has correct .git/cvs-revisions' '
+
+	(cd module-git &&
+	 git log --format="o_fortuna 1.1 %H" -1 HEAD^^ &&
+	 git log --format="o_fortuna 1.2 %H" -1 HEAD^
+	 git log --format="tick 1.1 %H" -1 HEAD) > expected &&
+	test_cmp expected module-git/.git/cvs-revisions
+'
+
 test_expect_success 'import from a CVS working tree' '
 
 	$CVS co -d import-from-wt module &&
@@ -126,6 +150,12 @@
 
 '
 
+test_expect_success 'no .git/cvs-revisions created by default' '
+
+	! test -e import-from-wt/.git/cvs-revisions
+
+'
+
 test_expect_success 'test entire HEAD' 'test_cmp_branch_tree master'
 
 test_done