Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
8e4adb60
Kaydet (Commit)
8e4adb60
authored
Agu 15, 2011
tarafından
Miklos Vajna
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
git-hooks: whitespace problems are not errors in non-source files
üst
02d95370
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
pre-commit
git-hooks/pre-commit
+7
-4
No files found.
git-hooks/pre-commit
Dosyayı görüntüle @
8e4adb60
...
@@ -12,9 +12,9 @@ use Cwd;
...
@@ -12,9 +12,9 @@ use Cwd;
$ENV
{
LC_ALL
}
=
"C"
;
$ENV
{
LC_ALL
}
=
"C"
;
sub
check_whitespaces
($)
sub
check_whitespaces
($
$
)
{
{
my
(
$h
)
=
@_
;
my
(
$h
,
$src_exts
)
=
@_
;
my
$found_bad
=
0
;
my
$found_bad
=
0
;
my
$filename
;
my
$filename
;
...
@@ -22,6 +22,7 @@ sub check_whitespaces($)
...
@@ -22,6 +22,7 @@ sub check_whitespaces($)
my
$lineno
;
my
$lineno
;
sub
bad_line
{
sub
bad_line
{
my
(
$why
,
$line
)
=
@_
;
my
(
$why
,
$line
)
=
@_
;
if
(
$filename
=~
/\.($src_exts)$/
)
{
if
(
!
$found_bad
)
{
if
(
!
$found_bad
)
{
print
STDERR
"*\n"
;
print
STDERR
"*\n"
;
print
STDERR
"* You have some suspicious patch lines:\n"
;
print
STDERR
"* You have some suspicious patch lines:\n"
;
...
@@ -34,6 +35,7 @@ sub check_whitespaces($)
...
@@ -34,6 +35,7 @@ sub check_whitespaces($)
}
}
print
STDERR
"* $why (line $lineno)\n"
;
print
STDERR
"* $why (line $lineno)\n"
;
print
STDERR
"$filename:$lineno:$line\n"
;
print
STDERR
"$filename:$lineno:$line\n"
;
}
}
}
open
(
FILES
,
"git-diff-index -p -M --cached $h |"
)
||
die
"Cannot run git diff-index."
;
open
(
FILES
,
"git-diff-index -p -M --cached $h |"
)
||
die
"Cannot run git diff-index."
;
while
(
<
FILES
>
)
{
while
(
<
FILES
>
)
{
...
@@ -134,12 +136,13 @@ while (my $file = <FILES>) {
...
@@ -134,12 +136,13 @@ while (my $file = <FILES>) {
# be strict about tabs - we don't want them at all, setup your editor
# be strict about tabs - we don't want them at all, setup your editor
# correctly ;-)
# correctly ;-)
my
$err_ext
=
""
;
my
$err_ext
=
""
;
my
$src_exts
=
"c|cpp|cxx|h|hrc|hxx|idl|inl|java|map|MK|pmk|pl|pm|sdi|sh|src|tab|xcu|xml"
;
open
(
FILES
,
"git diff-index --cached --name-only $against |"
)
||
die
"Cannot run git diff-index."
;
open
(
FILES
,
"git diff-index --cached --name-only $against |"
)
||
die
"Cannot run git diff-index."
;
while
(
my
$file
=
<
FILES
>
)
{
while
(
my
$file
=
<
FILES
>
)
{
chomp
(
$file
);
chomp
(
$file
);
if
(
$file
ne
"GNUmakefile"
&&
if
(
$file
ne
"GNUmakefile"
&&
$file
=~
/\.(
c|cpp|cxx|h|hrc|hxx|idl|inl|java|map|MK|pmk|pl|pm|sdi|sh|src|tab|xcu|xml
)$/
)
{
$file
=~
/\.(
$src_exts
)$/
)
{
open
(
F
,
"git diff-index -p --cached $against -- '$file' |"
);
open
(
F
,
"git diff-index -p --cached $against -- '$file' |"
);
while
(
my
$line
=
<
F
>
)
{
while
(
my
$line
=
<
F
>
)
{
if
(
$line
=~
/^\+ *\t/
)
{
if
(
$line
=~
/^\+ *\t/
)
{
...
@@ -186,7 +189,7 @@ EOM
...
@@ -186,7 +189,7 @@ EOM
}
}
# fix whitespace in code
# fix whitespace in code
check_whitespaces
(
$against
);
check_whitespaces
(
$against
,
$src_exts
);
# check the rest of the files
# check the rest of the files
my
$filter_patches
=
`git diff-index --check --cached $against -- | sed '/\.\(diff\|patch\):/,/.*/d'`
;
my
$filter_patches
=
`git diff-index --check --cached $against -- | sed '/\.\(diff\|patch\):/,/.*/d'`
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment