clang-format: ignore not staged hunks
09:28 <@sberg> vmiklos, I think I ran into a scenario last night where I had both `git add`-ed and non-added changes in a non-blacklisted file, and the non-added changes violated clang-format (and the added ones did not), and the commit hook complained So make sure we validate the index version, not the filesystem one. (And modify a formatted file to trigger CI validation of the hook change itself.) Change-Id: I6431b35ac50dd03741104b5709c5195d6ff28632 Reviewed-on: https://gerrit.libreoffice.org/46368 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
This commit is contained in:
@@ -161,8 +161,7 @@ sub check_style($)
|
|||||||
print("cp clang-format-$version-$platform clang-format\n");
|
print("cp clang-format-$version-$platform clang-format\n");
|
||||||
print("chmod +x clang-format\n\n");
|
print("chmod +x clang-format\n\n");
|
||||||
|
|
||||||
print("(Or read the instructions how to build it yourself at\n");
|
print("(Or read solenv/clang-format/README on how to build it yourself.\n");
|
||||||
print("<https://dev-www.libreoffice.org/bin/README.clang-format.txt>).\n\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!ClangFormat::check_style($clang_format, $filename))
|
if (!ClangFormat::check_style($clang_format, $filename))
|
||||||
|
@@ -91,11 +91,19 @@ sub find()
|
|||||||
return $clang_format;
|
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($$)
|
sub check_style($$)
|
||||||
{
|
{
|
||||||
|
# Make sure that not staged changes are not considered when diffing.
|
||||||
my ($clang_format, $filename) = @_;
|
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.
|
# Private functions.
|
||||||
|
@@ -3140,7 +3140,7 @@ RTFError RTFDocumentImpl::popState()
|
|||||||
{
|
{
|
||||||
if (m_aStates.top().eDestination == Destination::LISTOVERRIDEENTRY)
|
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().aTableAttributes = aState.aTableAttributes;
|
||||||
m_aStates.top().aTableSprms = aState.aTableSprms;
|
m_aStates.top().aTableSprms = aState.aTableSprms;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user