Add end anchor to limit regexp '[<>=]){7}'; the size of the conflict
markers. This prevents in some extent incorrect matches of underlined
headings:
HEADINGS LIKE THIS
==================
Other changes:
- Collapse multiple Perl warn functions calls into onex
- Add empty lines to separate code chunk paragraphs
- Add prototype to function definition: sub bad_line ($,$)
- Change 'print STDERR' calls to standard warn()
Signed-off-by: Jari Aalto <jari.aalto@cante.net>
---
templates/hooks--pre-commit | 23 ++++++++++++++---------
1 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/templates/hooks--pre-commit b/templates/hooks--pre-commit
index 18b8730..859694b 100644
--- a/templates/hooks--pre-commit
+++ b/templates/hooks--pre-commit
@@ -24,21 +24,26 @@ perl -e '
my $filename;
my $reported_filename = "";
my $lineno;
- sub bad_line {
+
+ sub bad_line ($,$) {
my ($why, $line) = @_;
- if (!$found_bad) {
- print STDERR "*\n";
- print STDERR "* You have some suspicious patch lines:\n";
- print STDERR "*\n";
+
+ unless ($found_bad) {
+ warn "*\n",
+ "* You have some suspicious patch lines:\n";
+ "*\n";
$found_bad = 1;
}
+
if ($reported_filename ne $filename) {
- print STDERR "* In $filename\n";
+ warn "* In $filename\n";
$reported_filename = $filename;
}
- print STDERR "* $why (line $lineno)\n";
- print STDERR "$filename:$lineno:$line\n";
+
+ warn "* $why (line $lineno)\n",
+ "$filename:$lineno:$line\n";
}
+
while (<>) {
if (m|^diff --git a/(.*) b/\1$|) {
$filename = $1;
@@ -61,7 +66,7 @@ perl -e '
if (/^\s* /) {
bad_line("indent SP followed by a TAB", $_);
}
- if (/^(?:[<>=]){7}/) {
+ if (/^(?:[<>=]){7}$/) {
bad_line("unresolved merge conflict", $_);
}
}
--
1.5.3.rc5
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html