diff options
author | joe <joe@FreeBSD.org> | 2001-12-03 20:53:05 +0000 |
---|---|---|
committer | joe <joe@FreeBSD.org> | 2001-12-03 20:53:05 +0000 |
commit | b43d206fd2f41f2dd6df312f0a102f5b58391b25 (patch) | |
tree | daf921bdab2c438d91e875dd2cdd6c110025b0a7 /CVSROOT | |
parent | 4e8f0a2eceaf6cfff3b1457d6ec759e1d89b71d4 (diff) | |
download | FreeBSD-ports-b43d206fd2f41f2dd6df312f0a102f5b58391b25.zip FreeBSD-ports-b43d206fd2f41f2dd6df312f0a102f5b58391b25.tar.gz |
Add a new config option $NO_DOS_LINEBREAKS to stop files with wierd
line endings from getting committed.
Mostly Submitted by: jesper
Diffstat (limited to 'CVSROOT')
-rwxr-xr-x | CVSROOT/cfg.pm | 8 | ||||
-rwxr-xr-x | CVSROOT/commit_prep.pl | 28 |
2 files changed, 30 insertions, 6 deletions
diff --git a/CVSROOT/cfg.pm b/CVSROOT/cfg.pm index ede8858..447fd03 100755 --- a/CVSROOT/cfg.pm +++ b/CVSROOT/cfg.pm @@ -18,8 +18,8 @@ use vars qw( @COMMIT_HOSTS $COMMITTER $DEBUG $EXCLUDE_FILE $FILE_PREFIX $IDHEADER $LAST_FILE @LOG_FILE_MAP $MAILADDRS $MAILBANNER $MAILCMD $MAIL_BRANCH_HDR $MAIL_ON_DIR_CREATION $MAIL_TRANSFORM $MINCVSVERSION - $MAX_DIFF_SIZE $PID $PROG_CVS $PROG_MV %TEMPLATE_HEADERS $TMPDIR - $UNEXPAND_RCSID $WARN_HEADERS + $MAX_DIFF_SIZE $NO_DOS_LINEBREAKS $PID $PROG_CVS $PROG_MV + %TEMPLATE_HEADERS $TMPDIR $UNEXPAND_RCSID $WARN_HEADERS ); my $CVSROOT = $ENV{'CVSROOT'} || die "Can't determine \$CVSROOT!"; @@ -140,6 +140,10 @@ $IDHEADER = 'CVSHeader'; # the repository as part of the delta. $UNEXPAND_RCSID = 0; +# Check for DOS/WINDOWS/MAC linebreaks in the file, bomb out if present. +# Exclusions can be specified in the exclude file. +$NO_DOS_LINEBREAKS = 0; + #################### ### log_accum.pl ### diff --git a/CVSROOT/commit_prep.pl b/CVSROOT/commit_prep.pl index fd07cb4..545f235 100755 --- a/CVSROOT/commit_prep.pl +++ b/CVSROOT/commit_prep.pl @@ -71,6 +71,10 @@ my $BadVersion = " perform an update to get the current version, and then CAREFULLY merge your changes into that file.\n"; +my $DOSLineBreak = "%s - Dos/Windows/Mac linebreaks encountered (line %d).\n"; +my $DOSLineErr = "PLEASE use only UNIX linebreaks.\n"; + + ############################################################ # # Subroutines @@ -125,6 +129,8 @@ sub check_version { my $rcsid_info; # The expanded values of the rcsid. my $rname; # The file pathname, parsed from the rcsid. my $version; # The file version, parsed from the rcsid. + my $dos_line_brk_found; # True if we found a DOS line break in the file. + my $line_number; # Keep track of where the line break is. # not present - either removed or let cvs deal with it. return 0 unless -f $filename; @@ -133,14 +139,28 @@ sub check_version { # NOTE: We stop after finding the first potential match. open FILE, $filename or die "Cannot open $filename, stopped\n"; $found_rcsid = 0; + $dos_line_brk_found = 0; + $line_number = 0; while (<FILE>) { - next unless /^.*(\$$HEADER.*)/; - $rcsid = $1; - $found_rcsid = 1; - last; + $line_number++; + if ( /^.*(\$$HEADER.*)/ ) { + $rcsid = $1; + $found_rcsid = 1; + } elsif ( m/\r/ ) { + # Found a DOS linebreak + printf($DOSLineBreak, "$directory/$filename", + $line_number); + $dos_line_brk_found = 1; + } } close FILE; + # The file must NOT contain DOS linebreaks + if ($cfg::NO_DOS_LINEBREAKS and $dos_line_brk_found) { + print $DOSLineErr; + return(1); + } + # The file should have had an rcsid in it! unless ($found_rcsid) { printf($NoId, "$directory/$filename"); |