summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x.git-hooks/pre-commit3
-rw-r--r--solenv/clang-format/ClangFormat.pm12
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx2
3 files changed, 12 insertions, 5 deletions
diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit
index c0464e1c0778..e25532bb0662 100755
--- a/.git-hooks/pre-commit
+++ b/.git-hooks/pre-commit
@@ -161,8 +161,7 @@ sub check_style($)
print("cp clang-format-$version-$platform clang-format\n");
print("chmod +x clang-format\n\n");
- print("(Or read the instructions how to build it yourself at\n");
- print("<https://dev-www.libreoffice.org/bin/README.clang-format.txt>).\n\n");
+ print("(Or read solenv/clang-format/README on how to build it yourself.\n");
return;
}
if (!ClangFormat::check_style($clang_format, $filename))
diff --git a/solenv/clang-format/ClangFormat.pm b/solenv/clang-format/ClangFormat.pm
index 1ec19ada2466..024fe7c1f87f 100644
--- a/solenv/clang-format/ClangFormat.pm
+++ b/solenv/clang-format/ClangFormat.pm
@@ -91,11 +91,19 @@ sub find()
return $clang_format;
}
-# Diffs the original and the formatted version of a single file.
+# Diffs the original and the formatted version of a single file from the index.
sub check_style($$)
{
+ # Make sure that not staged changes are not considered when diffing.
my ($clang_format, $filename) = @_;
- return system("'$clang_format' $filename | git --no-pager diff --no-index --exit-code $filename -") == 0;
+ my $index = $filename . ".index";
+ system("git show :$filename > $index");
+ my $format = $index . ".format";
+ system("'$clang_format' -assume-filename=$filename $index > $format");
+ my $ret = system("git --no-pager diff --no-index --exit-code $index $format") == 0;
+ unlink($index);
+ unlink($format);
+ return $ret;
}
# Private functions.
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 3cd40f81d9c6..081efdca95cc 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -3140,7 +3140,7 @@ RTFError RTFDocumentImpl::popState()
{
if (m_aStates.top().eDestination == Destination::LISTOVERRIDEENTRY)
{
- // copy properties upwards so upper popState inserts it
+ // copy properties upwards so upper popState() inserts it
m_aStates.top().aTableAttributes = aState.aTableAttributes;
m_aStates.top().aTableSprms = aState.aTableSprms;
}