210 |
210 |
211 function spaces_check() { |
211 function spaces_check() { |
212 TMP_FILE=`mktemp` |
212 TMP_FILE=`mktemp` |
213 cat $1 | sed -e 's/ \+$//g' >$TMP_FILE |
213 cat $1 | sed -e 's/ \+$//g' >$TMP_FILE |
214 |
214 |
215 "$ACTION"_action "$TMP_FILE" "$1" 'spaces' |
215 "$ACTION"_action "$TMP_FILE" "$1" 'trailing spaces' |
216 } |
216 } |
217 |
217 |
218 function long_lines_check() { |
218 function long_lines_check() { |
219 if cat $1 | grep -q -E '.{81,}' |
219 if cat $1 | grep -q -E '.{81,}' |
220 then |
220 then |
257 $0 [OPTIONS] [files] |
257 $0 [OPTIONS] [files] |
258 Options: |
258 Options: |
259 --dry-run|-n |
259 --dry-run|-n |
260 Check the given files, but do not modify them. |
260 Check the given files, but do not modify them. |
261 --interactive|-i |
261 --interactive|-i |
262 If --dry-run is specified and files are warned then a message is |
262 If --dry-run is specified and files are warned, then a message is |
263 prompted whether the warnings should be turned to errors. |
263 prompted whether the warnings should be turned to errors. |
264 --werror|-w |
264 --werror|-w |
265 If --dry-run is specified and the warnings are turned to errors. |
265 If --dry-run is specified, the warnings are turned to errors. |
266 --all|-a |
266 --all|-a |
267 All files in the repository will be checked. |
267 Check all source files in the repository. |
268 --modified|-m |
268 --modified|-m |
269 Check only the modified source files. This option is proper to |
269 Check only the modified source files. This option is proper to |
270 use before a commit. E.g. all files which are modified or added |
270 use before a commit. E.g. all files which are modified or added |
271 into the repository will be updated. |
271 into the repository will be updated. |
272 --changed|-c |
272 --changed|-c |
280 pretxncommit.checksources = scripts/unify-sources.sh -c -n -i |
280 pretxncommit.checksources = scripts/unify-sources.sh -c -n -i |
281 |
281 |
282 --help|-h |
282 --help|-h |
283 Print this help message. |
283 Print this help message. |
284 files |
284 files |
285 The files to check/unify. If no file names are given, the |
285 The files to check/unify. If no file names are given, the modified |
286 modified source will be checked/unified |
286 source files will be checked/unified (just like using the |
287 |
287 --modified|-m option). |
288 " |
288 " |
289 exit 0 |
289 exit 0 |
290 elif [ "$1" == '--dry-run' ] || [ "$1" == '-n' ] |
290 elif [ "$1" == '--dry-run' ] || [ "$1" == '-n' ] |
291 then |
291 then |
292 [ -n "$ACTION" ] && echo "Invalid option $1" >&2 && exit 1 |
292 [ -n "$ACTION" ] && echo "Conflicting action options" >&2 && exit 1 |
293 ACTION=check |
293 ACTION=check |
294 elif [ "$1" == "--all" ] || [ "$1" == '-a' ] |
294 elif [ "$1" == "--all" ] || [ "$1" == '-a' ] |
295 then |
295 then |
296 [ -n "$FILES" ] && echo "Invalid option $1" >&2 && exit 1 |
296 [ -n "$FILES" ] && echo "Conflicting target options" >&2 && exit 1 |
297 FILES=all_files |
297 FILES=all_files |
298 elif [ "$1" == "--changed" ] || [ "$1" == '-c' ] |
298 elif [ "$1" == "--changed" ] || [ "$1" == '-c' ] |
299 then |
299 then |
300 [ -n "$FILES" ] && echo "Invalid option $1" >&2 && exit 1 |
300 [ -n "$FILES" ] && echo "Conflicting target options" >&2 && exit 1 |
301 FILES=changed_files |
301 FILES=changed_files |
302 elif [ "$1" == "--modified" ] || [ "$1" == '-m' ] |
302 elif [ "$1" == "--modified" ] || [ "$1" == '-m' ] |
303 then |
303 then |
304 [ -n "$FILES" ] && echo "Invalid option $1" >&2 && exit 1 |
304 [ -n "$FILES" ] && echo "Conflicting target options" >&2 && exit 1 |
305 FILES=modified_files |
305 FILES=modified_files |
306 elif [ "$1" == "--interactive" ] || [ "$1" == "-i" ] |
306 elif [ "$1" == "--interactive" ] || [ "$1" == "-i" ] |
307 then |
307 then |
308 [ -n "$WARNING" ] && echo "Invalid option $1" >&2 && exit 1 |
308 [ -n "$WARNING" ] && echo "Conflicting warning options" >&2 && exit 1 |
309 WARNING='INTERACTIVE' |
309 WARNING='INTERACTIVE' |
310 elif [ "$1" == "--werror" ] || [ "$1" == "-w" ] |
310 elif [ "$1" == "--werror" ] || [ "$1" == "-w" ] |
311 then |
311 then |
312 [ -n "$WARNING" ] && echo "Invalid option $1" >&2 && exit 1 |
312 [ -n "$WARNING" ] && echo "Conflicting warning options" >&2 && exit 1 |
313 WARNING='WERROR' |
313 WARNING='WERROR' |
314 elif [ $(echo $1 | cut -c 1) == '-' ] |
314 elif [ $(echo x$1 | cut -c 2) == '-' ] |
315 then |
315 then |
316 echo "Invalid option $1" >&2 && exit 1 |
316 echo "Invalid option $1" >&2 && exit 1 |
317 else |
317 else |
318 [ -n "$FILES" ] && echo "Invalid option $1" >&2 && exit 1 |
318 [ -n "$FILES" ] && echo "Invalid option $1" >&2 && exit 1 |
319 GIVEN_FILES=$@ |
319 GIVEN_FILES=$@ |