summaryrefslogtreecommitdiff
path: root/tools/check-typo-since
blob: fcd01457a58e49a22c7ae3d9db7baf12e0e53c89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh

#**************************************************************************
#*                                                                        *
#*                                 OCaml                                  *
#*                                                                        *
#*            Gabriel Scherer, projet Parsifal, INRIA Saclay              *
#*                                                                        *
#*   Copyright 2018 Institut National de Recherche en Informatique et     *
#*     en Automatique.                                                    *
#*                                                                        *
#*   All rights reserved.  This file is distributed under the terms of    *
#*   the GNU Lesser General Public License version 2.1, with the          *
#*   special exception on linking described in the file LICENSE.          *
#*                                                                        *
#**************************************************************************

# Run check-typo, comparing only files that have changed since a particular
# git state

check_typo_since() {
  CHECK_TYPO=$(dirname $0)/check-typo
  git diff --name-only $1 \
  | (while IFS= read -r path
  do
    if test -e "$path"; then :; else continue; fi
    $CHECK_TYPO --check-prune "$path" 2>/dev/null
    if test $? -eq 0; then continue; fi
    $CHECK_TYPO "$path"
  done)
}

case $# in
    0) echo "usage: check-typo-since <git reference>"; exit 2;;
    1) check_typo_since $1;;
    *) echo "too many arguments"; exit 2;;
esac