3 # Hook used to indent all source files before commiting
6 # indent / format file by type
8 # getting against as the current commit
9 if git
rev-parse --verify HEAD
>/dev
/null
2>&1
13 # Initial commit: diff against an empty tree object
14 local against
=4b825dc642cb6eb9a060e54bf8d69288fbee4904
17 # loop on modified files
18 git
diff --cached --name-only $against | while read file;
20 local ext
=$(expr "$file" : ".*\(\..*\)")
29 # Indent the file with `indent' if this is a R file
36 echo "Indenting
" $file
37 echo "library
(formatR
);formatR
::tidy_source
('$file',comment
=TRUE
,blank
=TRUE
,
38 arrow
=TRUE
,brace.newline
=TRUE
,indent
=2,width.cutoff
=80,file='$file')" | R --slave