cvsserver status: provide real sticky info

Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Matthew Ogilvie committed Oct 13, 2012 at 23:42 UTC abd66f2207f4ed3ef54b526004120a9f0eddf67a
2 files changed +55 -4
git-cvsserver.perl
+20 -4
@@ -502,7 +502,7 @@ sub req_Entry
502
503 #$log->debug("req_Entry : $data");
504
505 - my @data = split(/\//, $data);
505 + my @data = split(/\//, $data, -1);
506
507 $state->{entries}{$state->{directory}.$data[1]} = {
508 revision => $data[2],
@@ -1681,9 +1681,25 @@ sub req_status
1681 print "M Repository revision:\t" .
1682 $meta->{revision} .
1683 "\t$state->{CVSROOT}/$state->{module}/$filename,v\n";
1684 - print "M Sticky Tag:\t\t(none)\n";
1685 - print "M Sticky Date:\t\t(none)\n";
1686 - print "M Sticky Options:\t\t(none)\n";
1684 + my($tagOrDate)=$state->{entries}{$filename}{tag_or_date};
1685 + my($tag)=($tagOrDate=~m/^T(.+)$/);
1686 + if( !defined($tag) )
1687 + {
1688 + $tag="(none)";
1689 + }
1690 + print "M Sticky Tag:\t\t$tag\n";
1691 + my($date)=($tagOrDate=~m/^D(.+)$/);
1692 + if( !defined($date) )
1693 + {
1694 + $date="(none)";
1695 + }
1696 + print "M Sticky Date:\t\t$date\n";
1697 + my($options)=$state->{entries}{$filename}{options};
1698 + if( $options eq "" )
1699 + {
1700 + $options="(none)";
1701 + }
1702 + print "M Sticky Options:\t\t$options\n";
1703 } else {
1704 print "M Repository revision:\tNo revision control file\n";
1705 }
t/t9401-git-cvsserver-crlf.sh
+35
@@ -38,6 +38,25 @@ not_present() {
38 fi
39 }
40
41 +check_status_options() {
42 + (cd "$1" &&
43 + GIT_CONFIG="$git_config" cvs -Q status "$2" > "${WORKDIR}/status.out" 2>&1
44 + )
45 + if [ x"$?" != x"0" ] ; then
46 + echo "Error from cvs status: $1 $2" >> "${WORKDIR}/marked.log"
47 + return 1;
48 + fi
49 + got="$(sed -n -e 's/^\s*Sticky Options:\s*//p' "${WORKDIR}/status.out")"
50 + expect="$3"
51 + if [ x"$expect" = x"" ] ; then
52 + expect="(none)"
53 + fi
54 + test x"$got" = x"$expect"
55 + stat=$?
56 + echo "cvs status: $1 $2 $stat '$3' '$got'" >> "${WORKDIR}/marked.log"
57 + return $stat
58 +}
59 +
60 cvs >/dev/null 2>&1
61 if test $? -ne 1
62 then
@@ -233,6 +252,22 @@ test_expect_success 'cvs co another copy (guess)' '
252 marked_as cvswork2/subdir newfile.c ""
253 '
254
255 +test_expect_success 'cvs status - sticky options' '
256 + check_status_options cvswork2 textfile.c "" &&
257 + check_status_options cvswork2 binfile.bin -kb &&
258 + check_status_options cvswork2 .gitattributes "" &&
259 + check_status_options cvswork2 mixedUp.c -kb &&
260 + check_status_options cvswork2 multiline.c -kb &&
261 + check_status_options cvswork2 multilineTxt.c "" &&
262 + check_status_options cvswork2/subdir withCr.bin -kb &&
263 + check_status_options cvswork2 subdir/withCr.bin -kb &&
264 + check_status_options cvswork2/subdir file.h "" &&
265 + check_status_options cvswork2 subdir/file.h "" &&
266 + check_status_options cvswork2/subdir unspecified.other "" &&
267 + check_status_options cvswork2/subdir newfile.bin "" &&
268 + check_status_options cvswork2/subdir newfile.c ""
269 +'
270 +
271 test_expect_success 'add text (guess)' '
272 (cd cvswork &&
273 echo "simpleText" > simpleText.c &&